From 2546661aeb27ebdc2db2804e3d7d1ade2373781c Mon Sep 17 00:00:00 2001 From: Mickael Savinaud Date: Thu, 16 Aug 2012 12:29:59 +0000 Subject: [PATCH] remove deprecated v1 style functions j2k_destroy_decompress, j2k_decode_jpt_stream, j2k_destroy_compress and j2k_encode --- libopenjpeg/j2k.c | 376 ---------------------------------------------- libopenjpeg/j2k.h | 27 ---- 2 files changed, 403 deletions(-) diff --git a/libopenjpeg/j2k.c b/libopenjpeg/j2k.c index 4c56df16..14654c6b 100644 --- a/libopenjpeg/j2k.c +++ b/libopenjpeg/j2k.c @@ -6575,56 +6575,6 @@ static opj_bool opj_j2k_read_cbd ( opj_j2k_v2_t *p_j2k, /* J2K / JPT decoder interface */ /* ----------------------------------------------------------------------- */ - - -void j2k_destroy_decompress(opj_j2k_t *j2k) { - int i = 0; - - if(j2k->tile_len != NULL) { - opj_free(j2k->tile_len); - } - if(j2k->tile_data != NULL) { - opj_free(j2k->tile_data); - } - if(j2k->default_tcp != NULL) { - opj_tcp_t *default_tcp = j2k->default_tcp; - if(default_tcp->ppt_data_first != NULL) { - opj_free(default_tcp->ppt_data_first); - } - if(j2k->default_tcp->tccps != NULL) { - opj_free(j2k->default_tcp->tccps); - } - opj_free(j2k->default_tcp); - } - if(j2k->cp != NULL) { - opj_cp_t *cp = j2k->cp; - if(cp->tcps != NULL) { - for(i = 0; i < cp->tw * cp->th; i++) { - if(cp->tcps[i].ppt_data_first != NULL) { - opj_free(cp->tcps[i].ppt_data_first); - } - if(cp->tcps[i].tccps != NULL) { - opj_free(cp->tcps[i].tccps); - } - } - opj_free(cp->tcps); - } - if(cp->ppm_data_first != NULL) { - opj_free(cp->ppm_data_first); - } - if(cp->tileno != NULL) { - opj_free(cp->tileno); - } - if(cp->comment != NULL) { - opj_free(cp->comment); - } - - opj_free(cp); - } - opj_free(j2k); -} - - void opj_j2k_setup_decoder(opj_j2k_v2_t *j2k, opj_dparameters_t *parameters) { if(j2k && parameters) { @@ -6640,91 +6590,6 @@ void opj_j2k_setup_decoder(opj_j2k_v2_t *j2k, opj_dparameters_t *parameters) } - -/* -* Read a JPT-stream and decode file -* -*/ -opj_image_t* j2k_decode_jpt_stream(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *cstr_info) { - opj_image_t *image = NULL; - opj_jpt_msg_header_t header; - int position; - opj_common_ptr cinfo = j2k->cinfo; - - OPJ_ARG_NOT_USED(cstr_info); - - j2k->cio = cio; - - /* create an empty image */ - image = opj_image_create0(); - j2k->image = image; - - j2k->state = J2K_STATE_MHSOC; - - /* Initialize the header */ - jpt_init_msg_header(&header); - /* Read the first header of the message */ - jpt_read_msg_header(cinfo, cio, &header); - - position = cio_tell(cio); - if (header.Class_Id != 6) { /* 6 : Main header data-bin message */ - opj_image_destroy(image); - opj_event_msg(cinfo, EVT_ERROR, "[JPT-stream] : Expecting Main header first [class_Id %d] !\n", header.Class_Id); - return 0; - } - - for (;;) { - opj_dec_mstabent_t *e = NULL; - int id; - - if (!cio_numbytesleft(cio)) { - j2k_read_eoc(j2k); - return image; - } - /* data-bin read -> need to read a new header */ - if ((unsigned int) (cio_tell(cio) - position) == header.Msg_length) { - jpt_read_msg_header(cinfo, cio, &header); - position = cio_tell(cio); - if (header.Class_Id != 4) { /* 4 : Tile data-bin message */ - opj_image_destroy(image); - opj_event_msg(cinfo, EVT_ERROR, "[JPT-stream] : Expecting Tile info !\n"); - return 0; - } - } - - id = cio_read(cio, 2); - if (id >> 8 != 0xff) { - opj_image_destroy(image); - opj_event_msg(cinfo, EVT_ERROR, "%.8x: expected a marker instead of %x\n", cio_tell(cio) - 2, id); - return 0; - } - e = j2k_dec_mstab_lookup(id); - if (!(j2k->state & e->states)) { - opj_image_destroy(image); - opj_event_msg(cinfo, EVT_ERROR, "%.8x: unexpected marker %x\n", cio_tell(cio) - 2, id); - return 0; - } - if (e->handler) { - (*e->handler)(j2k); - } - if (j2k->state == J2K_STATE_MT) { - break; - } - if (j2k->state == J2K_STATE_NEOC) { - break; - } - } - if (j2k->state == J2K_STATE_NEOC) { - j2k_read_eoc(j2k); - } - - if (j2k->state != J2K_STATE_MT) { - opj_event_msg(cinfo, EVT_WARNING, "Incomplete bitstream\n"); - } - - return image; -} - /* ----------------------------------------------------------------------- */ /* J2K encoder interface */ /* ----------------------------------------------------------------------- */ @@ -6774,29 +6639,6 @@ opj_j2k_v2_t* opj_j2k_create_compress_v2(void) return l_j2k; } -void j2k_destroy_compress(opj_j2k_t *j2k) { - int tileno; - - if(!j2k) return; - if(j2k->cp != NULL) { - opj_cp_t *cp = j2k->cp; - - if(cp->comment) { - opj_free(cp->comment); - } - if(cp->matrice) { - opj_free(cp->matrice); - } - for (tileno = 0; tileno < cp->tw * cp->th; tileno++) { - opj_free(cp->tcps[tileno].tccps); - } - opj_free(cp->tcps); - opj_free(cp); - } - - opj_free(j2k); -} - void j2k_setup_encoder(opj_j2k_t *j2k, opj_cparameters_t *parameters, opj_image_t *image) { OPJ_UINT32 i,j; int tileno, numpocs_tile; @@ -7376,225 +7218,7 @@ void opj_j2k_setup_encoder_v2( opj_j2k_v2_t *p_j2k, } -opj_bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info) { - int tileno; - OPJ_UINT32 compno; - opj_cp_t *cp = NULL; - - opj_tcd_t *tcd = NULL; /* TCD component */ - - j2k->cio = cio; - j2k->image = image; - - cp = j2k->cp; - - /* INDEX >> */ - j2k->cstr_info = cstr_info; - if (cstr_info) { - OPJ_UINT32 compno; - cstr_info->tile = (opj_tile_info_t *) opj_malloc(cp->tw * cp->th * sizeof(opj_tile_info_t)); - cstr_info->image_w = image->x1 - image->x0; - cstr_info->image_h = image->y1 - image->y0; - cstr_info->prog = (&cp->tcps[0])->prg; - cstr_info->tw = cp->tw; - cstr_info->th = cp->th; - cstr_info->tile_x = cp->tdx; /* new version parser */ - cstr_info->tile_y = cp->tdy; /* new version parser */ - cstr_info->tile_Ox = cp->tx0; /* new version parser */ - cstr_info->tile_Oy = cp->ty0; /* new version parser */ - cstr_info->numcomps = image->numcomps; - cstr_info->numlayers = (&cp->tcps[0])->numlayers; - cstr_info->numdecompos = (int*) opj_malloc(image->numcomps * sizeof(int)); - for (compno=0; compno < image->numcomps; compno++) { - cstr_info->numdecompos[compno] = (&cp->tcps[0])->tccps->numresolutions - 1; - } - cstr_info->D_max = 0.0; /* ADD Marcela */ - cstr_info->main_head_start = cio_tell(cio); /* position of SOC */ - cstr_info->maxmarknum = 100; - cstr_info->marker = (opj_marker_info_t *) opj_malloc(cstr_info->maxmarknum * sizeof(opj_marker_info_t)); - cstr_info->marknum = 0; - } - /* << INDEX */ - - j2k_write_soc(j2k); - j2k_write_siz(j2k); - j2k_write_cod(j2k); - j2k_write_qcd(j2k); - - if(cp->cinema){ - for (compno = 1; compno < image->numcomps; compno++) { - j2k_write_coc(j2k, compno); - j2k_write_qcc(j2k, compno); - } - } - - for (compno = 0; compno < image->numcomps; compno++) { - opj_tcp_t *tcp = &cp->tcps[0]; - if (tcp->tccps[compno].roishift) - j2k_write_rgn(j2k, compno, 0); - } - if (cp->comment != NULL) { - j2k_write_com(j2k); - } - - j2k->totnum_tp = j2k_calculate_tp(cp,image->numcomps,image,j2k); - /* TLM Marker*/ - if(cp->cinema){ - j2k_write_tlm(j2k); - if (cp->cinema == CINEMA4K_24) { - j2k_write_poc(j2k); - } - } - - /* uncomment only for testing JPSEC marker writing */ - /* j2k_write_sec(j2k); */ - - /* INDEX >> */ - if(cstr_info) { - cstr_info->main_head_end = cio_tell(cio) - 1; - } - /* << INDEX */ - /**** Main Header ENDS here ***/ - - /* create the tile encoder */ - tcd = tcd_create(j2k->cinfo); - - /* encode each tile */ - for (tileno = 0; tileno < cp->tw * cp->th; tileno++) { - int pino; - int tilepartno=0; - /* UniPG>> */ - int acc_pack_num = 0; - /* <tcps[tileno]; - opj_event_msg(j2k->cinfo, EVT_INFO, "tile number %d / %d\n", tileno + 1, cp->tw * cp->th); - - j2k->curtileno = tileno; - j2k->cur_tp_num = 0; - tcd->cur_totnum_tp = j2k->cur_totnum_tp[j2k->curtileno]; - /* initialisation before tile encoding */ - if (tileno == 0) { - tcd_malloc_encode(tcd, image, cp, j2k->curtileno); - } else { - tcd_init_encode(tcd, image, cp, j2k->curtileno); - } - - /* INDEX >> */ - if(cstr_info) { - cstr_info->tile[j2k->curtileno].start_pos = cio_tell(cio) + j2k->pos_correction; - cstr_info->tile[j2k->curtileno].maxmarknum = 10; - cstr_info->tile[j2k->curtileno].marker = (opj_marker_info_t *) opj_malloc(cstr_info->tile[j2k->curtileno].maxmarknum * sizeof(opj_marker_info_t)); - cstr_info->tile[j2k->curtileno].marknum = 0; - } - /* << INDEX */ - - for(pino = 0; pino <= tcp->numpocs; pino++) { - int tot_num_tp; - tcd->cur_pino=pino; - - /*Get number of tile parts*/ - tot_num_tp = j2k_get_num_tp(cp,pino,tileno); - tcd->tp_pos = cp->tp_pos; - - for(tilepartno = 0; tilepartno < tot_num_tp ; tilepartno++){ - j2k->tp_num = tilepartno; - /* INDEX >> */ - if(cstr_info) - cstr_info->tile[j2k->curtileno].tp[j2k->cur_tp_num].tp_start_pos = - cio_tell(cio) + j2k->pos_correction; - /* << INDEX */ - j2k_write_sot(j2k); - - if(j2k->cur_tp_num == 0 && cp->cinema == 0){ - for (compno = 1; compno < image->numcomps; compno++) { - j2k_write_coc(j2k, compno); - j2k_write_qcc(j2k, compno); - } - if (cp->tcps[tileno].numpocs) { - j2k_write_poc(j2k); - } - } - - /* INDEX >> */ - if(cstr_info) - cstr_info->tile[j2k->curtileno].tp[j2k->cur_tp_num].tp_end_header = - cio_tell(cio) + j2k->pos_correction + 1; - /* << INDEX */ - - j2k_write_sod(j2k, tcd); - - /* INDEX >> */ - if(cstr_info) { - cstr_info->tile[j2k->curtileno].tp[j2k->cur_tp_num].tp_end_pos = - cio_tell(cio) + j2k->pos_correction - 1; - cstr_info->tile[j2k->curtileno].tp[j2k->cur_tp_num].tp_start_pack = - acc_pack_num; - cstr_info->tile[j2k->curtileno].tp[j2k->cur_tp_num].tp_numpacks = - cstr_info->packno - acc_pack_num; - acc_pack_num = cstr_info->packno; - } - /* << INDEX */ - - j2k->cur_tp_num++; - } - } - if(cstr_info) { - cstr_info->tile[j2k->curtileno].end_pos = cio_tell(cio) + j2k->pos_correction - 1; - } - - - /* - if (tile->PPT) { // BAD PPT !!! - FILE *PPT_file; - int i; - PPT_file=fopen("PPT","rb"); - fprintf(stderr,"%c%c%c%c",255,97,tile->len_ppt/256,tile->len_ppt%256); - for (i=0;ilen_ppt;i++) { - unsigned char elmt; - fread(&elmt, 1, 1, PPT_file); - fwrite(&elmt,1,1,f); - } - fclose(PPT_file); - unlink("PPT"); - } - */ - - } - - /* destroy the tile encoder */ - tcd_free_encode(tcd); - tcd_destroy(tcd); - - opj_free(j2k->cur_totnum_tp); - - j2k_write_eoc(j2k); - - if(cstr_info) { - cstr_info->codestream_size = cio_tell(cio) + j2k->pos_correction; - /* UniPG>> */ - /* The following adjustment is done to adjust the codestream size */ - /* if SOD is not at 0 in the buffer. Useful in case of JP2, where */ - /* the first bunch of bytes is not in the codestream */ - cstr_info->codestream_size -= cstr_info->main_head_start; - /* <epc_on) { - - /* encode according to JPWL */ - jpwl_encode(j2k, cio, image); - - } -#endif /* USE_JPWL */ - return OPJ_TRUE; -} static void j2k_add_mhmarker(opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len) { diff --git a/libopenjpeg/j2k.h b/libopenjpeg/j2k.h index a1ad194b..7eacebc9 100644 --- a/libopenjpeg/j2k.h +++ b/libopenjpeg/j2k.h @@ -779,11 +779,6 @@ opj_j2k_v2_t; /*@{*/ /* ----------------------------------------------------------------------- */ -/** -Destroy a J2K decompressor handle -@param j2k J2K decompressor handle to destroy -*/ -void j2k_destroy_decompress(opj_j2k_t *j2k); /** Setup the decoder decoding parameters using user parameters. Decoding parameters are returned in j2k->cp. @@ -792,14 +787,6 @@ Decoding parameters are returned in j2k->cp. */ void opj_j2k_setup_decoder(opj_j2k_v2_t *j2k, opj_dparameters_t *parameters); -/** -Decode an image form a JPT-stream (JPEG 2000, JPIP) -@param j2k J2K decompressor handle -@param cio Input buffer stream -@param cstr_info Codestream information structure if required, NULL otherwise -@return Returns a decoded image if successful, returns NULL otherwise -*/ -opj_image_t* j2k_decode_jpt_stream(opj_j2k_t *j2k, opj_cio_t *cio, opj_codestream_info_t *cstr_info); /** Creates a J2K compression structure @param cinfo Codec context info @@ -814,11 +801,6 @@ Creates a J2K compression structure */ opj_j2k_v2_t* opj_j2k_create_compress_v2(void); -/** -Destroy a J2K compressor handle -@param j2k J2K compressor handle to destroy -*/ -void j2k_destroy_compress(opj_j2k_t *j2k); /** Setup the encoder parameters using the current image and using user parameters. Coding parameters are returned in j2k->cp. @@ -837,15 +819,6 @@ void opj_j2k_setup_encoder_v2( opj_j2k_v2_t *p_j2k, Converts an enum type progression order to string type */ char *j2k_convert_progression_order(OPJ_PROG_ORDER prg_order); -/** -Encode an image into a JPEG-2000 codestream -@param j2k J2K compressor handle -@param cio Output buffer stream -@param image Image to encode -@param cstr_info Codestream information structure if required, NULL otherwise -@return Returns true if successful, returns false otherwise -*/ -opj_bool j2k_encode(opj_j2k_t *j2k, opj_cio_t *cio, opj_image_t *image, opj_codestream_info_t *cstr_info); /* ----------------------------------------------------------------------- */ /*@}*/ -- 2.40.0