Lines Matching refs:p_j2k

54 static OPJ_BOOL opj_j2k_setup_header_reading (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager);
59 static OPJ_BOOL opj_j2k_read_header_procedure( opj_j2k_t *p_j2k,
72 static OPJ_BOOL opj_j2k_encoding_validation ( opj_j2k_t * p_j2k,
85 static OPJ_BOOL opj_j2k_decoding_validation ( opj_j2k_t * p_j2k,
93 static OPJ_BOOL opj_j2k_setup_encoding_validation (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager);
99 static OPJ_BOOL opj_j2k_setup_decoding_validation (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager);
105 static OPJ_BOOL opj_j2k_setup_end_compress (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager);
116 static OPJ_BOOL opj_j2k_mct_validation (opj_j2k_t * p_j2k,
123 static OPJ_BOOL opj_j2k_build_decoder ( opj_j2k_t * p_j2k,
129 static OPJ_BOOL opj_j2k_build_encoder ( opj_j2k_t * p_j2k,
140 static OPJ_BOOL opj_j2k_create_tcd( opj_j2k_t *p_j2k,
154 static OPJ_BOOL opj_j2k_exec ( opj_j2k_t * p_j2k,
166 static OPJ_BOOL opj_j2k_update_rates( opj_j2k_t *p_j2k,
174 static OPJ_BOOL opj_j2k_copy_default_tcp_and_create_tcd ( opj_j2k_t * p_j2k,
181 static OPJ_BOOL opj_j2k_destroy_header_memory ( opj_j2k_t * p_j2k,
227 static OPJ_BOOL opj_j2k_write_SPCod_SPCoc( opj_j2k_t *p_j2k,
243 static OPJ_UINT32 opj_j2k_get_SPCod_SPCoc_size (opj_j2k_t *p_j2k,
255 static OPJ_BOOL opj_j2k_read_SPCod_SPCoc( opj_j2k_t *p_j2k,
270 static OPJ_UINT32 opj_j2k_get_SQcd_SQcc_size ( opj_j2k_t *p_j2k,
285 static OPJ_BOOL opj_j2k_write_SQcd_SQcc(opj_j2k_t *p_j2k,
295 static void opj_j2k_update_tlm ( opj_j2k_t * p_j2k, OPJ_UINT32 p_tile_part_size);
307 static OPJ_BOOL opj_j2k_read_SQcd_SQcc( opj_j2k_t *p_j2k,
318 static void opj_j2k_copy_tile_component_parameters( opj_j2k_t *p_j2k );
325 static void opj_j2k_copy_tile_quantization_parameters( opj_j2k_t *p_j2k );
330 static OPJ_BOOL opj_j2k_decode_tiles ( opj_j2k_t *p_j2k,
334 static OPJ_BOOL opj_j2k_pre_write_tile ( opj_j2k_t * p_j2k,
355 static OPJ_BOOL opj_j2k_post_write_tile (opj_j2k_t * p_j2k,
363 static OPJ_BOOL opj_j2k_setup_header_writing (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager);
365 static OPJ_BOOL opj_j2k_write_first_tile_part( opj_j2k_t *p_j2k,
372 static OPJ_BOOL opj_j2k_write_all_tile_parts( opj_j2k_t *p_j2k,
386 static OPJ_BOOL opj_j2k_get_end_header( opj_j2k_t *p_j2k,
390 static OPJ_BOOL opj_j2k_allocate_tile_element_cstr_index(opj_j2k_t *p_j2k);
405 static OPJ_BOOL opj_j2k_write_soc( opj_j2k_t *p_j2k,
415 static OPJ_BOOL opj_j2k_read_soc( opj_j2k_t *p_j2k,
426 static OPJ_BOOL opj_j2k_write_siz( opj_j2k_t *p_j2k,
437 static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k,
449 static OPJ_BOOL opj_j2k_write_com( opj_j2k_t *p_j2k,
460 static OPJ_BOOL opj_j2k_read_com ( opj_j2k_t *p_j2k,
471 static OPJ_BOOL opj_j2k_write_cod( opj_j2k_t *p_j2k,
482 static OPJ_BOOL opj_j2k_read_cod ( opj_j2k_t *p_j2k,
496 static OPJ_BOOL opj_j2k_write_coc( opj_j2k_t *p_j2k,
512 static void opj_j2k_write_coc_in_memory(opj_j2k_t *p_j2k,
524 static OPJ_UINT32 opj_j2k_get_max_coc_size(opj_j2k_t *p_j2k);
533 static OPJ_BOOL opj_j2k_read_coc ( opj_j2k_t *p_j2k,
545 static OPJ_BOOL opj_j2k_write_qcd( opj_j2k_t *p_j2k,
556 static OPJ_BOOL opj_j2k_read_qcd ( opj_j2k_t *p_j2k,
569 static OPJ_BOOL opj_j2k_write_qcc( opj_j2k_t *p_j2k,
585 static void opj_j2k_write_qcc_in_memory(opj_j2k_t *p_j2k,
595 static OPJ_UINT32 opj_j2k_get_max_qcc_size (opj_j2k_t *p_j2k);
604 static OPJ_BOOL opj_j2k_read_qcc( opj_j2k_t *p_j2k,
615 static OPJ_BOOL opj_j2k_write_poc( opj_j2k_t *p_j2k,
626 static void opj_j2k_write_poc_in_memory(opj_j2k_t *p_j2k,
633 static OPJ_UINT32 opj_j2k_get_max_poc_size(opj_j2k_t *p_j2k);
643 static OPJ_BOOL opj_j2k_read_poc ( opj_j2k_t *p_j2k,
651 static OPJ_UINT32 opj_j2k_get_max_toc_size (opj_j2k_t *p_j2k);
658 static OPJ_UINT32 opj_j2k_get_specific_header_sizes(opj_j2k_t *p_j2k);
668 static OPJ_BOOL opj_j2k_read_crg ( opj_j2k_t *p_j2k,
680 static OPJ_BOOL opj_j2k_read_tlm ( opj_j2k_t *p_j2k,
692 static OPJ_BOOL opj_j2k_write_updated_tlm( opj_j2k_t *p_j2k,
704 static OPJ_BOOL opj_j2k_read_plm ( opj_j2k_t *p_j2k,
716 static OPJ_BOOL opj_j2k_read_plt ( opj_j2k_t *p_j2k,
731 opj_j2k_t *p_j2k,
752 static OPJ_BOOL opj_j2k_read_ppt ( opj_j2k_t *p_j2k,
774 static OPJ_BOOL opj_j2k_write_tlm( opj_j2k_t *p_j2k,
787 static OPJ_BOOL opj_j2k_write_sot( opj_j2k_t *p_j2k,
821 static OPJ_BOOL opj_j2k_read_sot ( opj_j2k_t *p_j2k,
836 static OPJ_BOOL opj_j2k_write_sod( opj_j2k_t *p_j2k,
851 static OPJ_BOOL opj_j2k_read_sod( opj_j2k_t *p_j2k,
855 static void opj_j2k_update_tlm (opj_j2k_t * p_j2k, OPJ_UINT32 p_tile_part_size ) in opj_j2k_update_tlm() argument
857 …opj_write_bytes(p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current,p_j2k->m_current_tile_… in opj_j2k_update_tlm()
858 ++p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current; in opj_j2k_update_tlm()
860 …opj_write_bytes(p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current,p_tile_part_size,4); … in opj_j2k_update_tlm()
861 p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current += 4; in opj_j2k_update_tlm()
874 static OPJ_BOOL opj_j2k_write_rgn( opj_j2k_t *p_j2k,
889 static OPJ_BOOL opj_j2k_read_rgn (opj_j2k_t *p_j2k,
901 static OPJ_BOOL opj_j2k_write_eoc( opj_j2k_t *p_j2k,
913 static OPJ_BOOL opj_j2k_read_eoc ( opj_j2k_t *p_j2k,
925 static OPJ_BOOL opj_j2k_write_mct_data_group( opj_j2k_t *p_j2k,
936 static OPJ_BOOL opj_j2k_init_info( opj_j2k_t *p_j2k,
968 static OPJ_BOOL opj_j2k_read_unk( opj_j2k_t *p_j2k,
981 static OPJ_BOOL opj_j2k_write_mct_record( opj_j2k_t *p_j2k,
994 static OPJ_BOOL opj_j2k_read_mct ( opj_j2k_t *p_j2k,
1007 static OPJ_BOOL opj_j2k_write_mcc_record( opj_j2k_t *p_j2k,
1020 static OPJ_BOOL opj_j2k_read_mcc ( opj_j2k_t *p_j2k,
1032 static OPJ_BOOL opj_j2k_write_mco( opj_j2k_t *p_j2k,
1044 static OPJ_BOOL opj_j2k_read_mco ( opj_j2k_t *p_j2k,
1073 static OPJ_BOOL opj_j2k_end_encoding( opj_j2k_t *p_j2k,
1084 static OPJ_BOOL opj_j2k_write_cbd( opj_j2k_t *p_j2k,
1095 static OPJ_BOOL opj_j2k_read_cbd ( opj_j2k_t *p_j2k,
1108 static OPJ_BOOL opj_j2k_write_all_coc( opj_j2k_t *p_j2k,
1121 static OPJ_BOOL opj_j2k_write_all_qcc( opj_j2k_t *p_j2k,
1133 static OPJ_BOOL opj_j2k_write_regions( opj_j2k_t *p_j2k,
1144 static OPJ_BOOL opj_j2k_write_epc( opj_j2k_t *p_j2k,
1191 static OPJ_BOOL opj_j2k_calculate_tp( opj_j2k_t *p_j2k,
1197 static void opj_j2k_dump_MH_info(opj_j2k_t* p_j2k, FILE* out_stream);
1199 static void opj_j2k_dump_MH_index(opj_j2k_t* p_j2k, FILE* out_stream);
1288 OPJ_BOOL (*handler) ( opj_j2k_t *p_j2k,
1696 static OPJ_BOOL opj_j2k_calculate_tp( opj_j2k_t *p_j2k, in opj_j2k_calculate_tp() argument
1711 assert(p_j2k != 00); in opj_j2k_calculate_tp()
1774 static OPJ_BOOL opj_j2k_write_soc( opj_j2k_t *p_j2k, in opj_j2k_write_soc() argument
1783 assert(p_j2k != 00); in opj_j2k_write_soc()
1786 l_start_stream = p_j2k->m_specific_param.m_encoder.m_header_tile_data; in opj_j2k_write_soc()
1814 static OPJ_BOOL opj_j2k_read_soc( opj_j2k_t *p_j2k, in opj_j2k_read_soc() argument
1823 assert(p_j2k != 00); in opj_j2k_read_soc()
1837 p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_MHSIZ; in opj_j2k_read_soc()
1840 p_j2k->cstr_index->main_head_start = opj_stream_tell(p_stream) - 2; in opj_j2k_read_soc()
1842 …opj_event_msg(p_manager, EVT_INFO, "Start to read j2k main header (%d).\n", p_j2k->cstr_index->mai… in opj_j2k_read_soc()
1845 …if (OPJ_FALSE == opj_j2k_add_mhmarker(p_j2k->cstr_index, J2K_MS_SOC, p_j2k->cstr_index->main_head_… in opj_j2k_read_soc()
1852 static OPJ_BOOL opj_j2k_write_siz( opj_j2k_t *p_j2k, in opj_j2k_write_siz() argument
1865 assert(p_j2k != 00); in opj_j2k_write_siz()
1868 l_image = p_j2k->m_private_image; in opj_j2k_write_siz()
1869 cp = &(p_j2k->m_cp); in opj_j2k_write_siz()
1873 if (l_size_len > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) { in opj_j2k_write_siz()
1875 …OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_encoder.m_head… in opj_j2k_write_siz()
1877 opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data); in opj_j2k_write_siz()
1878 p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL; in opj_j2k_write_siz()
1879 p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0; in opj_j2k_write_siz()
1883 p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data; in opj_j2k_write_siz()
1884 p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_size_len; in opj_j2k_write_siz()
1887 l_current_ptr = p_j2k->m_specific_param.m_encoder.m_header_tile_data; in opj_j2k_write_siz()
1940 …if (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_size_len… in opj_j2k_write_siz()
1954 static OPJ_BOOL opj_j2k_read_siz(opj_j2k_t *p_j2k, in opj_j2k_read_siz() argument
1972 assert(p_j2k != 00); in opj_j2k_read_siz()
1976 l_image = p_j2k->m_private_image; in opj_j2k_read_siz()
1977 l_cp = &(p_j2k->m_cp); in opj_j2k_read_siz()
2177 if (p_j2k->m_specific_param.m_decoder.m_discard_tiles) { in opj_j2k_read_siz()
2178p_j2k->m_specific_param.m_decoder.m_start_tile_x = (p_j2k->m_specific_param.m_decoder.m_start_tile… in opj_j2k_read_siz()
2179p_j2k->m_specific_param.m_decoder.m_start_tile_y = (p_j2k->m_specific_param.m_decoder.m_start_tile… in opj_j2k_read_siz()
2180p_j2k->m_specific_param.m_decoder.m_end_tile_x = opj_uint_ceildiv(p_j2k->m_specific_param.m_decode… in opj_j2k_read_siz()
2181p_j2k->m_specific_param.m_decoder.m_end_tile_y = opj_uint_ceildiv(p_j2k->m_specific_param.m_decode… in opj_j2k_read_siz()
2184 p_j2k->m_specific_param.m_decoder.m_start_tile_x = 0; in opj_j2k_read_siz()
2185 p_j2k->m_specific_param.m_decoder.m_start_tile_y = 0; in opj_j2k_read_siz()
2186 p_j2k->m_specific_param.m_decoder.m_end_tile_x = l_cp->tw; in opj_j2k_read_siz()
2187 p_j2k->m_specific_param.m_decoder.m_end_tile_y = l_cp->th; in opj_j2k_read_siz()
2250 p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps = in opj_j2k_read_siz()
2252 if(p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps == 00) { in opj_j2k_read_siz()
2257 p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mct_records = in opj_j2k_read_siz()
2260 if (! p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mct_records) { in opj_j2k_read_siz()
2264p_j2k->m_specific_param.m_decoder.m_default_tcp->m_nb_max_mct_records = OPJ_J2K_MCT_DEFAULT_NB_REC… in opj_j2k_read_siz()
2266 p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mcc_records = in opj_j2k_read_siz()
2270 if (! p_j2k->m_specific_param.m_decoder.m_default_tcp->m_mcc_records) { in opj_j2k_read_siz()
2274p_j2k->m_specific_param.m_decoder.m_default_tcp->m_nb_max_mcc_records = OPJ_J2K_MCC_DEFAULT_NB_REC… in opj_j2k_read_siz()
2279p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps[i].m_dc_level_shift = 1 << (l_image->comps[… in opj_j2k_read_siz()
2294 p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_MH; /* FIXME J2K_DEC_STATE_MH; */ in opj_j2k_read_siz()
2300 static OPJ_BOOL opj_j2k_write_com( opj_j2k_t *p_j2k, in opj_j2k_write_com() argument
2311 assert(p_j2k != 00); in opj_j2k_write_com()
2315 l_comment = p_j2k->m_cp.comment; in opj_j2k_write_com()
2319 if (l_total_com_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) { in opj_j2k_write_com()
2320 …OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_encoder.m_head… in opj_j2k_write_com()
2322 opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data); in opj_j2k_write_com()
2323 p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL; in opj_j2k_write_com()
2324 p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0; in opj_j2k_write_com()
2328 p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data; in opj_j2k_write_com()
2329 p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_total_com_size; in opj_j2k_write_com()
2332 l_current_ptr = p_j2k->m_specific_param.m_encoder.m_header_tile_data; in opj_j2k_write_com()
2345 …if (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_total_co… in opj_j2k_write_com()
2359 static OPJ_BOOL opj_j2k_read_com ( opj_j2k_t *p_j2k, in opj_j2k_read_com() argument
2366 assert(p_j2k != 00); in opj_j2k_read_com()
2374 static OPJ_BOOL opj_j2k_write_cod( opj_j2k_t *p_j2k, in opj_j2k_write_cod() argument
2384 assert(p_j2k != 00); in opj_j2k_write_cod()
2388 l_cp = &(p_j2k->m_cp); in opj_j2k_write_cod()
2389 l_tcp = &l_cp->tcps[p_j2k->m_current_tile_number]; in opj_j2k_write_cod()
2390 l_code_size = 9 + opj_j2k_get_SPCod_SPCoc_size(p_j2k,p_j2k->m_current_tile_number,0); in opj_j2k_write_cod()
2393 if (l_code_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) { in opj_j2k_write_cod()
2394 …OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_encoder.m_head… in opj_j2k_write_cod()
2396 opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data); in opj_j2k_write_cod()
2397 p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL; in opj_j2k_write_cod()
2398 p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0; in opj_j2k_write_cod()
2402 p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data; in opj_j2k_write_cod()
2403 p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_code_size; in opj_j2k_write_cod()
2406 l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data; in opj_j2k_write_cod()
2428 …if (! opj_j2k_write_SPCod_SPCoc(p_j2k,p_j2k->m_current_tile_number,0,l_current_data,&l_remaining_s… in opj_j2k_write_cod()
2438 …if (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_code_siz… in opj_j2k_write_cod()
2452 static OPJ_BOOL opj_j2k_read_cod ( opj_j2k_t *p_j2k, in opj_j2k_read_cod() argument
2467 assert(p_j2k != 00); in opj_j2k_read_cod()
2470 l_image = p_j2k->m_private_image; in opj_j2k_read_cod()
2471 l_cp = &(p_j2k->m_cp); in opj_j2k_read_cod()
2474 l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH) ? in opj_j2k_read_cod()
2475 &l_cp->tcps[p_j2k->m_current_tile_number] : in opj_j2k_read_cod()
2476 p_j2k->m_specific_param.m_decoder.m_default_tcp; in opj_j2k_read_cod()
2530 if (! opj_j2k_read_SPCod_SPCoc(p_j2k,0,p_header_data,&p_header_size,p_manager)) { in opj_j2k_read_cod()
2541 opj_j2k_copy_tile_component_parameters(p_j2k); in opj_j2k_read_cod()
2545 if (p_j2k->cstr_info) { in opj_j2k_read_cod()
2547 p_j2k->cstr_info->prog = l_tcp->prg; in opj_j2k_read_cod()
2548 p_j2k->cstr_info->numlayers = l_tcp->numlayers; in opj_j2k_read_cod()
2549p_j2k->cstr_info->numdecompos = (OPJ_INT32*) opj_malloc(l_image->numcomps * sizeof(OPJ_UINT32)); in opj_j2k_read_cod()
2551 p_j2k->cstr_info->numdecompos[i] = l_tcp->tccps[i].numresolutions - 1; in opj_j2k_read_cod()
2560 static OPJ_BOOL opj_j2k_write_coc( opj_j2k_t *p_j2k,
2569 assert(p_j2k != 00);
2573 l_comp_room = (p_j2k->m_private_image->numcomps <= 256) ? 1 : 2;
2575 …l_coc_size = 5 + l_comp_room + opj_j2k_get_SPCod_SPCoc_size(p_j2k,p_j2k->m_current_tile_number,p_c…
2577 if (l_coc_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
2584 …new_header_tile_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_encoder.m_header_tile_da…
2586 opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
2587 p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;
2588 p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
2592 p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
2593 p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_coc_size;
2596 …opj_j2k_write_coc_in_memory(p_j2k,p_comp_no,p_j2k->m_specific_param.m_encoder.m_header_tile_data,&…
2598 …if (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_coc_size…
2607 static void opj_j2k_write_coc_in_memory( opj_j2k_t *p_j2k,
2622 assert(p_j2k != 00);
2625 l_cp = &(p_j2k->m_cp);
2626 l_tcp = &l_cp->tcps[p_j2k->m_current_tile_number];
2627 l_image = p_j2k->m_private_image;
2630 …l_coc_size = 5 + l_comp_room + opj_j2k_get_SPCod_SPCoc_size(p_j2k,p_j2k->m_current_tile_number,p_c…
2648 …opj_j2k_write_SPCod_SPCoc(p_j2k,p_j2k->m_current_tile_number,0,l_current_data,&l_remaining_size,p_…
2653 static OPJ_UINT32 opj_j2k_get_max_coc_size(opj_j2k_t *p_j2k) in opj_j2k_get_max_coc_size() argument
2662 l_nb_tiles = p_j2k->m_cp.tw * p_j2k->m_cp.th ; in opj_j2k_get_max_coc_size()
2663 l_nb_comp = p_j2k->m_private_image->numcomps; in opj_j2k_get_max_coc_size()
2667 l_max = opj_uint_max(l_max,opj_j2k_get_SPCod_SPCoc_size(p_j2k,i,j)); in opj_j2k_get_max_coc_size()
2681 static OPJ_BOOL opj_j2k_read_coc ( opj_j2k_t *p_j2k, in opj_j2k_read_coc() argument
2695 assert(p_j2k != 00); in opj_j2k_read_coc()
2698 l_cp = &(p_j2k->m_cp); in opj_j2k_read_coc()
2699 …l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH ) ? /*FIXME J2K_DEC_STATE_TPH*/ in opj_j2k_read_coc()
2700 &l_cp->tcps[p_j2k->m_current_tile_number] : in opj_j2k_read_coc()
2701 p_j2k->m_specific_param.m_decoder.m_default_tcp; in opj_j2k_read_coc()
2702 l_image = p_j2k->m_private_image; in opj_j2k_read_coc()
2723 if (! opj_j2k_read_SPCod_SPCoc(p_j2k,l_comp_no,p_header_data,&p_header_size,p_manager)) { in opj_j2k_read_coc()
2735 static OPJ_BOOL opj_j2k_write_qcd( opj_j2k_t *p_j2k, in opj_j2k_write_qcd() argument
2744 assert(p_j2k != 00); in opj_j2k_write_qcd()
2748 l_qcd_size = 4 + opj_j2k_get_SQcd_SQcc_size(p_j2k,p_j2k->m_current_tile_number,0); in opj_j2k_write_qcd()
2751 if (l_qcd_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) { in opj_j2k_write_qcd()
2752 …OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_encoder.m_head… in opj_j2k_write_qcd()
2754 opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data); in opj_j2k_write_qcd()
2755 p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL; in opj_j2k_write_qcd()
2756 p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0; in opj_j2k_write_qcd()
2760 p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data; in opj_j2k_write_qcd()
2761 p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_qcd_size; in opj_j2k_write_qcd()
2764 l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data; in opj_j2k_write_qcd()
2774 …if (! opj_j2k_write_SQcd_SQcc(p_j2k,p_j2k->m_current_tile_number,0,l_current_data,&l_remaining_siz… in opj_j2k_write_qcd()
2784 …if (opj_stream_write_data(p_stream, p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_qcd_siz… in opj_j2k_write_qcd()
2798 static OPJ_BOOL opj_j2k_read_qcd ( opj_j2k_t *p_j2k, in opj_j2k_read_qcd() argument
2806 assert(p_j2k != 00); in opj_j2k_read_qcd()
2809 if (! opj_j2k_read_SQcd_SQcc(p_j2k,0,p_header_data,&p_header_size,p_manager)) { in opj_j2k_read_qcd()
2820 opj_j2k_copy_tile_quantization_parameters(p_j2k); in opj_j2k_read_qcd()
2826 static OPJ_BOOL opj_j2k_write_qcc( opj_j2k_t *p_j2k,
2835 assert(p_j2k != 00);
2839 l_qcc_size = 5 + opj_j2k_get_SQcd_SQcc_size(p_j2k,p_j2k->m_current_tile_number,p_comp_no);
2840 l_qcc_size += p_j2k->m_private_image->numcomps <= 256 ? 0:1;
2843 if (l_qcc_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) {
2844 …OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_encoder.m_head…
2846 opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data);
2847 p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL;
2848 p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0;
2852 p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data;
2853 p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_qcc_size;
2856 …opj_j2k_write_qcc_in_memory(p_j2k,p_comp_no,p_j2k->m_specific_param.m_encoder.m_header_tile_data,&…
2858 …if (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_qcc_size…
2867 static void opj_j2k_write_qcc_in_memory( opj_j2k_t *p_j2k,
2878 assert(p_j2k != 00);
2881 l_qcc_size = 6 + opj_j2k_get_SQcd_SQcc_size(p_j2k,p_j2k->m_current_tile_number,p_comp_no);
2889 if (p_j2k->m_private_image->numcomps <= 256) {
2911 …opj_j2k_write_SQcd_SQcc(p_j2k,p_j2k->m_current_tile_number,p_comp_no,l_current_data,&l_remaining_s…
2917 static OPJ_UINT32 opj_j2k_get_max_qcc_size (opj_j2k_t *p_j2k) in opj_j2k_get_max_qcc_size() argument
2919 return opj_j2k_get_max_coc_size(p_j2k); in opj_j2k_get_max_qcc_size()
2929 static OPJ_BOOL opj_j2k_read_qcc( opj_j2k_t *p_j2k, in opj_j2k_read_qcc() argument
2939 assert(p_j2k != 00); in opj_j2k_read_qcc()
2942 l_num_comp = p_j2k->m_private_image->numcomps; in opj_j2k_read_qcc()
2964 if (p_j2k->m_cp.correct) { in opj_j2k_read_qcc()
2989 if (l_comp_no >= p_j2k->m_private_image->numcomps) { in opj_j2k_read_qcc()
2992 l_comp_no, p_j2k->m_private_image->numcomps); in opj_j2k_read_qcc()
2996 if (! opj_j2k_read_SQcd_SQcc(p_j2k,l_comp_no,p_header_data,&p_header_size,p_manager)) { in opj_j2k_read_qcc()
3009 static OPJ_BOOL opj_j2k_write_poc( opj_j2k_t *p_j2k, in opj_j2k_write_poc() argument
3022 assert(p_j2k != 00); in opj_j2k_write_poc()
3026 l_tcp = &p_j2k->m_cp.tcps[p_j2k->m_current_tile_number]; in opj_j2k_write_poc()
3027 l_nb_comp = p_j2k->m_private_image->numcomps; in opj_j2k_write_poc()
3038 if (l_poc_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) { in opj_j2k_write_poc()
3039 …OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_encoder.m_head… in opj_j2k_write_poc()
3041 opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data); in opj_j2k_write_poc()
3042 p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL; in opj_j2k_write_poc()
3043 p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0; in opj_j2k_write_poc()
3047 p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data; in opj_j2k_write_poc()
3048 p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_poc_size; in opj_j2k_write_poc()
3051 …opj_j2k_write_poc_in_memory(p_j2k,p_j2k->m_specific_param.m_encoder.m_header_tile_data,&l_written_… in opj_j2k_write_poc()
3053 …if (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_poc_size… in opj_j2k_write_poc()
3060 static void opj_j2k_write_poc_in_memory( opj_j2k_t *p_j2k, in opj_j2k_write_poc_in_memory() argument
3078 assert(p_j2k != 00); in opj_j2k_write_poc_in_memory()
3081 l_tcp = &p_j2k->m_cp.tcps[p_j2k->m_current_tile_number]; in opj_j2k_write_poc_in_memory()
3083 l_image = p_j2k->m_private_image; in opj_j2k_write_poc_in_memory()
3135 static OPJ_UINT32 opj_j2k_get_max_poc_size(opj_j2k_t *p_j2k) in opj_j2k_get_max_poc_size() argument
3142 l_tcp = p_j2k->m_cp.tcps; in opj_j2k_get_max_poc_size()
3143 l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw; in opj_j2k_get_max_poc_size()
3155 static OPJ_UINT32 opj_j2k_get_max_toc_size (opj_j2k_t *p_j2k) in opj_j2k_get_max_toc_size() argument
3162 l_tcp = p_j2k->m_cp.tcps; in opj_j2k_get_max_toc_size()
3163 l_nb_tiles = p_j2k->m_cp.tw * p_j2k->m_cp.th ; in opj_j2k_get_max_toc_size()
3174 static OPJ_UINT32 opj_j2k_get_specific_header_sizes(opj_j2k_t *p_j2k) in opj_j2k_get_specific_header_sizes() argument
3180 l_nb_comps = p_j2k->m_private_image->numcomps - 1; in opj_j2k_get_specific_header_sizes()
3181 l_nb_bytes += opj_j2k_get_max_toc_size(p_j2k); in opj_j2k_get_specific_header_sizes()
3183 if (!(OPJ_IS_CINEMA(p_j2k->m_cp.rsiz))) { in opj_j2k_get_specific_header_sizes()
3184 l_coc_bytes = opj_j2k_get_max_coc_size(p_j2k); in opj_j2k_get_specific_header_sizes()
3187 l_qcc_bytes = opj_j2k_get_max_qcc_size(p_j2k); in opj_j2k_get_specific_header_sizes()
3191 l_nb_bytes += opj_j2k_get_max_poc_size(p_j2k); in opj_j2k_get_specific_header_sizes()
3206 static OPJ_BOOL opj_j2k_read_poc ( opj_j2k_t *p_j2k, in opj_j2k_read_poc() argument
3223 assert(p_j2k != 00); in opj_j2k_read_poc()
3226 l_image = p_j2k->m_private_image; in opj_j2k_read_poc()
3243 l_cp = &(p_j2k->m_cp); in opj_j2k_read_poc()
3244 l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH) ? in opj_j2k_read_poc()
3245 &l_cp->tcps[p_j2k->m_current_tile_number] : in opj_j2k_read_poc()
3246 p_j2k->m_specific_param.m_decoder.m_default_tcp; in opj_j2k_read_poc()
3294 static OPJ_BOOL opj_j2k_read_crg ( opj_j2k_t *p_j2k, in opj_j2k_read_crg() argument
3303 assert(p_j2k != 00); in opj_j2k_read_crg()
3306 l_nb_comp = p_j2k->m_private_image->numcomps; in opj_j2k_read_crg()
3334 static OPJ_BOOL opj_j2k_read_tlm ( opj_j2k_t *p_j2k, in opj_j2k_read_tlm() argument
3343 assert(p_j2k != 00); in opj_j2k_read_tlm()
3390 static OPJ_BOOL opj_j2k_read_plm ( opj_j2k_t *p_j2k, in opj_j2k_read_plm() argument
3398 assert(p_j2k != 00); in opj_j2k_read_plm()
3460 static OPJ_BOOL opj_j2k_read_plt ( opj_j2k_t *p_j2k, in opj_j2k_read_plt() argument
3470 assert(p_j2k != 00); in opj_j2k_read_plt()
3514 opj_j2k_t *p_j2k, in opj_j2k_read_ppm() argument
3524 assert(p_j2k != 00); in opj_j2k_read_ppm()
3533 l_cp = &(p_j2k->m_cp); in opj_j2k_read_ppm()
3728 static OPJ_BOOL opj_j2k_read_ppt ( opj_j2k_t *p_j2k, in opj_j2k_read_ppt() argument
3740 assert(p_j2k != 00); in opj_j2k_read_ppt()
3749 l_cp = &(p_j2k->m_cp); in opj_j2k_read_ppt()
3755 l_tcp = &(l_cp->tcps[p_j2k->m_current_tile_number]); in opj_j2k_read_ppt()
3854 static OPJ_BOOL opj_j2k_write_tlm( opj_j2k_t *p_j2k, in opj_j2k_write_tlm() argument
3863 assert(p_j2k != 00); in opj_j2k_write_tlm()
3867 l_tlm_size = 6 + (5*p_j2k->m_specific_param.m_encoder.m_total_tile_parts); in opj_j2k_write_tlm()
3869 if (l_tlm_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) { in opj_j2k_write_tlm()
3870 …OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_encoder.m_head… in opj_j2k_write_tlm()
3872 opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data); in opj_j2k_write_tlm()
3873 p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL; in opj_j2k_write_tlm()
3874 p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0; in opj_j2k_write_tlm()
3878 p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data; in opj_j2k_write_tlm()
3879 p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_tlm_size; in opj_j2k_write_tlm()
3882 l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data; in opj_j2k_write_tlm()
3886 p_j2k->m_specific_param.m_encoder.m_tlm_start = opj_stream_tell(p_stream); in opj_j2k_write_tlm()
3901 …if (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_tlm_size… in opj_j2k_write_tlm()
3908 static OPJ_BOOL opj_j2k_write_sot( opj_j2k_t *p_j2k, in opj_j2k_write_sot() argument
3916 assert(p_j2k != 00); in opj_j2k_write_sot()
3926 opj_write_bytes(p_data, p_j2k->m_current_tile_number,2); /* Isot */ in opj_j2k_write_sot()
3932 …opj_write_bytes(p_data, p_j2k->m_specific_param.m_encoder.m_current_tile_part_number,1); … in opj_j2k_write_sot()
3935 …opj_write_bytes(p_data, p_j2k->m_cp.tcps[p_j2k->m_current_tile_number].m_nb_tile_parts,1); … in opj_j2k_write_sot()
3981 static OPJ_BOOL opj_j2k_read_sot ( opj_j2k_t *p_j2k, in opj_j2k_read_sot() argument
3994 assert(p_j2k != 00); in opj_j2k_read_sot()
3997 …if (! opj_j2k_get_sot_values(p_header_data, p_header_size, &(p_j2k->m_current_tile_number), &l_tot… in opj_j2k_read_sot()
4002 l_cp = &(p_j2k->m_cp); in opj_j2k_read_sot()
4005 if (p_j2k->m_current_tile_number >= l_cp->tw * l_cp->th) { in opj_j2k_read_sot()
4006 … opj_event_msg(p_manager, EVT_ERROR, "Invalid tile number %d\n", p_j2k->m_current_tile_number); in opj_j2k_read_sot()
4010 l_tcp = &l_cp->tcps[p_j2k->m_current_tile_number]; in opj_j2k_read_sot()
4011 l_tile_x = p_j2k->m_current_tile_number % l_cp->tw; in opj_j2k_read_sot()
4012 l_tile_y = p_j2k->m_current_tile_number / l_cp->tw; in opj_j2k_read_sot()
4017 OPJ_UINT32 tileno = p_j2k->m_current_tile_number; in opj_j2k_read_sot()
4084 p_j2k->m_specific_param.m_decoder.m_last_tile_part = 1; in opj_j2k_read_sot()
4088 l_num_parts += p_j2k->m_specific_param.m_decoder.m_nb_tile_parts_correction; in opj_j2k_read_sot()
4095 p_j2k->m_specific_param.m_decoder.m_last_tile_part = 1; in opj_j2k_read_sot()
4103 p_j2k->m_specific_param.m_decoder.m_last_tile_part = 1; in opj_j2k_read_sot()
4112p_j2k->m_specific_param.m_decoder.m_can_decode = 1; /* Process the last tile-part header*/ in opj_j2k_read_sot()
4116 if (!p_j2k->m_specific_param.m_decoder.m_last_tile_part){ in opj_j2k_read_sot()
4118p_j2k->m_specific_param.m_decoder.m_sot_length = l_tot_len - 12; /* SOT_marker_size = 12 */ in opj_j2k_read_sot()
4122 p_j2k->m_specific_param.m_decoder.m_sot_length = 0; in opj_j2k_read_sot()
4125 p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPH; in opj_j2k_read_sot()
4128 if (p_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec == -1) { in opj_j2k_read_sot()
4129 p_j2k->m_specific_param.m_decoder.m_skip_data = in opj_j2k_read_sot()
4130 (l_tile_x < p_j2k->m_specific_param.m_decoder.m_start_tile_x) in opj_j2k_read_sot()
4131 || (l_tile_x >= p_j2k->m_specific_param.m_decoder.m_end_tile_x) in opj_j2k_read_sot()
4132 || (l_tile_y < p_j2k->m_specific_param.m_decoder.m_start_tile_y) in opj_j2k_read_sot()
4133 … || (l_tile_y >= p_j2k->m_specific_param.m_decoder.m_end_tile_y); in opj_j2k_read_sot()
4136 assert( p_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec >= 0 ); in opj_j2k_read_sot()
4137 p_j2k->m_specific_param.m_decoder.m_skip_data = in opj_j2k_read_sot()
4138 … (p_j2k->m_current_tile_number != (OPJ_UINT32)p_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec); in opj_j2k_read_sot()
4142 if (p_j2k->cstr_index) in opj_j2k_read_sot()
4144 assert(p_j2k->cstr_index->tile_index != 00); in opj_j2k_read_sot()
4145p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tileno = p_j2k->m_current_tile_number; in opj_j2k_read_sot()
4146p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_tpsno = l_current_part; in opj_j2k_read_sot()
4149p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].nb_tps = l_num_parts; in opj_j2k_read_sot()
4150p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps = l_num_parts; in opj_j2k_read_sot()
4152 … if (!p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index) { in opj_j2k_read_sot()
4153p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index = in opj_j2k_read_sot()
4155 … if (!p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index) { in opj_j2k_read_sot()
4162p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index, l_num_parts* sizeof(opj_tp_i… in opj_j2k_read_sot()
4164 … opj_free(p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index); in opj_j2k_read_sot()
4165p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index = NULL; in opj_j2k_read_sot()
4169p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index = new_tp_index; in opj_j2k_read_sot()
4175 … if (!p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index) { in opj_j2k_read_sot()
4176p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps = 10; in opj_j2k_read_sot()
4177p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index = in opj_j2k_read_sot()
4178 …(opj_tp_index_t*)opj_calloc( p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_n… in opj_j2k_read_sot()
4180 if (!p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index) { in opj_j2k_read_sot()
4181p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps = 0; in opj_j2k_read_sot()
4187 …if ( l_current_part >= p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps … in opj_j2k_read_sot()
4189p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps = l_current_part + 1; in opj_j2k_read_sot()
4191p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index, in opj_j2k_read_sot()
4192p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps * sizeof(opj_tp_index_t… in opj_j2k_read_sot()
4194 … opj_free(p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index); in opj_j2k_read_sot()
4195p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index = NULL; in opj_j2k_read_sot()
4196p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps = 0; in opj_j2k_read_sot()
4200p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index = new_tp_index; in opj_j2k_read_sot()
4238 static OPJ_BOOL opj_j2k_write_sod( opj_j2k_t *p_j2k, in opj_j2k_write_sod() argument
4251 assert(p_j2k != 00); in opj_j2k_write_sod()
4262 p_tile_coder->tp_num = p_j2k->m_specific_param.m_encoder.m_current_poc_tile_part_number ; in opj_j2k_write_sod()
4263 p_tile_coder->cur_tp_num = p_j2k->m_specific_param.m_encoder.m_current_tile_part_number; in opj_j2k_write_sod()
4293 if (p_j2k->m_specific_param.m_encoder.m_current_tile_part_number == 0) { in opj_j2k_write_sod()
4302 …if (! opj_tcd_encode_tile(p_tile_coder, p_j2k->m_current_tile_number, p_data, p_data_written, l_re… in opj_j2k_write_sod()
4312 static OPJ_BOOL opj_j2k_read_sod (opj_j2k_t *p_j2k, in opj_j2k_read_sod() argument
4325 assert(p_j2k != 00); in opj_j2k_read_sod()
4329 l_tcp = &(p_j2k->m_cp.tcps[p_j2k->m_current_tile_number]); in opj_j2k_read_sod()
4331 if (p_j2k->m_specific_param.m_decoder.m_last_tile_part) { in opj_j2k_read_sod()
4336p_j2k->m_specific_param.m_decoder.m_sot_length = (OPJ_UINT32)(opj_stream_get_number_byte_left(p_st… in opj_j2k_read_sod()
4340 if (p_j2k->m_specific_param.m_decoder.m_sot_length >= 2 ) in opj_j2k_read_sod()
4341 p_j2k->m_specific_param.m_decoder.m_sot_length -= 2; in opj_j2k_read_sod()
4351 if (p_j2k->m_specific_param.m_decoder.m_sot_length) { in opj_j2k_read_sod()
4354 …if ((OPJ_OFF_T)p_j2k->m_specific_param.m_decoder.m_sot_length > opj_stream_get_number_byte_left(p_… in opj_j2k_read_sod()
4362 … *l_current_data = (OPJ_BYTE*) opj_malloc(p_j2k->m_specific_param.m_decoder.m_sot_length); in opj_j2k_read_sod()
4365 …ew_current_data = (OPJ_BYTE *) opj_realloc(*l_current_data, *l_tile_len + p_j2k->m_specific_param.… in opj_j2k_read_sod()
4386 l_cstr_index = p_j2k->cstr_index; in opj_j2k_read_sod()
4390 …OPJ_UINT32 l_current_tile_part = l_cstr_index->tile_index[p_j2k->m_current_tile_number].current_tp… in opj_j2k_read_sod()
4391 … l_cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index[l_current_tile_part].end_header = in opj_j2k_read_sod()
4393 … l_cstr_index->tile_index[p_j2k->m_current_tile_number].tp_index[l_current_tile_part].end_pos = in opj_j2k_read_sod()
4394 l_current_pos + p_j2k->m_specific_param.m_decoder.m_sot_length + 2; in opj_j2k_read_sod()
4396 if (OPJ_FALSE == opj_j2k_add_tlmarker(p_j2k->m_current_tile_number, in opj_j2k_read_sod()
4400 p_j2k->m_specific_param.m_decoder.m_sot_length + 2)) { in opj_j2k_read_sod()
4413 p_j2k->m_specific_param.m_decoder.m_sot_length, in opj_j2k_read_sod()
4421 if (l_current_read_size != p_j2k->m_specific_param.m_decoder.m_sot_length) { in opj_j2k_read_sod()
4422 p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_NEOC; in opj_j2k_read_sod()
4425 p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPHSOT; in opj_j2k_read_sod()
4433 static OPJ_BOOL opj_j2k_write_rgn(opj_j2k_t *p_j2k, in opj_j2k_write_rgn() argument
4449 assert(p_j2k != 00); in opj_j2k_write_rgn()
4453 l_cp = &(p_j2k->m_cp); in opj_j2k_write_rgn()
4466 l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data; in opj_j2k_write_rgn()
4483 …if (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_rgn_size… in opj_j2k_write_rgn()
4490 static OPJ_BOOL opj_j2k_write_eoc( opj_j2k_t *p_j2k, in opj_j2k_write_eoc() argument
4496 assert(p_j2k != 00); in opj_j2k_write_eoc()
4500 …opj_write_bytes(p_j2k->m_specific_param.m_encoder.m_header_tile_data,J2K_MS_EOC,2); … in opj_j2k_write_eoc()
4510 …if ( opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,2,p_manag… in opj_j2k_write_eoc()
4529 static OPJ_BOOL opj_j2k_read_rgn (opj_j2k_t *p_j2k, in opj_j2k_read_rgn() argument
4544 assert(p_j2k != 00); in opj_j2k_read_rgn()
4547 l_image = p_j2k->m_private_image; in opj_j2k_read_rgn()
4560 l_cp = &(p_j2k->m_cp); in opj_j2k_read_rgn()
4561 l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH) ? in opj_j2k_read_rgn()
4562 &l_cp->tcps[p_j2k->m_current_tile_number] : in opj_j2k_read_rgn()
4563 p_j2k->m_specific_param.m_decoder.m_default_tcp; in opj_j2k_read_rgn()
4611 static OPJ_BOOL opj_j2k_update_rates( opj_j2k_t *p_j2k, in opj_j2k_update_rates() argument
4630 assert(p_j2k != 00); in opj_j2k_update_rates()
4634 l_cp = &(p_j2k->m_cp); in opj_j2k_update_rates()
4635 l_image = p_j2k->m_private_image; in opj_j2k_update_rates()
4750 l_tile_size += opj_j2k_get_specific_header_sizes(p_j2k); in opj_j2k_update_rates()
4752 p_j2k->m_specific_param.m_encoder.m_encoded_tile_size = l_tile_size; in opj_j2k_update_rates()
4753 p_j2k->m_specific_param.m_encoder.m_encoded_tile_data = in opj_j2k_update_rates()
4754 … (OPJ_BYTE *) opj_malloc(p_j2k->m_specific_param.m_encoder.m_encoded_tile_size); in opj_j2k_update_rates()
4755 if (p_j2k->m_specific_param.m_encoder.m_encoded_tile_data == 00) { in opj_j2k_update_rates()
4760 p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer = in opj_j2k_update_rates()
4761 … (OPJ_BYTE *) opj_malloc(5*p_j2k->m_specific_param.m_encoder.m_total_tile_parts); in opj_j2k_update_rates()
4762 if (! p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer) { in opj_j2k_update_rates()
4766 p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current = in opj_j2k_update_rates()
4767 p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer; in opj_j2k_update_rates()
4774 static OPJ_BOOL opj_j2k_read_eoc ( opj_j2k_t *p_j2k,
4785 assert(p_j2k != 00);
4789 l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw;
4790 l_tcp = p_j2k->m_cp.tcps;
4806 … l_success = opj_tcd_decode_tile(l_tcd, l_tcp->m_data, l_tcp->m_data_size, i, p_j2k->cstr_index);
4810 p_j2k->m_specific_param.m_decoder.m_state |= J2K_STATE_ERR;
4824 static OPJ_BOOL opj_j2k_get_end_header(opj_j2k_t *p_j2k, in opj_j2k_get_end_header() argument
4829 assert(p_j2k != 00); in opj_j2k_get_end_header()
4833 p_j2k->cstr_index->main_head_end = opj_stream_tell(p_stream); in opj_j2k_get_end_header()
4838 static OPJ_BOOL opj_j2k_write_mct_data_group( opj_j2k_t *p_j2k, in opj_j2k_write_mct_data_group() argument
4848 assert(p_j2k != 00); in opj_j2k_write_mct_data_group()
4852 if (! opj_j2k_write_cbd(p_j2k,p_stream,p_manager)) { in opj_j2k_write_mct_data_group()
4856 l_tcp = &(p_j2k->m_cp.tcps[p_j2k->m_current_tile_number]); in opj_j2k_write_mct_data_group()
4861 if (! opj_j2k_write_mct_record(p_j2k,l_mct_record,p_stream,p_manager)) { in opj_j2k_write_mct_data_group()
4872 if (! opj_j2k_write_mcc_record(p_j2k,l_mcc_record,p_stream,p_manager)) { in opj_j2k_write_mct_data_group()
4879 if (! opj_j2k_write_mco(p_j2k,p_stream,p_manager)) { in opj_j2k_write_mct_data_group()
4887 static OPJ_BOOL opj_j2k_write_all_coc(opj_j2k_t *p_j2k,
4894 assert(p_j2k != 00);
4898 for (compno = 0; compno < p_j2k->m_private_image->numcomps; ++compno)
4900 if (! opj_j2k_write_coc(p_j2k,compno,p_stream, p_manager)) {
4910 static OPJ_BOOL opj_j2k_write_all_qcc(opj_j2k_t *p_j2k,
4917 assert(p_j2k != 00);
4921 for (compno = 0; compno < p_j2k->m_private_image->numcomps; ++compno)
4923 if (! opj_j2k_write_qcc(p_j2k,compno,p_stream, p_manager)) {
4933 static OPJ_BOOL opj_j2k_write_regions( opj_j2k_t *p_j2k, in opj_j2k_write_regions() argument
4941 assert(p_j2k != 00); in opj_j2k_write_regions()
4945 l_tccp = p_j2k->m_cp.tcps->tccps; in opj_j2k_write_regions()
4947 for (compno = 0; compno < p_j2k->m_private_image->numcomps; ++compno) { in opj_j2k_write_regions()
4950 … if (! opj_j2k_write_rgn(p_j2k,0,compno,p_j2k->m_private_image->numcomps,p_stream,p_manager)) { in opj_j2k_write_regions()
4961 static OPJ_BOOL opj_j2k_write_epc( opj_j2k_t *p_j2k, in opj_j2k_write_epc() argument
4968 assert(p_j2k != 00); in opj_j2k_write_epc()
4972 l_cstr_index = p_j2k->cstr_index; in opj_j2k_write_epc()
4989 jpwl_encode(p_j2k, p_stream, image); in opj_j2k_write_epc()
4999 static OPJ_BOOL opj_j2k_read_unk ( opj_j2k_t *p_j2k, in opj_j2k_read_unk() argument
5010 assert(p_j2k != 00); in opj_j2k_read_unk()
5018 …if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != … in opj_j2k_read_unk()
5024 opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_unknown_marker,2); in opj_j2k_read_unk()
5031 … if (!(p_j2k->m_specific_param.m_decoder.m_state & l_marker_handler->states)) { in opj_j2k_read_unk()
5040 … OPJ_BOOL res = opj_j2k_add_mhmarker(p_j2k->cstr_index, J2K_MS_UNK, in opj_j2k_read_unk()
5061 static OPJ_BOOL opj_j2k_write_mct_record( opj_j2k_t *p_j2k, in opj_j2k_write_mct_record() argument
5071 assert(p_j2k != 00); in opj_j2k_write_mct_record()
5077 if (l_mct_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) { in opj_j2k_write_mct_record()
5078 …OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_encoder.m_head… in opj_j2k_write_mct_record()
5080 opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data); in opj_j2k_write_mct_record()
5081 p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL; in opj_j2k_write_mct_record()
5082 p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0; in opj_j2k_write_mct_record()
5086 p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data; in opj_j2k_write_mct_record()
5087 p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_mct_size; in opj_j2k_write_mct_record()
5090 l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data; in opj_j2k_write_mct_record()
5112 …if (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_mct_size… in opj_j2k_write_mct_record()
5127 static OPJ_BOOL opj_j2k_read_mct ( opj_j2k_t *p_j2k, in opj_j2k_read_mct() argument
5142 assert(p_j2k != 00); in opj_j2k_read_mct()
5144 l_tcp = p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH ? in opj_j2k_read_mct()
5145 &p_j2k->m_cp.tcps[p_j2k->m_current_tile_number] : in opj_j2k_read_mct()
5146 p_j2k->m_specific_param.m_decoder.m_default_tcp; in opj_j2k_read_mct()
5237 static OPJ_BOOL opj_j2k_write_mcc_record( opj_j2k_t *p_j2k, in opj_j2k_write_mcc_record() argument
5250 assert(p_j2k != 00); in opj_j2k_write_mcc_record()
5264 if (l_mcc_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) in opj_j2k_write_mcc_record()
5266 …OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_encoder.m_head… in opj_j2k_write_mcc_record()
5268 opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data); in opj_j2k_write_mcc_record()
5269 p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL; in opj_j2k_write_mcc_record()
5270 p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0; in opj_j2k_write_mcc_record()
5274 p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data; in opj_j2k_write_mcc_record()
5275 p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_mcc_size; in opj_j2k_write_mcc_record()
5278 l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data; in opj_j2k_write_mcc_record()
5333 …if (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_mcc_size… in opj_j2k_write_mcc_record()
5340 static OPJ_BOOL opj_j2k_read_mcc ( opj_j2k_t *p_j2k, in opj_j2k_read_mcc() argument
5358 assert(p_j2k != 00); in opj_j2k_read_mcc()
5361 l_tcp = p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH ? in opj_j2k_read_mcc()
5362 &p_j2k->m_cp.tcps[p_j2k->m_current_tile_number] : in opj_j2k_read_mcc()
5363 p_j2k->m_specific_param.m_decoder.m_default_tcp; in opj_j2k_read_mcc()
5559 static OPJ_BOOL opj_j2k_write_mco( opj_j2k_t *p_j2k, in opj_j2k_write_mco() argument
5571 assert(p_j2k != 00); in opj_j2k_write_mco()
5575 l_tcp =&(p_j2k->m_cp.tcps[p_j2k->m_current_tile_number]); in opj_j2k_write_mco()
5578 if (l_mco_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) { in opj_j2k_write_mco()
5580 …OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_encoder.m_head… in opj_j2k_write_mco()
5582 opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data); in opj_j2k_write_mco()
5583 p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL; in opj_j2k_write_mco()
5584 p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0; in opj_j2k_write_mco()
5588 p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data; in opj_j2k_write_mco()
5589 p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_mco_size; in opj_j2k_write_mco()
5591 l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data; in opj_j2k_write_mco()
5610 …if (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_mco_size… in opj_j2k_write_mco()
5625 static OPJ_BOOL opj_j2k_read_mco ( opj_j2k_t *p_j2k, in opj_j2k_read_mco() argument
5639 assert(p_j2k != 00); in opj_j2k_read_mco()
5642 l_image = p_j2k->m_private_image; in opj_j2k_read_mco()
5643 l_tcp = p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH ? in opj_j2k_read_mco()
5644 &p_j2k->m_cp.tcps[p_j2k->m_current_tile_number] : in opj_j2k_read_mco()
5645 p_j2k->m_specific_param.m_decoder.m_default_tcp; in opj_j2k_read_mco()
5681 if (! opj_j2k_add_mct(l_tcp,p_j2k->m_private_image,l_tmp)) { in opj_j2k_read_mco()
5771 static OPJ_BOOL opj_j2k_write_cbd( opj_j2k_t *p_j2k, in opj_j2k_write_cbd() argument
5782 assert(p_j2k != 00); in opj_j2k_write_cbd()
5786 l_image = p_j2k->m_private_image; in opj_j2k_write_cbd()
5787 l_cbd_size = 6 + p_j2k->m_private_image->numcomps; in opj_j2k_write_cbd()
5789 if (l_cbd_size > p_j2k->m_specific_param.m_encoder.m_header_tile_data_size) { in opj_j2k_write_cbd()
5790 …OPJ_BYTE *new_header_tile_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_encoder.m_head… in opj_j2k_write_cbd()
5792 opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data); in opj_j2k_write_cbd()
5793 p_j2k->m_specific_param.m_encoder.m_header_tile_data = NULL; in opj_j2k_write_cbd()
5794 p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0; in opj_j2k_write_cbd()
5798 p_j2k->m_specific_param.m_encoder.m_header_tile_data = new_header_tile_data; in opj_j2k_write_cbd()
5799 p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = l_cbd_size; in opj_j2k_write_cbd()
5802 l_current_data = p_j2k->m_specific_param.m_encoder.m_header_tile_data; in opj_j2k_write_cbd()
5822 …if (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_header_tile_data,l_cbd_size… in opj_j2k_write_cbd()
5836 static OPJ_BOOL opj_j2k_read_cbd ( opj_j2k_t *p_j2k, in opj_j2k_read_cbd() argument
5849 assert(p_j2k != 00); in opj_j2k_read_cbd()
5852 l_num_comp = p_j2k->m_private_image->numcomps; in opj_j2k_read_cbd()
5854 if (p_header_size != (p_j2k->m_private_image->numcomps + 2)) { in opj_j2k_read_cbd()
5867 l_comp = p_j2k->m_private_image->comps; in opj_j2k_read_cbd()
6154 OPJ_BOOL opj_j2k_setup_encoder( opj_j2k_t *p_j2k, in opj_j2k_setup_encoder() argument
6162 if(!p_j2k || !parameters || ! image) { in opj_j2k_setup_encoder()
6172 cp = &(p_j2k->m_cp); in opj_j2k_setup_encoder()
6729 OPJ_BOOL opj_j2k_end_decompress(opj_j2k_t *p_j2k, in opj_j2k_end_decompress() argument
6734 (void)p_j2k; in opj_j2k_end_decompress()
6741 opj_j2k_t* p_j2k, in opj_j2k_read_header() argument
6746 assert(p_j2k != 00); in opj_j2k_read_header()
6751 p_j2k->m_private_image = opj_image_create0(); in opj_j2k_read_header()
6752 if (! p_j2k->m_private_image) { in opj_j2k_read_header()
6757 if (! opj_j2k_setup_decoding_validation(p_j2k, p_manager)) { in opj_j2k_read_header()
6758 opj_image_destroy(p_j2k->m_private_image); in opj_j2k_read_header()
6759 p_j2k->m_private_image = NULL; in opj_j2k_read_header()
6764 if (! opj_j2k_exec(p_j2k, p_j2k->m_validation_list, p_stream,p_manager)) { in opj_j2k_read_header()
6765 opj_image_destroy(p_j2k->m_private_image); in opj_j2k_read_header()
6766 p_j2k->m_private_image = NULL; in opj_j2k_read_header()
6771 if (! opj_j2k_setup_header_reading(p_j2k, p_manager)) { in opj_j2k_read_header()
6772 opj_image_destroy(p_j2k->m_private_image); in opj_j2k_read_header()
6773 p_j2k->m_private_image = NULL; in opj_j2k_read_header()
6778 if (! opj_j2k_exec (p_j2k,p_j2k->m_procedure_list,p_stream,p_manager)) { in opj_j2k_read_header()
6779 opj_image_destroy(p_j2k->m_private_image); in opj_j2k_read_header()
6780 p_j2k->m_private_image = NULL; in opj_j2k_read_header()
6790 opj_copy_image_header(p_j2k->m_private_image, *p_image); in opj_j2k_read_header()
6793 if (!opj_j2k_allocate_tile_element_cstr_index(p_j2k)){ in opj_j2k_read_header()
6800 static OPJ_BOOL opj_j2k_setup_header_reading (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager) in opj_j2k_setup_header_reading() argument
6803 assert(p_j2k != 00); in opj_j2k_setup_header_reading()
6806 …if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_read_header_… in opj_j2k_setup_header_reading()
6811 …if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_copy_default… in opj_j2k_setup_header_reading()
6818 static OPJ_BOOL opj_j2k_setup_decoding_validation (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager) in opj_j2k_setup_decoding_validation() argument
6821 assert(p_j2k != 00); in opj_j2k_setup_decoding_validation()
6824 …if (! opj_procedure_list_add_procedure(p_j2k->m_validation_list,(opj_procedure)opj_j2k_build_decod… in opj_j2k_setup_decoding_validation()
6827 …if (! opj_procedure_list_add_procedure(p_j2k->m_validation_list,(opj_procedure)opj_j2k_decoding_va… in opj_j2k_setup_decoding_validation()
6835 static OPJ_BOOL opj_j2k_mct_validation ( opj_j2k_t * p_j2k, in opj_j2k_mct_validation() argument
6843 assert(p_j2k != 00); in opj_j2k_mct_validation()
6847 if ((p_j2k->m_cp.rsiz & 0x8200) == 0x8200) { in opj_j2k_mct_validation()
6848 OPJ_UINT32 l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw; in opj_j2k_mct_validation()
6849 opj_tcp_t * l_tcp = p_j2k->m_cp.tcps; in opj_j2k_mct_validation()
6856 for (j=0;j<p_j2k->m_private_image->numcomps;++j) { in opj_j2k_mct_validation()
7021 static OPJ_BOOL opj_j2k_build_decoder (opj_j2k_t * p_j2k, in opj_j2k_build_decoder() argument
7027 (void)p_j2k; in opj_j2k_build_decoder()
7033 static OPJ_BOOL opj_j2k_build_encoder (opj_j2k_t * p_j2k, in opj_j2k_build_encoder() argument
7039 (void)p_j2k; in opj_j2k_build_encoder()
7045 static OPJ_BOOL opj_j2k_encoding_validation ( opj_j2k_t * p_j2k, in opj_j2k_encoding_validation() argument
7052 assert(p_j2k != 00); in opj_j2k_encoding_validation()
7058 l_is_valid &= (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_NONE); in opj_j2k_encoding_validation()
7062 l_is_valid &= (p_j2k->m_procedure_list != 00); in opj_j2k_encoding_validation()
7064 l_is_valid &= (p_j2k->m_validation_list != 00); in opj_j2k_encoding_validation()
7069 …if ((p_j2k->m_cp.tcps->tccps->numresolutions <= 0) || (p_j2k->m_cp.tcps->tccps->numresolutions > 3… in opj_j2k_encoding_validation()
7074 … if ((p_j2k->m_cp.tdx) < (OPJ_UINT32) (1 << (p_j2k->m_cp.tcps->tccps->numresolutions - 1U))) { in opj_j2k_encoding_validation()
7079 … if ((p_j2k->m_cp.tdy) < (OPJ_UINT32) (1 << (p_j2k->m_cp.tcps->tccps->numresolutions - 1U))) { in opj_j2k_encoding_validation()
7088 static OPJ_BOOL opj_j2k_decoding_validation ( opj_j2k_t *p_j2k, in opj_j2k_decoding_validation() argument
7096 assert(p_j2k != 00); in opj_j2k_decoding_validation()
7103 l_is_valid &= (p_j2k->m_specific_param.m_decoder.m_state == J2K_DEC_STATE_NONE); in opj_j2k_decoding_validation()
7105 l_is_valid &= (p_j2k->m_specific_param.m_decoder.m_state == 0x0000); in opj_j2k_decoding_validation()
7110 l_is_valid &= (p_j2k->m_procedure_list != 00); in opj_j2k_decoding_validation()
7112 l_is_valid &= (p_j2k->m_validation_list != 00); in opj_j2k_decoding_validation()
7118 static OPJ_BOOL opj_j2k_read_header_procedure( opj_j2k_t *p_j2k, in opj_j2k_read_header_procedure() argument
7131 assert(p_j2k != 00); in opj_j2k_read_header_procedure()
7135 p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_MHSOC; in opj_j2k_read_header_procedure()
7138 if (! opj_j2k_read_soc(p_j2k,p_stream,p_manager)) { in opj_j2k_read_header_procedure()
7144 …if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != … in opj_j2k_read_header_procedure()
7150 opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_current_marker,2); in opj_j2k_read_header_procedure()
7166 if (! opj_j2k_read_unk(p_j2k, p_stream, &l_current_marker, p_manager)){ in opj_j2k_read_header_procedure()
7191 if (! (p_j2k->m_specific_param.m_decoder.m_state & l_marker_handler->states) ) { in opj_j2k_read_header_procedure()
7197 …if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != … in opj_j2k_read_header_procedure()
7203 opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_marker_size,2); in opj_j2k_read_header_procedure()
7211 if (l_marker_size > p_j2k->m_specific_param.m_decoder.m_header_data_size) { in opj_j2k_read_header_procedure()
7212 …OPJ_BYTE *new_header_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_decoder.m_header_da… in opj_j2k_read_header_procedure()
7214 opj_free(p_j2k->m_specific_param.m_decoder.m_header_data); in opj_j2k_read_header_procedure()
7215 p_j2k->m_specific_param.m_decoder.m_header_data = NULL; in opj_j2k_read_header_procedure()
7216 p_j2k->m_specific_param.m_decoder.m_header_data_size = 0; in opj_j2k_read_header_procedure()
7220 p_j2k->m_specific_param.m_decoder.m_header_data = new_header_data; in opj_j2k_read_header_procedure()
7221 p_j2k->m_specific_param.m_decoder.m_header_data_size = l_marker_size; in opj_j2k_read_header_procedure()
7225 …if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,l_marker_size,p_… in opj_j2k_read_header_procedure()
7231 …if (! (*(l_marker_handler->handler))(p_j2k,p_j2k->m_specific_param.m_decoder.m_header_data,l_marke… in opj_j2k_read_header_procedure()
7238 p_j2k->cstr_index, in opj_j2k_read_header_procedure()
7247 …if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != … in opj_j2k_read_header_procedure()
7253 opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_current_marker,2); in opj_j2k_read_header_procedure()
7269 if (! opj_j2k_merge_ppm(&(p_j2k->m_cp), p_manager)) { in opj_j2k_read_header_procedure()
7277 p_j2k->cstr_index->main_head_end = (OPJ_UINT32) opj_stream_tell(p_stream) - 2; in opj_j2k_read_header_procedure()
7280 p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPHSOT; in opj_j2k_read_header_procedure()
7285 static OPJ_BOOL opj_j2k_exec ( opj_j2k_t * p_j2k, in opj_j2k_exec() argument
7296 assert(p_j2k != 00); in opj_j2k_exec()
7304 l_result = l_result && ((*l_procedure) (p_j2k,p_stream,p_manager)); in opj_j2k_exec()
7314 static OPJ_BOOL opj_j2k_copy_default_tcp_and_create_tcd ( opj_j2k_t * p_j2k, in opj_j2k_copy_default_tcp_and_create_tcd() argument
7333 assert(p_j2k != 00); in opj_j2k_copy_default_tcp_and_create_tcd()
7337 l_image = p_j2k->m_private_image; in opj_j2k_copy_default_tcp_and_create_tcd()
7338 l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw; in opj_j2k_copy_default_tcp_and_create_tcd()
7339 l_tcp = p_j2k->m_cp.tcps; in opj_j2k_copy_default_tcp_and_create_tcd()
7341 l_default_tcp = p_j2k->m_specific_param.m_decoder.m_default_tcp; in opj_j2k_copy_default_tcp_and_create_tcd()
7438 p_j2k->m_tcd = (opj_tcd_t*)opj_tcd_create(OPJ_TRUE); /* FIXME why a cast ? */ in opj_j2k_copy_default_tcp_and_create_tcd()
7439 if (! p_j2k->m_tcd ) { in opj_j2k_copy_default_tcp_and_create_tcd()
7443 if ( !opj_tcd_init(p_j2k->m_tcd, l_image, &(p_j2k->m_cp)) ) { in opj_j2k_copy_default_tcp_and_create_tcd()
7444 opj_tcd_destroy(p_j2k->m_tcd); in opj_j2k_copy_default_tcp_and_create_tcd()
7445 p_j2k->m_tcd = 00; in opj_j2k_copy_default_tcp_and_create_tcd()
7464 void opj_j2k_destroy (opj_j2k_t *p_j2k) in opj_j2k_destroy() argument
7466 if (p_j2k == 00) { in opj_j2k_destroy()
7470 if (p_j2k->m_is_decoder) { in opj_j2k_destroy()
7472 if (p_j2k->m_specific_param.m_decoder.m_default_tcp != 00) { in opj_j2k_destroy()
7473 opj_j2k_tcp_destroy(p_j2k->m_specific_param.m_decoder.m_default_tcp); in opj_j2k_destroy()
7474 opj_free(p_j2k->m_specific_param.m_decoder.m_default_tcp); in opj_j2k_destroy()
7475 p_j2k->m_specific_param.m_decoder.m_default_tcp = 00; in opj_j2k_destroy()
7478 if (p_j2k->m_specific_param.m_decoder.m_header_data != 00) { in opj_j2k_destroy()
7479 opj_free(p_j2k->m_specific_param.m_decoder.m_header_data); in opj_j2k_destroy()
7480 p_j2k->m_specific_param.m_decoder.m_header_data = 00; in opj_j2k_destroy()
7481 p_j2k->m_specific_param.m_decoder.m_header_data_size = 0; in opj_j2k_destroy()
7486 if (p_j2k->m_specific_param.m_encoder.m_encoded_tile_data) { in opj_j2k_destroy()
7487 opj_free(p_j2k->m_specific_param.m_encoder.m_encoded_tile_data); in opj_j2k_destroy()
7488 p_j2k->m_specific_param.m_encoder.m_encoded_tile_data = 00; in opj_j2k_destroy()
7491 if (p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer) { in opj_j2k_destroy()
7492 opj_free(p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer); in opj_j2k_destroy()
7493 p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer = 00; in opj_j2k_destroy()
7494 p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current = 00; in opj_j2k_destroy()
7497 if (p_j2k->m_specific_param.m_encoder.m_header_tile_data) { in opj_j2k_destroy()
7498 opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data); in opj_j2k_destroy()
7499 p_j2k->m_specific_param.m_encoder.m_header_tile_data = 00; in opj_j2k_destroy()
7500 p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0; in opj_j2k_destroy()
7504 opj_tcd_destroy(p_j2k->m_tcd); in opj_j2k_destroy()
7506 opj_j2k_cp_destroy(&(p_j2k->m_cp)); in opj_j2k_destroy()
7507 memset(&(p_j2k->m_cp),0,sizeof(opj_cp_t)); in opj_j2k_destroy()
7509 opj_procedure_list_destroy(p_j2k->m_procedure_list); in opj_j2k_destroy()
7510 p_j2k->m_procedure_list = 00; in opj_j2k_destroy()
7512 opj_procedure_list_destroy(p_j2k->m_validation_list); in opj_j2k_destroy()
7513 p_j2k->m_procedure_list = 00; in opj_j2k_destroy()
7515 j2k_destroy_cstr_index(p_j2k->cstr_index); in opj_j2k_destroy()
7516 p_j2k->cstr_index = NULL; in opj_j2k_destroy()
7518 opj_image_destroy(p_j2k->m_private_image); in opj_j2k_destroy()
7519 p_j2k->m_private_image = NULL; in opj_j2k_destroy()
7521 opj_image_destroy(p_j2k->m_output_image); in opj_j2k_destroy()
7522 p_j2k->m_output_image = NULL; in opj_j2k_destroy()
7524 opj_free(p_j2k); in opj_j2k_destroy()
7790 OPJ_BOOL opj_j2k_read_tile_header( opj_j2k_t * p_j2k, in opj_j2k_read_tile_header() argument
7807 assert(p_j2k != 00); in opj_j2k_read_tile_header()
7811 if (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_EOC){ in opj_j2k_read_tile_header()
7815 else if (p_j2k->m_specific_param.m_decoder.m_state != J2K_STATE_TPHSOT){ in opj_j2k_read_tile_header()
7820 … while ( (!p_j2k->m_specific_param.m_decoder.m_can_decode) && (l_current_marker != J2K_MS_EOC) ) { in opj_j2k_read_tile_header()
7827 p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_NEOC; in opj_j2k_read_tile_header()
7832 …if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != … in opj_j2k_read_tile_header()
7838 … opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_marker_size,2); in opj_j2k_read_tile_header()
7848 p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_NEOC; in opj_j2k_read_tile_header()
7853 if (p_j2k->m_specific_param.m_decoder.m_state & J2K_STATE_TPH){ in opj_j2k_read_tile_header()
7854p_j2k->m_specific_param.m_decoder.m_sot_length -= (l_marker_size + 2); in opj_j2k_read_tile_header()
7862 … if (! (p_j2k->m_specific_param.m_decoder.m_state & l_marker_handler->states) ) { in opj_j2k_read_tile_header()
7869 if (l_marker_size > p_j2k->m_specific_param.m_decoder.m_header_data_size) { in opj_j2k_read_tile_header()
7877 …new_header_data = (OPJ_BYTE *) opj_realloc(p_j2k->m_specific_param.m_decoder.m_header_data, l_mark… in opj_j2k_read_tile_header()
7879 opj_free(p_j2k->m_specific_param.m_decoder.m_header_data); in opj_j2k_read_tile_header()
7880 p_j2k->m_specific_param.m_decoder.m_header_data = NULL; in opj_j2k_read_tile_header()
7881 p_j2k->m_specific_param.m_decoder.m_header_data_size = 0; in opj_j2k_read_tile_header()
7885 p_j2k->m_specific_param.m_decoder.m_header_data = new_header_data; in opj_j2k_read_tile_header()
7886p_j2k->m_specific_param.m_decoder.m_header_data_size = l_marker_size; in opj_j2k_read_tile_header()
7890 …if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,l_marker_size,p_… in opj_j2k_read_tile_header()
7901 …if (! (*(l_marker_handler->handler))(p_j2k,p_j2k->m_specific_param.m_decoder.m_header_data,l_marke… in opj_j2k_read_tile_header()
7907 if (OPJ_FALSE == opj_j2k_add_tlmarker(p_j2k->m_current_tile_number, in opj_j2k_read_tile_header()
7908 p_j2k->cstr_index, in opj_j2k_read_tile_header()
7919 if (sot_pos > p_j2k->m_specific_param.m_decoder.m_last_sot_read_pos) in opj_j2k_read_tile_header()
7921p_j2k->m_specific_param.m_decoder.m_last_sot_read_pos = sot_pos; in opj_j2k_read_tile_header()
7925 if (p_j2k->m_specific_param.m_decoder.m_skip_data) { in opj_j2k_read_tile_header()
7927 …if (opj_stream_skip(p_stream,p_j2k->m_specific_param.m_decoder.m_sot_length,p_manager) != p_j2k->m… in opj_j2k_read_tile_header()
7935 …if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != … in opj_j2k_read_tile_header()
7940 … opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_current_marker,2); in opj_j2k_read_tile_header()
7944 && p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_NEOC) in opj_j2k_read_tile_header()
7948 if (! p_j2k->m_specific_param.m_decoder.m_skip_data) { in opj_j2k_read_tile_header()
7950 if (! opj_j2k_read_sod(p_j2k, p_stream, p_manager)) { in opj_j2k_read_tile_header()
7953 …if (p_j2k->m_specific_param.m_decoder.m_can_decode && !p_j2k->m_specific_param.m_decoder.m_nb_tile… in opj_j2k_read_tile_header()
7957p_j2k->m_specific_param.m_decoder.m_nb_tile_parts_correction_checked = 1; in opj_j2k_read_tile_header()
7958 …if(!opj_j2k_need_nb_tile_parts_correction(p_stream, p_j2k->m_current_tile_number, &l_correction_ne… in opj_j2k_read_tile_header()
7963 OPJ_UINT32 l_nb_tiles = p_j2k->m_cp.tw * p_j2k->m_cp.th; in opj_j2k_read_tile_header()
7966 p_j2k->m_specific_param.m_decoder.m_can_decode = 0; in opj_j2k_read_tile_header()
7967p_j2k->m_specific_param.m_decoder.m_nb_tile_parts_correction = 1; in opj_j2k_read_tile_header()
7970 … if (p_j2k->m_cp.tcps[l_tile_no].m_nb_tile_parts != 0U) { in opj_j2k_read_tile_header()
7971p_j2k->m_cp.tcps[l_tile_no].m_nb_tile_parts+=1; in opj_j2k_read_tile_header()
7977 if (! p_j2k->m_specific_param.m_decoder.m_can_decode){ in opj_j2k_read_tile_header()
7979 …if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != … in opj_j2k_read_tile_header()
7985 … opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_current_marker,2); in opj_j2k_read_tile_header()
7990 p_j2k->m_specific_param.m_decoder.m_skip_data = 0; in opj_j2k_read_tile_header()
7991 p_j2k->m_specific_param.m_decoder.m_can_decode = 0; in opj_j2k_read_tile_header()
7992 p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPHSOT; in opj_j2k_read_tile_header()
7995 …if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_decoder.m_header_data,2,p_manager) != … in opj_j2k_read_tile_header()
8001 … opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,&l_current_marker,2); in opj_j2k_read_tile_header()
8007 if (p_j2k->m_specific_param.m_decoder.m_state != J2K_STATE_EOC ){ in opj_j2k_read_tile_header()
8008 p_j2k->m_current_tile_number = 0; in opj_j2k_read_tile_header()
8009 p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_EOC; in opj_j2k_read_tile_header()
8014 if ( ! p_j2k->m_specific_param.m_decoder.m_can_decode) { in opj_j2k_read_tile_header()
8015 OPJ_UINT32 l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw; in opj_j2k_read_tile_header()
8016 l_tcp = p_j2k->m_cp.tcps + p_j2k->m_current_tile_number; in opj_j2k_read_tile_header()
8018 while( (p_j2k->m_current_tile_number < l_nb_tiles) && (l_tcp->m_data == 00) ) { in opj_j2k_read_tile_header()
8019 ++p_j2k->m_current_tile_number; in opj_j2k_read_tile_header()
8023 if (p_j2k->m_current_tile_number == l_nb_tiles) { in opj_j2k_read_tile_header()
8029 if (! opj_j2k_merge_ppt(p_j2k->m_cp.tcps + p_j2k->m_current_tile_number, p_manager)) { in opj_j2k_read_tile_header()
8034 if (! opj_tcd_init_decode_tile(p_j2k->m_tcd, p_j2k->m_current_tile_number, p_manager)) { in opj_j2k_read_tile_header()
8040 p_j2k->m_current_tile_number+1, (p_j2k->m_cp.th * p_j2k->m_cp.tw)); in opj_j2k_read_tile_header()
8042 *p_tile_index = p_j2k->m_current_tile_number; in opj_j2k_read_tile_header()
8044 *p_data_size = opj_tcd_get_decoded_tile_size(p_j2k->m_tcd); in opj_j2k_read_tile_header()
8049 *p_tile_x0 = p_j2k->m_tcd->tcd_image->tiles->x0; in opj_j2k_read_tile_header()
8050 *p_tile_y0 = p_j2k->m_tcd->tcd_image->tiles->y0; in opj_j2k_read_tile_header()
8051 *p_tile_x1 = p_j2k->m_tcd->tcd_image->tiles->x1; in opj_j2k_read_tile_header()
8052 *p_tile_y1 = p_j2k->m_tcd->tcd_image->tiles->y1; in opj_j2k_read_tile_header()
8053 *p_nb_comps = p_j2k->m_tcd->tcd_image->tiles->numcomps; in opj_j2k_read_tile_header()
8055 p_j2k->m_specific_param.m_decoder.m_state |= 0x0080;/* FIXME J2K_DEC_STATE_DATA;*/ in opj_j2k_read_tile_header()
8060 OPJ_BOOL opj_j2k_decode_tile ( opj_j2k_t * p_j2k, in opj_j2k_decode_tile() argument
8073 assert(p_j2k != 00); in opj_j2k_decode_tile()
8076 if ( !(p_j2k->m_specific_param.m_decoder.m_state & 0x0080/*FIXME J2K_DEC_STATE_DATA*/) in opj_j2k_decode_tile()
8077 || (p_tile_index != p_j2k->m_current_tile_number) ) { in opj_j2k_decode_tile()
8081 l_tcp = &(p_j2k->m_cp.tcps[p_tile_index]); in opj_j2k_decode_tile()
8087 if (! opj_tcd_decode_tile( p_j2k->m_tcd, in opj_j2k_decode_tile()
8091 p_j2k->cstr_index, p_manager) ) { in opj_j2k_decode_tile()
8093 p_j2k->m_specific_param.m_decoder.m_state |= 0x8000;/*FIXME J2K_DEC_STATE_ERR;*/ in opj_j2k_decode_tile()
8098 if (! opj_tcd_update_tile_data(p_j2k->m_tcd,p_data,p_data_size)) { in opj_j2k_decode_tile()
8108 p_j2k->m_specific_param.m_decoder.m_can_decode = 0; in opj_j2k_decode_tile()
8109 p_j2k->m_specific_param.m_decoder.m_state &= (~ (0x0080u));/* FIXME J2K_DEC_STATE_DATA);*/ in opj_j2k_decode_tile()
8112 && p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_NEOC){ in opj_j2k_decode_tile()
8116 if (p_j2k->m_specific_param.m_decoder.m_state != 0x0100){ /*FIXME J2K_DEC_STATE_EOC)*/ in opj_j2k_decode_tile()
8125 p_j2k->m_current_tile_number = 0; in opj_j2k_decode_tile()
8126p_j2k->m_specific_param.m_decoder.m_state = 0x0100;/*FIXME J2K_DEC_STATE_EOC;*/ in opj_j2k_decode_tile()
8131 p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_NEOC; in opj_j2k_decode_tile()
8416 OPJ_BOOL opj_j2k_set_decode_area( opj_j2k_t *p_j2k, in opj_j2k_set_decode_area() argument
8422 opj_cp_t * l_cp = &(p_j2k->m_cp); in opj_j2k_set_decode_area()
8423 opj_image_t * l_image = p_j2k->m_private_image; in opj_j2k_set_decode_area()
8430 …if (p_j2k->m_specific_param.m_decoder.m_state != J2K_STATE_TPHSOT) { /* FIXME J2K_DEC_STATE_TPHSOT… in opj_j2k_set_decode_area()
8438 p_j2k->m_specific_param.m_decoder.m_start_tile_x = 0; in opj_j2k_set_decode_area()
8439 p_j2k->m_specific_param.m_decoder.m_start_tile_y = 0; in opj_j2k_set_decode_area()
8440 p_j2k->m_specific_param.m_decoder.m_end_tile_x = l_cp->tw; in opj_j2k_set_decode_area()
8441 p_j2k->m_specific_param.m_decoder.m_end_tile_y = l_cp->th; in opj_j2k_set_decode_area()
8463 p_j2k->m_specific_param.m_decoder.m_start_tile_x = 0; in opj_j2k_set_decode_area()
8467p_j2k->m_specific_param.m_decoder.m_start_tile_x = ((OPJ_UINT32)p_start_x - l_cp->tx0) / l_cp->tdx; in opj_j2k_set_decode_area()
8482 p_j2k->m_specific_param.m_decoder.m_start_tile_y = 0; in opj_j2k_set_decode_area()
8486p_j2k->m_specific_param.m_decoder.m_start_tile_y = ((OPJ_UINT32)p_start_y - l_cp->ty0) / l_cp->tdy; in opj_j2k_set_decode_area()
8503 p_j2k->m_specific_param.m_decoder.m_end_tile_x = l_cp->tw; in opj_j2k_set_decode_area()
8507p_j2k->m_specific_param.m_decoder.m_end_tile_x = (OPJ_UINT32)opj_int_ceildiv(p_end_x - (OPJ_INT32)… in opj_j2k_set_decode_area()
8522 p_j2k->m_specific_param.m_decoder.m_end_tile_y = l_cp->th; in opj_j2k_set_decode_area()
8526p_j2k->m_specific_param.m_decoder.m_end_tile_y = (OPJ_UINT32)opj_int_ceildiv(p_end_y - (OPJ_INT32)… in opj_j2k_set_decode_area()
8531 p_j2k->m_specific_param.m_decoder.m_discard_tiles = 1; in opj_j2k_set_decode_area()
8649 static OPJ_UINT32 opj_j2k_get_SPCod_SPCoc_size ( opj_j2k_t *p_j2k, in opj_j2k_get_SPCod_SPCoc_size() argument
8658 assert(p_j2k != 00); in opj_j2k_get_SPCod_SPCoc_size()
8660 l_cp = &(p_j2k->m_cp); in opj_j2k_get_SPCod_SPCoc_size()
8666 assert(p_comp_no < p_j2k->m_private_image->numcomps); in opj_j2k_get_SPCod_SPCoc_size()
8676 static OPJ_BOOL opj_j2k_write_SPCod_SPCoc( opj_j2k_t *p_j2k, in opj_j2k_write_SPCod_SPCoc() argument
8689 assert(p_j2k != 00); in opj_j2k_write_SPCod_SPCoc()
8694 l_cp = &(p_j2k->m_cp); in opj_j2k_write_SPCod_SPCoc()
8700 assert(p_comp_no <(p_j2k->m_private_image->numcomps)); in opj_j2k_write_SPCod_SPCoc()
8742 static OPJ_BOOL opj_j2k_read_SPCod_SPCoc( opj_j2k_t *p_j2k, in opj_j2k_read_SPCod_SPCoc() argument
8755 assert(p_j2k != 00); in opj_j2k_read_SPCod_SPCoc()
8759 l_cp = &(p_j2k->m_cp); in opj_j2k_read_SPCod_SPCoc()
8760 l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH) ? in opj_j2k_read_SPCod_SPCoc()
8761 &l_cp->tcps[p_j2k->m_current_tile_number] : in opj_j2k_read_SPCod_SPCoc()
8762 p_j2k->m_specific_param.m_decoder.m_default_tcp; in opj_j2k_read_SPCod_SPCoc()
8765 if (compno >= p_j2k->m_private_image->numcomps) { in opj_j2k_read_SPCod_SPCoc()
8792 p_j2k->m_specific_param.m_decoder.m_state |= 0x8000;/* FIXME J2K_DEC_STATE_ERR;*/ in opj_j2k_read_SPCod_SPCoc()
8849 if (p_j2k->cstr_info && compno == 0) { in opj_j2k_read_SPCod_SPCoc()
8852p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].tccp_info[compno].cblkh = l_tccp->cblkh; in opj_j2k_read_SPCod_SPCoc()
8853p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].tccp_info[compno].cblkw = l_tccp->cblkw; in opj_j2k_read_SPCod_SPCoc()
8854p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].tccp_info[compno].numresolutions = l_tccp->nu… in opj_j2k_read_SPCod_SPCoc()
8855p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].tccp_info[compno].cblksty = l_tccp->cblksty; in opj_j2k_read_SPCod_SPCoc()
8856p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].tccp_info[compno].qmfbid = l_tccp->qmfbid; in opj_j2k_read_SPCod_SPCoc()
8858 … memcpy(p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].pdx,l_tccp->prcw, l_data_size); in opj_j2k_read_SPCod_SPCoc()
8859 … memcpy(p_j2k->cstr_info->tile[p_j2k->m_current_tile_number].pdy,l_tccp->prch, l_data_size); in opj_j2k_read_SPCod_SPCoc()
8867 static void opj_j2k_copy_tile_component_parameters( opj_j2k_t *p_j2k ) in opj_j2k_copy_tile_component_parameters() argument
8877 assert(p_j2k != 00); in opj_j2k_copy_tile_component_parameters()
8879 l_cp = &(p_j2k->m_cp); in opj_j2k_copy_tile_component_parameters()
8880 …l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH) ? /* FIXME J2K_DEC_STATE_TPH*/ in opj_j2k_copy_tile_component_parameters()
8881 &l_cp->tcps[p_j2k->m_current_tile_number] : in opj_j2k_copy_tile_component_parameters()
8882 p_j2k->m_specific_param.m_decoder.m_default_tcp; in opj_j2k_copy_tile_component_parameters()
8888 for (i=1; i<p_j2k->m_private_image->numcomps; ++i) { in opj_j2k_copy_tile_component_parameters()
8900 static OPJ_UINT32 opj_j2k_get_SQcd_SQcc_size ( opj_j2k_t *p_j2k, in opj_j2k_get_SQcd_SQcc_size() argument
8911 assert(p_j2k != 00); in opj_j2k_get_SQcd_SQcc_size()
8913 l_cp = &(p_j2k->m_cp); in opj_j2k_get_SQcd_SQcc_size()
8919 assert(p_comp_no < p_j2k->m_private_image->numcomps); in opj_j2k_get_SQcd_SQcc_size()
8931 static OPJ_BOOL opj_j2k_write_SQcd_SQcc( opj_j2k_t *p_j2k, in opj_j2k_write_SQcd_SQcc() argument
8947 assert(p_j2k != 00); in opj_j2k_write_SQcd_SQcc()
8952 l_cp = &(p_j2k->m_cp); in opj_j2k_write_SQcd_SQcc()
8958 assert(p_comp_no <p_j2k->m_private_image->numcomps); in opj_j2k_write_SQcd_SQcc()
9004 static OPJ_BOOL opj_j2k_read_SQcd_SQcc(opj_j2k_t *p_j2k, in opj_j2k_read_SQcd_SQcc() argument
9020 assert(p_j2k != 00); in opj_j2k_read_SQcd_SQcc()
9024 l_cp = &(p_j2k->m_cp); in opj_j2k_read_SQcd_SQcc()
9026 … l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH) ? /*FIXME J2K_DEC_STATE_TPH*/ in opj_j2k_read_SQcd_SQcc()
9027 &l_cp->tcps[p_j2k->m_current_tile_number] : in opj_j2k_read_SQcd_SQcc()
9028 p_j2k->m_specific_param.m_decoder.m_default_tcp; in opj_j2k_read_SQcd_SQcc()
9031 if (p_comp_no >= p_j2k->m_private_image->numcomps) { in opj_j2k_read_SQcd_SQcc()
9123 static void opj_j2k_copy_tile_quantization_parameters( opj_j2k_t *p_j2k ) in opj_j2k_copy_tile_quantization_parameters() argument
9133 assert(p_j2k != 00); in opj_j2k_copy_tile_quantization_parameters()
9135 l_cp = &(p_j2k->m_cp); in opj_j2k_copy_tile_quantization_parameters()
9136 l_tcp = p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH ? in opj_j2k_copy_tile_quantization_parameters()
9137 &l_cp->tcps[p_j2k->m_current_tile_number] : in opj_j2k_copy_tile_quantization_parameters()
9138 p_j2k->m_specific_param.m_decoder.m_default_tcp; in opj_j2k_copy_tile_quantization_parameters()
9144 for (i=1;i<p_j2k->m_private_image->numcomps;++i) { in opj_j2k_copy_tile_quantization_parameters()
9204 void j2k_dump (opj_j2k_t* p_j2k, OPJ_INT32 flag, FILE* out_stream) in j2k_dump() argument
9214 if (p_j2k->m_private_image) in j2k_dump()
9215 j2k_dump_image_header(p_j2k->m_private_image, 0, out_stream); in j2k_dump()
9220 opj_j2k_dump_MH_info(p_j2k, out_stream); in j2k_dump()
9224 OPJ_UINT32 l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw; in j2k_dump()
9226 opj_tcp_t * l_tcp = p_j2k->m_cp.tcps; in j2k_dump()
9228 opj_j2k_dump_tile_info( l_tcp,(OPJ_INT32)p_j2k->m_private_image->numcomps, out_stream); in j2k_dump()
9240 opj_j2k_dump_MH_index(p_j2k, out_stream); in j2k_dump()
9250 static void opj_j2k_dump_MH_index(opj_j2k_t* p_j2k, FILE* out_stream) in opj_j2k_dump_MH_index() argument
9252 opj_codestream_index_t* cstr_index = p_j2k->cstr_index; in opj_j2k_dump_MH_index()
9319 static void opj_j2k_dump_MH_info(opj_j2k_t* p_j2k, FILE* out_stream) in opj_j2k_dump_MH_info() argument
9324 fprintf(out_stream, "\t tx0=%d, ty0=%d\n", p_j2k->m_cp.tx0, p_j2k->m_cp.ty0); in opj_j2k_dump_MH_info()
9325 fprintf(out_stream, "\t tdx=%d, tdy=%d\n", p_j2k->m_cp.tdx, p_j2k->m_cp.tdy); in opj_j2k_dump_MH_info()
9326 fprintf(out_stream, "\t tw=%d, th=%d\n", p_j2k->m_cp.tw, p_j2k->m_cp.th); in opj_j2k_dump_MH_info()
9327 …opj_j2k_dump_tile_info(p_j2k->m_specific_param.m_decoder.m_default_tcp,(OPJ_INT32)p_j2k->m_private… in opj_j2k_dump_MH_info()
9379 opj_codestream_info_v2_t* j2k_get_cstr_info(opj_j2k_t* p_j2k) in j2k_get_cstr_info() argument
9382 OPJ_UINT32 numcomps = p_j2k->m_private_image->numcomps; in j2k_get_cstr_info()
9388 cstr_info->nbcomps = p_j2k->m_private_image->numcomps; in j2k_get_cstr_info()
9390 cstr_info->tx0 = p_j2k->m_cp.tx0; in j2k_get_cstr_info()
9391 cstr_info->ty0 = p_j2k->m_cp.ty0; in j2k_get_cstr_info()
9392 cstr_info->tdx = p_j2k->m_cp.tdx; in j2k_get_cstr_info()
9393 cstr_info->tdy = p_j2k->m_cp.tdy; in j2k_get_cstr_info()
9394 cstr_info->tw = p_j2k->m_cp.tw; in j2k_get_cstr_info()
9395 cstr_info->th = p_j2k->m_cp.th; in j2k_get_cstr_info()
9399 l_default_tile = p_j2k->m_specific_param.m_decoder.m_default_tcp; in j2k_get_cstr_info()
9450 opj_codestream_index_t* j2k_get_cstr_index(opj_j2k_t* p_j2k) in j2k_get_cstr_index() argument
9457 l_cstr_index->main_head_start = p_j2k->cstr_index->main_head_start; in j2k_get_cstr_index()
9458 l_cstr_index->main_head_end = p_j2k->cstr_index->main_head_end; in j2k_get_cstr_index()
9459 l_cstr_index->codestream_size = p_j2k->cstr_index->codestream_size; in j2k_get_cstr_index()
9461 l_cstr_index->marknum = p_j2k->cstr_index->marknum; in j2k_get_cstr_index()
9468 if (p_j2k->cstr_index->marker) in j2k_get_cstr_index()
9469 …memcpy(l_cstr_index->marker, p_j2k->cstr_index->marker, l_cstr_index->marknum * sizeof(opj_marker_… in j2k_get_cstr_index()
9475 l_cstr_index->nb_of_tiles = p_j2k->cstr_index->nb_of_tiles; in j2k_get_cstr_index()
9483 if (!p_j2k->cstr_index->tile_index){ in j2k_get_cstr_index()
9492 … l_cstr_index->tile_index[it_tile].marknum = p_j2k->cstr_index->tile_index[it_tile].marknum; in j2k_get_cstr_index()
9510 if (p_j2k->cstr_index->tile_index[it_tile].marker) in j2k_get_cstr_index()
9512 p_j2k->cstr_index->tile_index[it_tile].marker, in j2k_get_cstr_index()
9520 … l_cstr_index->tile_index[it_tile].nb_tps = p_j2k->cstr_index->tile_index[it_tile].nb_tps; in j2k_get_cstr_index()
9539 if (p_j2k->cstr_index->tile_index[it_tile].tp_index){ in j2k_get_cstr_index()
9541 p_j2k->cstr_index->tile_index[it_tile].tp_index, in j2k_get_cstr_index()
9559 static OPJ_BOOL opj_j2k_allocate_tile_element_cstr_index(opj_j2k_t *p_j2k) in opj_j2k_allocate_tile_element_cstr_index() argument
9563 p_j2k->cstr_index->nb_of_tiles = p_j2k->m_cp.tw * p_j2k->m_cp.th; in opj_j2k_allocate_tile_element_cstr_index()
9564p_j2k->cstr_index->tile_index = (opj_tile_index_t*)opj_calloc(p_j2k->cstr_index->nb_of_tiles, size… in opj_j2k_allocate_tile_element_cstr_index()
9565 if (!p_j2k->cstr_index->tile_index) in opj_j2k_allocate_tile_element_cstr_index()
9568 for (it_tile=0; it_tile < p_j2k->cstr_index->nb_of_tiles; it_tile++){ in opj_j2k_allocate_tile_element_cstr_index()
9569 p_j2k->cstr_index->tile_index[it_tile].maxmarknum = 100; in opj_j2k_allocate_tile_element_cstr_index()
9570 p_j2k->cstr_index->tile_index[it_tile].marknum = 0; in opj_j2k_allocate_tile_element_cstr_index()
9571 p_j2k->cstr_index->tile_index[it_tile].marker = (opj_marker_info_t*) in opj_j2k_allocate_tile_element_cstr_index()
9572 … opj_calloc(p_j2k->cstr_index->tile_index[it_tile].maxmarknum, sizeof(opj_marker_info_t)); in opj_j2k_allocate_tile_element_cstr_index()
9573 if (!p_j2k->cstr_index->tile_index[it_tile].marker) in opj_j2k_allocate_tile_element_cstr_index()
9580 static OPJ_BOOL opj_j2k_decode_tiles ( opj_j2k_t *p_j2k, in opj_j2k_decode_tiles() argument
9600 if (! opj_j2k_read_tile_header( p_j2k, in opj_j2k_decode_tiles()
9621 …"Not enough memory to decode tile %d/%d\n", l_current_tile_no +1, p_j2k->m_cp.th * p_j2k->m_cp.tw); in opj_j2k_decode_tiles()
9628 …if (! opj_j2k_decode_tile(p_j2k,l_current_tile_no,l_current_data,l_data_size,p_stream,p_manager)) { in opj_j2k_decode_tiles()
9630 …EVT_ERROR, "Failed to decode tile %d/%d\n", l_current_tile_no +1, p_j2k->m_cp.th * p_j2k->m_cp.tw); in opj_j2k_decode_tiles()
9633 …EVT_INFO, "Tile %d/%d has been decoded.\n", l_current_tile_no +1, p_j2k->m_cp.th * p_j2k->m_cp.tw); in opj_j2k_decode_tiles()
9635 … if (! opj_j2k_update_image_data(p_j2k->m_tcd,l_current_data, p_j2k->m_output_image)) { in opj_j2k_decode_tiles()
9642 && p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_NEOC) in opj_j2k_decode_tiles()
9644 if(++nr_tiles == p_j2k->m_cp.th * p_j2k->m_cp.tw) in opj_j2k_decode_tiles()
9656 static OPJ_BOOL opj_j2k_setup_decoding (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager) in opj_j2k_setup_decoding() argument
9659 assert(p_j2k != 00); in opj_j2k_setup_decoding()
9662 …if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_decode_tiles… in opj_j2k_setup_decoding()
9673 static OPJ_BOOL opj_j2k_decode_one_tile ( opj_j2k_t *p_j2k, in opj_j2k_decode_one_tile() argument
9693 if( !p_j2k->cstr_index->tile_index) in opj_j2k_decode_one_tile()
9695 if (!opj_j2k_allocate_tile_element_cstr_index(p_j2k)){ in opj_j2k_decode_one_tile()
9701 l_tile_no_to_dec = (OPJ_UINT32)p_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec; in opj_j2k_decode_one_tile()
9702 if (p_j2k->cstr_index->tile_index) in opj_j2k_decode_one_tile()
9703 if(p_j2k->cstr_index->tile_index->tp_index) in opj_j2k_decode_one_tile()
9705 if ( ! p_j2k->cstr_index->tile_index[l_tile_no_to_dec].nb_tps) { in opj_j2k_decode_one_tile()
9708 …if ( !(opj_stream_read_seek(p_stream, p_j2k->m_specific_param.m_decoder.m_last_sot_read_pos+2, p_m… in opj_j2k_decode_one_tile()
9715 …if ( !(opj_stream_read_seek(p_stream, p_j2k->cstr_index->tile_index[l_tile_no_to_dec].tp_index[0].… in opj_j2k_decode_one_tile()
9722 if(p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_EOC) in opj_j2k_decode_one_tile()
9723 p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPHSOT; in opj_j2k_decode_one_tile()
9727 if (! opj_j2k_read_tile_header( p_j2k, in opj_j2k_decode_one_tile()
9751 … "Not enough memory to decode tile %d/%d\n", l_current_tile_no, (p_j2k->m_cp.th * p_j2k->m_cp.tw) … in opj_j2k_decode_one_tile()
9758 …if (! opj_j2k_decode_tile(p_j2k,l_current_tile_no,l_current_data,l_data_size,p_stream,p_manager)) { in opj_j2k_decode_one_tile()
9762 … EVT_INFO, "Tile %d/%d has been decoded.\n", l_current_tile_no, (p_j2k->m_cp.th * p_j2k->m_cp.tw) … in opj_j2k_decode_one_tile()
9764 … if (! opj_j2k_update_image_data(p_j2k->m_tcd,l_current_data, p_j2k->m_output_image)) { in opj_j2k_decode_one_tile()
9773 … if (!(opj_stream_read_seek(p_stream, p_j2k->cstr_index->main_head_end + 2, p_manager) ) ) { in opj_j2k_decode_one_tile()
9794 static OPJ_BOOL opj_j2k_setup_decoding_tile (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager) in opj_j2k_setup_decoding_tile() argument
9797 assert(p_j2k != 00); in opj_j2k_setup_decoding_tile()
9800 …if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_decode_one_t… in opj_j2k_setup_decoding_tile()
9808 OPJ_BOOL opj_j2k_decode(opj_j2k_t * p_j2k, in opj_j2k_decode() argument
9818 p_j2k->m_output_image = opj_image_create0(); in opj_j2k_decode()
9819 if (! (p_j2k->m_output_image)) { in opj_j2k_decode()
9822 opj_copy_image_header(p_image, p_j2k->m_output_image); in opj_j2k_decode()
9825 opj_j2k_setup_decoding(p_j2k, p_manager); in opj_j2k_decode()
9828 if (! opj_j2k_exec (p_j2k,p_j2k->m_procedure_list,p_stream,p_manager)) { in opj_j2k_decode()
9829 opj_image_destroy(p_j2k->m_private_image); in opj_j2k_decode()
9830 p_j2k->m_private_image = NULL; in opj_j2k_decode()
9836 … p_image->comps[compno].resno_decoded = p_j2k->m_output_image->comps[compno].resno_decoded; in opj_j2k_decode()
9837 p_image->comps[compno].data = p_j2k->m_output_image->comps[compno].data; in opj_j2k_decode()
9845 p_j2k->m_output_image->comps[compno].data = NULL; in opj_j2k_decode()
9851 OPJ_BOOL opj_j2k_get_tile( opj_j2k_t *p_j2k, in opj_j2k_get_tile() argument
9866 if ( /*(tile_index < 0) &&*/ (tile_index >= p_j2k->m_cp.tw * p_j2k->m_cp.th) ){ in opj_j2k_get_tile()
9867 …rovided by the user is incorrect %d (max = %d) \n", tile_index, (p_j2k->m_cp.tw * p_j2k->m_cp.th) … in opj_j2k_get_tile()
9872 l_tile_x = tile_index % p_j2k->m_cp.tw; in opj_j2k_get_tile()
9873 l_tile_y = tile_index / p_j2k->m_cp.tw; in opj_j2k_get_tile()
9875 p_image->x0 = l_tile_x * p_j2k->m_cp.tdx + p_j2k->m_cp.tx0; in opj_j2k_get_tile()
9876 if (p_image->x0 < p_j2k->m_private_image->x0) in opj_j2k_get_tile()
9877 p_image->x0 = p_j2k->m_private_image->x0; in opj_j2k_get_tile()
9878 p_image->x1 = (l_tile_x + 1) * p_j2k->m_cp.tdx + p_j2k->m_cp.tx0; in opj_j2k_get_tile()
9879 if (p_image->x1 > p_j2k->m_private_image->x1) in opj_j2k_get_tile()
9880 p_image->x1 = p_j2k->m_private_image->x1; in opj_j2k_get_tile()
9882 p_image->y0 = l_tile_y * p_j2k->m_cp.tdy + p_j2k->m_cp.ty0; in opj_j2k_get_tile()
9883 if (p_image->y0 < p_j2k->m_private_image->y0) in opj_j2k_get_tile()
9884 p_image->y0 = p_j2k->m_private_image->y0; in opj_j2k_get_tile()
9885 p_image->y1 = (l_tile_y + 1) * p_j2k->m_cp.tdy + p_j2k->m_cp.ty0; in opj_j2k_get_tile()
9886 if (p_image->y1 > p_j2k->m_private_image->y1) in opj_j2k_get_tile()
9887 p_image->y1 = p_j2k->m_private_image->y1; in opj_j2k_get_tile()
9894 l_img_comp->factor = p_j2k->m_private_image->comps[compno].factor; in opj_j2k_get_tile()
9908 if (p_j2k->m_output_image) in opj_j2k_get_tile()
9909 opj_image_destroy(p_j2k->m_output_image); in opj_j2k_get_tile()
9912 p_j2k->m_output_image = opj_image_create0(); in opj_j2k_get_tile()
9913 if (! (p_j2k->m_output_image)) { in opj_j2k_get_tile()
9916 opj_copy_image_header(p_image, p_j2k->m_output_image); in opj_j2k_get_tile()
9918 p_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec = (OPJ_INT32)tile_index; in opj_j2k_get_tile()
9921 opj_j2k_setup_decoding_tile(p_j2k, p_manager); in opj_j2k_get_tile()
9924 if (! opj_j2k_exec (p_j2k,p_j2k->m_procedure_list,p_stream,p_manager)) { in opj_j2k_get_tile()
9925 opj_image_destroy(p_j2k->m_private_image); in opj_j2k_get_tile()
9926 p_j2k->m_private_image = NULL; in opj_j2k_get_tile()
9932 … p_image->comps[compno].resno_decoded = p_j2k->m_output_image->comps[compno].resno_decoded; in opj_j2k_get_tile()
9937 p_image->comps[compno].data = p_j2k->m_output_image->comps[compno].data; in opj_j2k_get_tile()
9939 p_j2k->m_output_image->comps[compno].data = NULL; in opj_j2k_get_tile()
9945 OPJ_BOOL opj_j2k_set_decoded_resolution_factor(opj_j2k_t *p_j2k, in opj_j2k_set_decoded_resolution_factor() argument
9951 p_j2k->m_cp.m_specific_param.m_dec.m_reduce = res_factor; in opj_j2k_set_decoded_resolution_factor()
9953 if (p_j2k->m_private_image) { in opj_j2k_set_decoded_resolution_factor()
9954 if (p_j2k->m_private_image->comps) { in opj_j2k_set_decoded_resolution_factor()
9955 if (p_j2k->m_specific_param.m_decoder.m_default_tcp) { in opj_j2k_set_decoded_resolution_factor()
9956 if (p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps) { in opj_j2k_set_decoded_resolution_factor()
9957 … for (it_comp = 0 ; it_comp < p_j2k->m_private_image->numcomps; it_comp++) { in opj_j2k_set_decoded_resolution_factor()
9958 …OPJ_UINT32 max_res = p_j2k->m_specific_param.m_decoder.m_default_tcp->tccps[it_comp].numresolution… in opj_j2k_set_decoded_resolution_factor()
9963p_j2k->m_private_image->comps[it_comp].factor = res_factor; in opj_j2k_set_decoded_resolution_factor()
9974 OPJ_BOOL opj_j2k_encode(opj_j2k_t * p_j2k, in opj_j2k_encode() argument
9985 assert(p_j2k != 00); in opj_j2k_encode()
9989 p_tcd = p_j2k->m_tcd; in opj_j2k_encode()
9991 l_nb_tiles = p_j2k->m_cp.th * p_j2k->m_cp.tw; in opj_j2k_encode()
9993 if (! opj_j2k_pre_write_tile(p_j2k,i,p_stream,p_manager)) { in opj_j2k_encode()
10002 for (j=0;j<p_j2k->m_tcd->image->numcomps;++j) { in opj_j2k_encode()
10018 l_current_tile_size = opj_tcd_get_encoded_tile_size(p_j2k->m_tcd); in opj_j2k_encode()
10036 opj_j2k_get_tile_data(p_j2k->m_tcd,l_current_data); in opj_j2k_encode()
10039 … if (! opj_tcd_copy_tile_data(p_j2k->m_tcd,l_current_data,l_current_tile_size)) { in opj_j2k_encode()
10046 if (! opj_j2k_post_write_tile (p_j2k,p_stream,p_manager)) { in opj_j2k_encode()
10060 OPJ_BOOL opj_j2k_end_compress( opj_j2k_t *p_j2k, in opj_j2k_end_compress() argument
10065 if (! opj_j2k_setup_end_compress(p_j2k, p_manager)) { in opj_j2k_end_compress()
10069 if (! opj_j2k_exec (p_j2k, p_j2k->m_procedure_list, p_stream, p_manager)) in opj_j2k_end_compress()
10077 OPJ_BOOL opj_j2k_start_compress(opj_j2k_t *p_j2k, in opj_j2k_start_compress() argument
10083 assert(p_j2k != 00); in opj_j2k_start_compress()
10087 p_j2k->m_private_image = opj_image_create0(); in opj_j2k_start_compress()
10088 if (! p_j2k->m_private_image) { in opj_j2k_start_compress()
10092 opj_copy_image_header(p_image, p_j2k->m_private_image); in opj_j2k_start_compress()
10099p_j2k->m_private_image->comps[it_comp].data =p_image->comps[it_comp].data; in opj_j2k_start_compress()
10107 if (! opj_j2k_setup_encoding_validation (p_j2k, p_manager)) { in opj_j2k_start_compress()
10112 if (! opj_j2k_exec(p_j2k,p_j2k->m_validation_list,p_stream,p_manager)) { in opj_j2k_start_compress()
10117 if (! opj_j2k_setup_header_writing(p_j2k, p_manager)) { in opj_j2k_start_compress()
10122 if (! opj_j2k_exec (p_j2k,p_j2k->m_procedure_list,p_stream,p_manager)) { in opj_j2k_start_compress()
10129 static OPJ_BOOL opj_j2k_pre_write_tile ( opj_j2k_t * p_j2k, in opj_j2k_pre_write_tile() argument
10135 if (p_tile_index != p_j2k->m_current_tile_number) { in opj_j2k_pre_write_tile()
10140 …g(p_manager, EVT_INFO, "tile number %d / %d\n", p_j2k->m_current_tile_number + 1, p_j2k->m_cp.tw *… in opj_j2k_pre_write_tile()
10142 p_j2k->m_specific_param.m_encoder.m_current_tile_part_number = 0; in opj_j2k_pre_write_tile()
10143 p_j2k->m_tcd->cur_totnum_tp = p_j2k->m_cp.tcps[p_tile_index].m_nb_tile_parts; in opj_j2k_pre_write_tile()
10144 p_j2k->m_specific_param.m_encoder.m_current_poc_tile_part_number = 0; in opj_j2k_pre_write_tile()
10147 if (! opj_tcd_init_encode_tile(p_j2k->m_tcd, p_j2k->m_current_tile_number, p_manager)) { in opj_j2k_pre_write_tile()
10278 static OPJ_BOOL opj_j2k_post_write_tile ( opj_j2k_t * p_j2k, in opj_j2k_post_write_tile() argument
10288 assert(p_j2k->m_specific_param.m_encoder.m_encoded_tile_data); in opj_j2k_post_write_tile()
10290 l_tile_size = p_j2k->m_specific_param.m_encoder.m_encoded_tile_size; in opj_j2k_post_write_tile()
10292 l_current_data = p_j2k->m_specific_param.m_encoder.m_encoded_tile_data; in opj_j2k_post_write_tile()
10295 …if (! opj_j2k_write_first_tile_part(p_j2k,l_current_data,&l_nb_bytes_written,l_available_data,p_st… in opj_j2k_post_write_tile()
10302 …if (! opj_j2k_write_all_tile_parts(p_j2k,l_current_data,&l_nb_bytes_written,l_available_data,p_str… in opj_j2k_post_write_tile()
10310p_j2k->m_specific_param.m_encoder.m_encoded_tile_data, in opj_j2k_post_write_tile()
10315 ++p_j2k->m_current_tile_number; in opj_j2k_post_write_tile()
10320 static OPJ_BOOL opj_j2k_setup_end_compress (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager) in opj_j2k_setup_end_compress() argument
10323 assert(p_j2k != 00); in opj_j2k_setup_end_compress()
10327 …if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_eoc, p… in opj_j2k_setup_end_compress()
10331 if (OPJ_IS_CINEMA(p_j2k->m_cp.rsiz)) { in opj_j2k_setup_end_compress()
10332 …if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_update… in opj_j2k_setup_end_compress()
10337 …if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_epc, p… in opj_j2k_setup_end_compress()
10340 …if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_end_encoding… in opj_j2k_setup_end_compress()
10343 …if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_destroy_head… in opj_j2k_setup_end_compress()
10349 static OPJ_BOOL opj_j2k_setup_encoding_validation (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager) in opj_j2k_setup_encoding_validation() argument
10352 assert(p_j2k != 00); in opj_j2k_setup_encoding_validation()
10355 …if (! opj_procedure_list_add_procedure(p_j2k->m_validation_list, (opj_procedure)opj_j2k_build_enco… in opj_j2k_setup_encoding_validation()
10358 …if (! opj_procedure_list_add_procedure(p_j2k->m_validation_list, (opj_procedure)opj_j2k_encoding_v… in opj_j2k_setup_encoding_validation()
10363 …if (! opj_procedure_list_add_procedure(p_j2k->m_validation_list, (opj_procedure)opj_j2k_mct_valida… in opj_j2k_setup_encoding_validation()
10370 static OPJ_BOOL opj_j2k_setup_header_writing (opj_j2k_t *p_j2k, opj_event_mgr_t * p_manager) in opj_j2k_setup_header_writing() argument
10373 assert(p_j2k != 00); in opj_j2k_setup_header_writing()
10376 …if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_init_info, p… in opj_j2k_setup_header_writing()
10379 …if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_soc, p… in opj_j2k_setup_header_writing()
10382 …if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_siz, p… in opj_j2k_setup_header_writing()
10385 …if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_cod, p… in opj_j2k_setup_header_writing()
10388 …if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_qcd, p… in opj_j2k_setup_header_writing()
10392 if (OPJ_IS_CINEMA(p_j2k->m_cp.rsiz)) { in opj_j2k_setup_header_writing()
10401 …if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_tlm, p… in opj_j2k_setup_header_writing()
10405 if (p_j2k->m_cp.rsiz == OPJ_PROFILE_CINEMA_4K) { in opj_j2k_setup_header_writing()
10406 …if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_poc, p… in opj_j2k_setup_header_writing()
10412 …if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_region… in opj_j2k_setup_header_writing()
10416 if (p_j2k->m_cp.comment != 00) { in opj_j2k_setup_header_writing()
10417 …if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_com, p… in opj_j2k_setup_header_writing()
10423 if (p_j2k->m_cp.rsiz & OPJ_EXTENSION_MCT) { in opj_j2k_setup_header_writing()
10424 …if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_write_mct_da… in opj_j2k_setup_header_writing()
10430 if (p_j2k->cstr_index) { in opj_j2k_setup_header_writing()
10431 …if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_get_end_head… in opj_j2k_setup_header_writing()
10436 …if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_create_tcd, … in opj_j2k_setup_header_writing()
10439 …if (! opj_procedure_list_add_procedure(p_j2k->m_procedure_list,(opj_procedure)opj_j2k_update_rates… in opj_j2k_setup_header_writing()
10446 static OPJ_BOOL opj_j2k_write_first_tile_part (opj_j2k_t *p_j2k, in opj_j2k_write_first_tile_part() argument
10460 l_tcd = p_j2k->m_tcd; in opj_j2k_write_first_tile_part()
10461 l_cp = &(p_j2k->m_cp); in opj_j2k_write_first_tile_part()
10466 p_j2k->m_specific_param.m_encoder.m_current_poc_tile_part_number = 0; in opj_j2k_write_first_tile_part()
10473 if (! opj_j2k_write_sot(p_j2k,p_data,&l_current_nb_bytes_written,p_stream,p_manager)) in opj_j2k_write_first_tile_part()
10484 for (compno = 1; compno < p_j2k->m_private_image->numcomps; compno++) { in opj_j2k_write_first_tile_part()
10486 … opj_j2k_write_coc_in_memory(p_j2k,compno,p_data,&l_current_nb_bytes_written,p_manager); in opj_j2k_write_first_tile_part()
10492 … opj_j2k_write_qcc_in_memory(p_j2k,compno,p_data,&l_current_nb_bytes_written,p_manager); in opj_j2k_write_first_tile_part()
10499 if (l_cp->tcps[p_j2k->m_current_tile_number].numpocs) { in opj_j2k_write_first_tile_part()
10501 … opj_j2k_write_poc_in_memory(p_j2k,p_data,&l_current_nb_bytes_written,p_manager); in opj_j2k_write_first_tile_part()
10509 …if (! opj_j2k_write_sod(p_j2k,l_tcd,p_data,&l_current_nb_bytes_written,p_total_data_size,p_stream,… in opj_j2k_write_first_tile_part()
10520 opj_j2k_update_tlm(p_j2k,l_nb_bytes_written); in opj_j2k_write_first_tile_part()
10526 static OPJ_BOOL opj_j2k_write_all_tile_parts( opj_j2k_t *p_j2k, in opj_j2k_write_all_tile_parts() argument
10546 l_tcd = p_j2k->m_tcd; in opj_j2k_write_all_tile_parts()
10547 l_cp = &(p_j2k->m_cp); in opj_j2k_write_all_tile_parts()
10548 l_tcp = l_cp->tcps + p_j2k->m_current_tile_number; in opj_j2k_write_all_tile_parts()
10551 tot_num_tp = opj_j2k_get_num_tp(l_cp,0,p_j2k->m_current_tile_number); in opj_j2k_write_all_tile_parts()
10554 ++p_j2k->m_specific_param.m_encoder.m_current_tile_part_number; in opj_j2k_write_all_tile_parts()
10556 p_j2k->m_specific_param.m_encoder.m_current_poc_tile_part_number = tilepartno; in opj_j2k_write_all_tile_parts()
10561 … if (! opj_j2k_write_sot(p_j2k,p_data,&l_current_nb_bytes_written,p_stream,p_manager)) { in opj_j2k_write_all_tile_parts()
10571 …if (! opj_j2k_write_sod(p_j2k,l_tcd,p_data,&l_current_nb_bytes_written,p_total_data_size,p_stream,… in opj_j2k_write_all_tile_parts()
10584 opj_j2k_update_tlm(p_j2k,l_part_tile_size); in opj_j2k_write_all_tile_parts()
10587 ++p_j2k->m_specific_param.m_encoder.m_current_tile_part_number; in opj_j2k_write_all_tile_parts()
10594 tot_num_tp = opj_j2k_get_num_tp(l_cp,pino,p_j2k->m_current_tile_number); in opj_j2k_write_all_tile_parts()
10596p_j2k->m_specific_param.m_encoder.m_current_poc_tile_part_number = tilepartno; in opj_j2k_write_all_tile_parts()
10601 … if (! opj_j2k_write_sot(p_j2k,p_data,&l_current_nb_bytes_written,p_stream,p_manager)) { in opj_j2k_write_all_tile_parts()
10612 …if (! opj_j2k_write_sod(p_j2k,l_tcd,p_data,&l_current_nb_bytes_written,p_total_data_size,p_stream,… in opj_j2k_write_all_tile_parts()
10625 opj_j2k_update_tlm(p_j2k,l_part_tile_size); in opj_j2k_write_all_tile_parts()
10628 ++p_j2k->m_specific_param.m_encoder.m_current_tile_part_number; in opj_j2k_write_all_tile_parts()
10637 static OPJ_BOOL opj_j2k_write_updated_tlm( opj_j2k_t *p_j2k, in opj_j2k_write_updated_tlm() argument
10645 assert(p_j2k != 00); in opj_j2k_write_updated_tlm()
10649 l_tlm_size = 5 * p_j2k->m_specific_param.m_encoder.m_total_tile_parts; in opj_j2k_write_updated_tlm()
10650 l_tlm_position = 6 + p_j2k->m_specific_param.m_encoder.m_tlm_start; in opj_j2k_write_updated_tlm()
10657 …if (opj_stream_write_data(p_stream,p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer,l_tl… in opj_j2k_write_updated_tlm()
10668 static OPJ_BOOL opj_j2k_end_encoding( opj_j2k_t *p_j2k, in opj_j2k_end_encoding() argument
10673 assert(p_j2k != 00); in opj_j2k_end_encoding()
10677 opj_tcd_destroy(p_j2k->m_tcd); in opj_j2k_end_encoding()
10678 p_j2k->m_tcd = 00; in opj_j2k_end_encoding()
10680 if (p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer) { in opj_j2k_end_encoding()
10681 opj_free(p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer); in opj_j2k_end_encoding()
10682 p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_buffer = 0; in opj_j2k_end_encoding()
10683 p_j2k->m_specific_param.m_encoder.m_tlm_sot_offsets_current = 0; in opj_j2k_end_encoding()
10686 if (p_j2k->m_specific_param.m_encoder.m_encoded_tile_data) { in opj_j2k_end_encoding()
10687 opj_free(p_j2k->m_specific_param.m_encoder.m_encoded_tile_data); in opj_j2k_end_encoding()
10688 p_j2k->m_specific_param.m_encoder.m_encoded_tile_data = 0; in opj_j2k_end_encoding()
10691 p_j2k->m_specific_param.m_encoder.m_encoded_tile_size = 0; in opj_j2k_end_encoding()
10699 static OPJ_BOOL opj_j2k_destroy_header_memory ( opj_j2k_t * p_j2k, in opj_j2k_destroy_header_memory() argument
10705 assert(p_j2k != 00); in opj_j2k_destroy_header_memory()
10709 if (p_j2k->m_specific_param.m_encoder.m_header_tile_data) { in opj_j2k_destroy_header_memory()
10710 opj_free(p_j2k->m_specific_param.m_encoder.m_header_tile_data); in opj_j2k_destroy_header_memory()
10711 p_j2k->m_specific_param.m_encoder.m_header_tile_data = 0; in opj_j2k_destroy_header_memory()
10714 p_j2k->m_specific_param.m_encoder.m_header_tile_data_size = 0; in opj_j2k_destroy_header_memory()
10719 static OPJ_BOOL opj_j2k_init_info( opj_j2k_t *p_j2k, in opj_j2k_init_info() argument
10726 assert(p_j2k != 00); in opj_j2k_init_info()
10770 …return opj_j2k_calculate_tp(p_j2k,&(p_j2k->m_cp),&p_j2k->m_specific_param.m_encoder.m_total_tile_p… in opj_j2k_init_info()
10780 static OPJ_BOOL opj_j2k_create_tcd( opj_j2k_t *p_j2k, in opj_j2k_create_tcd() argument
10786 assert(p_j2k != 00); in opj_j2k_create_tcd()
10790 p_j2k->m_tcd = opj_tcd_create(OPJ_FALSE); in opj_j2k_create_tcd()
10792 if (! p_j2k->m_tcd) { in opj_j2k_create_tcd()
10797 if (!opj_tcd_init(p_j2k->m_tcd,p_j2k->m_private_image,&p_j2k->m_cp)) { in opj_j2k_create_tcd()
10798 opj_tcd_destroy(p_j2k->m_tcd); in opj_j2k_create_tcd()
10799 p_j2k->m_tcd = 00; in opj_j2k_create_tcd()
10806 OPJ_BOOL opj_j2k_write_tile (opj_j2k_t * p_j2k, in opj_j2k_write_tile() argument
10813 if (! opj_j2k_pre_write_tile(p_j2k,p_tile_index,p_stream,p_manager)) { in opj_j2k_write_tile()
10820 for (j=0;j<p_j2k->m_tcd->image->numcomps;++j) { in opj_j2k_write_tile()
10821 opj_tcd_tilecomp_t* l_tilec = p_j2k->m_tcd->tcd_image->tiles->comps + j; in opj_j2k_write_tile()
10830 if (! opj_tcd_copy_tile_data(p_j2k->m_tcd,p_data,p_data_size)) { in opj_j2k_write_tile()
10834 if (! opj_j2k_post_write_tile(p_j2k,p_stream,p_manager)) { in opj_j2k_write_tile()