| OLD | NEW |
| 1 /* | 1 /* |
| 2 * The copyright in this software is being made available under the 2-clauses | 2 * The copyright in this software is being made available under the 2-clauses |
| 3 * BSD License, included below. This software may be subject to other third | 3 * BSD License, included below. This software may be subject to other third |
| 4 * party and contributor rights, including patent rights, and no such rights | 4 * party and contributor rights, including patent rights, and no such rights |
| 5 * are granted under this license. | 5 * are granted under this license. |
| 6 * | 6 * |
| 7 * Copyright (c) 2005, Herve Drolon, FreeImage Team | 7 * Copyright (c) 2005, Herve Drolon, FreeImage Team |
| 8 * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR | 8 * Copyright (c) 2008, 2011-2012, Centre National d'Etudes Spatiales (CNES), FR |
| 9 * Copyright (c) 2012, CS Systemes d'Information, France | 9 * Copyright (c) 2012, CS Systemes d'Information, France |
| 10 * All rights reserved. | 10 * All rights reserved. |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 return OPJ_FALSE; | 125 return OPJ_FALSE; |
| 126 } | 126 } |
| 127 | 127 |
| 128 return OPJ_TRUE; | 128 return OPJ_TRUE; |
| 129 } | 129 } |
| 130 | 130 |
| 131 /* ---------------------------------------------------------------------- */ | 131 /* ---------------------------------------------------------------------- */ |
| 132 #ifdef _WIN32 | 132 #ifdef _WIN32 |
| 133 #ifndef OPJ_STATIC | 133 #ifndef OPJ_STATIC |
| 134 BOOL APIENTRY | 134 BOOL APIENTRY |
| 135 DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { | 135 DllMain(HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { |
| 136 | 136 |
| 137 OPJ_ARG_NOT_USED(lpReserved); | 137 OPJ_ARG_NOT_USED(lpReserved); |
| 138 OPJ_ARG_NOT_USED(hModule); | 138 OPJ_ARG_NOT_USED(hModule); |
| 139 | 139 |
| 140 switch (ul_reason_for_call) { | 140 switch (ul_reason_for_call) { |
| 141 case DLL_PROCESS_ATTACH : | 141 case DLL_PROCESS_ATTACH : |
| 142 break; | 142 break; |
| 143 case DLL_PROCESS_DETACH : | 143 case DLL_PROCESS_DETACH : |
| 144 break; | 144 break; |
| 145 case DLL_THREAD_ATTACH : | 145 case DLL_THREAD_ATTACH : |
| (...skipping 16 matching lines...) Expand all Loading... |
| 162 /* DECOMPRESSION FUNCTIONS*/ | 162 /* DECOMPRESSION FUNCTIONS*/ |
| 163 | 163 |
| 164 opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format) | 164 opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format) |
| 165 { | 165 { |
| 166 opj_codec_private_t *l_codec = 00; | 166 opj_codec_private_t *l_codec = 00; |
| 167 | 167 |
| 168 l_codec = (opj_codec_private_t*) opj_calloc(1, sizeof(opj_codec_private_
t)); | 168 l_codec = (opj_codec_private_t*) opj_calloc(1, sizeof(opj_codec_private_
t)); |
| 169 if (!l_codec){ | 169 if (!l_codec){ |
| 170 return 00; | 170 return 00; |
| 171 } | 171 } |
| 172 memset(l_codec, 0, sizeof(opj_codec_private_t)); | |
| 173 | 172 |
| 174 l_codec->is_decompressor = 1; | 173 l_codec->is_decompressor = 1; |
| 175 | 174 |
| 176 switch (p_format) { | 175 switch (p_format) { |
| 177 case OPJ_CODEC_J2K: | 176 case OPJ_CODEC_J2K: |
| 178 l_codec->opj_dump_codec = (void (*) (void*, OPJ_INT32, F
ILE*)) j2k_dump; | 177 l_codec->opj_dump_codec = (void (*) (void*, OPJ_INT32, F
ILE*)) j2k_dump; |
| 179 | 178 |
| 180 l_codec->opj_get_codec_info = (opj_codestream_info_v2_t*
(*) (void*) ) j2k_get_cstr_info; | 179 l_codec->opj_get_codec_info = (opj_codestream_info_v2_t*
(*) (void*) ) j2k_get_cstr_info; |
| 181 | 180 |
| 182 l_codec->opj_get_codec_index = (opj_codestream_index_t*
(*) (void*) ) j2k_get_cstr_index; | 181 l_codec->opj_get_codec_index = (opj_codestream_index_t*
(*) (void*) ) j2k_get_cstr_index; |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 /* COMPRESSION FUNCTIONS*/ | 538 /* COMPRESSION FUNCTIONS*/ |
| 540 | 539 |
| 541 opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT p_format) | 540 opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT p_format) |
| 542 { | 541 { |
| 543 opj_codec_private_t *l_codec = 00; | 542 opj_codec_private_t *l_codec = 00; |
| 544 | 543 |
| 545 l_codec = (opj_codec_private_t*)opj_calloc(1, sizeof(opj_codec_private_t
)); | 544 l_codec = (opj_codec_private_t*)opj_calloc(1, sizeof(opj_codec_private_t
)); |
| 546 if (!l_codec) { | 545 if (!l_codec) { |
| 547 return 00; | 546 return 00; |
| 548 } | 547 } |
| 549 memset(l_codec, 0, sizeof(opj_codec_private_t)); | |
| 550 | 548 |
| 551 l_codec->is_decompressor = 0; | 549 l_codec->is_decompressor = 0; |
| 552 | 550 |
| 553 switch(p_format) { | 551 switch(p_format) { |
| 554 case OPJ_CODEC_J2K: | 552 case OPJ_CODEC_J2K: |
| 555 l_codec->m_codec_data.m_compression.opj_encode = (OPJ_BO
OL (*) (void *, | 553 l_codec->m_codec_data.m_compression.opj_encode = (OPJ_BO
OL (*) (void *, |
| 556
struct o
pj_stream_private *, | 554
struct o
pj_stream_private *, |
| 557
struct o
pj_event_mgr * )) opj_j2k_encode; | 555
struct o
pj_event_mgr * )) opj_j2k_encode; |
| 558 | 556 |
| 559 l_codec->m_codec_data.m_compression.opj_end_compress = (
OPJ_BOOL (*) ( void *, | 557 l_codec->m_codec_data.m_compression.opj_end_compress = (
OPJ_BOOL (*) ( void *, |
| 560
struct opj_stream_private *, | 558
struct opj_stream_private *, |
| 561
struct opj_event_mgr *)) opj_j2k_end_compress; | 559
struct opj_event_mgr *)) opj_j2k_end_compress; |
| 562 | 560 |
| 563 l_codec->m_codec_data.m_compression.opj_start_compress =
(OPJ_BOOL (*) (void *, | 561 l_codec->m_codec_data.m_compression.opj_start_compress =
(OPJ_BOOL (*) (void *, |
| 564
struct opj_stream_private *, | 562
struct opj_stream_private *, |
| 565
struct opj_image * , | 563
struct opj_image * , |
| 566
struct opj_event_mgr *)) opj_j2k_start_compress; | 564
struct opj_event_mgr *)) opj_j2k_start_compress; |
| 567 | 565 |
| 568 l_codec->m_codec_data.m_compression.opj_write_tile = (OP
J_BOOL (*) (void *, | 566 l_codec->m_codec_data.m_compression.opj_write_tile = (OP
J_BOOL (*) (void *, |
| 569
OPJ_UINT32, | 567
OPJ_UINT32, |
| 570
OPJ_BYTE*, | 568
OPJ_BYTE*, |
| 571
OPJ_UINT32, | 569
OPJ_UINT32, |
| 572
struct opj_stream_private *, | 570
struct opj_stream_private *, |
| 573
struct opj_event_mgr *) ) opj_j2k_write_tile; | 571
struct opj_event_mgr *) ) opj_j2k_write_tile; |
| 574 | 572 |
| 575 l_codec->m_codec_data.m_compression.opj_destroy = (void
(*) (void *)) opj_j2k_destroy; | 573 l_codec->m_codec_data.m_compression.opj_destroy = (void
(*) (void *)) opj_j2k_destroy; |
| 576 | 574 |
| 577 » » » l_codec->m_codec_data.m_compression.opj_setup_encoder =
(void (*) (» void *, | 575 » » » l_codec->m_codec_data.m_compression.opj_setup_encoder =
(OPJ_BOOL (*) (»void *, |
| 578
opj_cparameters_t *, | 576
opj_cparameters_t *, |
| 579
struct opj_image *, | 577
struct opj_image *, |
| 580
struct opj_event_mgr * )) opj_j2k_setup_encoder; | 578
struct opj_event_mgr * )) opj_j2k_setup_encoder; |
| 581 | 579 |
| 582 l_codec->m_codec = opj_j2k_create_compress(); | 580 l_codec->m_codec = opj_j2k_create_compress(); |
| 583 if (! l_codec->m_codec) { | 581 if (! l_codec->m_codec) { |
| 584 opj_free(l_codec); | 582 opj_free(l_codec); |
| 585 return 00; | 583 return 00; |
| 586 } | 584 } |
| 587 | 585 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 604 | 602 |
| 605 l_codec->m_codec_data.m_compression.opj_write_tile = (OP
J_BOOL (*) (void *, | 603 l_codec->m_codec_data.m_compression.opj_write_tile = (OP
J_BOOL (*) (void *, |
| 606
OPJ_UINT32, | 604
OPJ_UINT32, |
| 607
OPJ_BYTE*, | 605
OPJ_BYTE*, |
| 608
OPJ_UINT32, | 606
OPJ_UINT32, |
| 609
struct opj_stream_private *, | 607
struct opj_stream_private *, |
| 610
struct opj_event_mgr *)) opj_jp2_write_tile; | 608
struct opj_event_mgr *)) opj_jp2_write_tile; |
| 611 | 609 |
| 612 l_codec->m_codec_data.m_compression.opj_destroy = (void
(*) (void *)) opj_jp2_destroy; | 610 l_codec->m_codec_data.m_compression.opj_destroy = (void
(*) (void *)) opj_jp2_destroy; |
| 613 | 611 |
| 614 » » » l_codec->m_codec_data.m_compression.opj_setup_encoder =
(void (*) (» void *, | 612 » » » l_codec->m_codec_data.m_compression.opj_setup_encoder =
(OPJ_BOOL (*) (»void *, |
| 615
opj_cparameters_t *, | 613
opj_cparameters_t *, |
| 616
struct opj_image *, | 614
struct opj_image *, |
| 617
struct opj_event_mgr * )) opj_jp2_setup_encoder; | 615
struct opj_event_mgr * )) opj_jp2_setup_encoder; |
| 618 | 616 |
| 619 l_codec->m_codec = opj_jp2_create(OPJ_FALSE); | 617 l_codec->m_codec = opj_jp2_create(OPJ_FALSE); |
| 620 if (! l_codec->m_codec) { | 618 if (! l_codec->m_codec) { |
| 621 opj_free(l_codec); | 619 opj_free(l_codec); |
| 622 return 00; | 620 return 00; |
| 623 } | 621 } |
| 624 | 622 |
| 625 break; | 623 break; |
| 626 | 624 |
| 627 case OPJ_CODEC_UNKNOWN: | 625 case OPJ_CODEC_UNKNOWN: |
| 628 case OPJ_CODEC_JPT: | 626 case OPJ_CODEC_JPT: |
| 629 default: | 627 default: |
| 630 opj_free(l_codec); | 628 opj_free(l_codec); |
| 631 return 00; | 629 return 00; |
| 632 } | 630 } |
| 633 | 631 |
| 634 opj_set_default_event_handler(&(l_codec->m_event_mgr)); | 632 opj_set_default_event_handler(&(l_codec->m_event_mgr)); |
| 635 return (opj_codec_t*) l_codec; | 633 return (opj_codec_t*) l_codec; |
| 636 } | 634 } |
| 637 | 635 |
| 638 void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *paramete
rs) { | 636 void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *paramete
rs) { |
| 639 if(parameters) { | 637 if(parameters) { |
| 640 memset(parameters, 0, sizeof(opj_cparameters_t)); | 638 memset(parameters, 0, sizeof(opj_cparameters_t)); |
| 641 /* default coding parameters */ | 639 /* default coding parameters */ |
| 642 » » parameters->cp_cinema = OPJ_OFF; | 640 parameters->cp_cinema = OPJ_OFF; /* DEPRECATED */ |
| 641 parameters->rsiz = OPJ_PROFILE_NONE; |
| 643 parameters->max_comp_size = 0; | 642 parameters->max_comp_size = 0; |
| 644 parameters->numresolution = 6; | 643 parameters->numresolution = 6; |
| 645 » » parameters->cp_rsiz = OPJ_STD_RSIZ; | 644 parameters->cp_rsiz = OPJ_STD_RSIZ; /* DEPRECATED */ |
| 646 parameters->cblockw_init = 64; | 645 parameters->cblockw_init = 64; |
| 647 parameters->cblockh_init = 64; | 646 parameters->cblockh_init = 64; |
| 648 parameters->prog_order = OPJ_LRCP; | 647 parameters->prog_order = OPJ_LRCP; |
| 649 parameters->roi_compno = -1; /* no ROI */ | 648 parameters->roi_compno = -1; /* no ROI */ |
| 650 parameters->subsampling_dx = 1; | 649 parameters->subsampling_dx = 1; |
| 651 parameters->subsampling_dy = 1; | 650 parameters->subsampling_dy = 1; |
| 652 parameters->tp_on = 0; | 651 parameters->tp_on = 0; |
| 653 parameters->decod_format = -1; | 652 parameters->decod_format = -1; |
| 654 parameters->cod_format = -1; | 653 parameters->cod_format = -1; |
| 655 parameters->tcp_rates[0] = 0; | 654 parameters->tcp_rates[0] = 0; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 | 785 |
| 787 OPJ_BOOL OPJ_CALLCONV opj_set_MCT(opj_cparameters_t *parameters, | 786 OPJ_BOOL OPJ_CALLCONV opj_set_MCT(opj_cparameters_t *parameters, |
| 788 OPJ_FLOAT32 * pEncodingMatrix, | 787 OPJ_FLOAT32 * pEncodingMatrix, |
| 789 OPJ_INT32 * p_dc_shift,OPJ_UINT32 pNbComp) | 788 OPJ_INT32 * p_dc_shift,OPJ_UINT32 pNbComp) |
| 790 { | 789 { |
| 791 OPJ_UINT32 l_matrix_size = pNbComp * pNbComp * (OPJ_UINT32)sizeof(OPJ_FL
OAT32); | 790 OPJ_UINT32 l_matrix_size = pNbComp * pNbComp * (OPJ_UINT32)sizeof(OPJ_FL
OAT32); |
| 792 OPJ_UINT32 l_dc_shift_size = pNbComp * (OPJ_UINT32)sizeof(OPJ_INT32); | 791 OPJ_UINT32 l_dc_shift_size = pNbComp * (OPJ_UINT32)sizeof(OPJ_INT32); |
| 793 OPJ_UINT32 l_mct_total_size = l_matrix_size + l_dc_shift_size; | 792 OPJ_UINT32 l_mct_total_size = l_matrix_size + l_dc_shift_size; |
| 794 | 793 |
| 795 /* add MCT capability */ | 794 /* add MCT capability */ |
| 796 » OPJ_INT32 rsiz = (OPJ_INT32)parameters->cp_rsiz | (OPJ_INT32)OPJ_MCT; | 795 if (OPJ_IS_PART2(parameters->rsiz)) { |
| 797 » parameters->cp_rsiz = (OPJ_RSIZ_CAPABILITIES)rsiz; | 796 parameters->rsiz |= OPJ_EXTENSION_MCT; |
| 797 } else { |
| 798 parameters->rsiz = ((OPJ_PROFILE_PART2) | (OPJ_EXTENSION_MCT)); |
| 799 } |
| 798 parameters->irreversible = 1; | 800 parameters->irreversible = 1; |
| 799 | 801 |
| 800 /* use array based MCT */ | 802 /* use array based MCT */ |
| 801 parameters->tcp_mct = 2; | 803 parameters->tcp_mct = 2; |
| 802 parameters->mct_data = opj_malloc(l_mct_total_size); | 804 parameters->mct_data = opj_malloc(l_mct_total_size); |
| 803 if (! parameters->mct_data) { | 805 if (! parameters->mct_data) { |
| 804 return OPJ_FALSE; | 806 return OPJ_FALSE; |
| 805 } | 807 } |
| 806 | 808 |
| 807 memcpy(parameters->mct_data,pEncodingMatrix,l_matrix_size); | 809 memcpy(parameters->mct_data,pEncodingMatrix,l_matrix_size); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 } | 912 } |
| 911 | 913 |
| 912 void OPJ_CALLCONV opj_destroy_cstr_index(opj_codestream_index_t **p_cstr_index) | 914 void OPJ_CALLCONV opj_destroy_cstr_index(opj_codestream_index_t **p_cstr_index) |
| 913 { | 915 { |
| 914 if (*p_cstr_index){ | 916 if (*p_cstr_index){ |
| 915 j2k_destroy_cstr_index(*p_cstr_index); | 917 j2k_destroy_cstr_index(*p_cstr_index); |
| 916 (*p_cstr_index) = NULL; | 918 (*p_cstr_index) = NULL; |
| 917 } | 919 } |
| 918 } | 920 } |
| 919 | 921 |
| 920 opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream_v3 (const char
*fname, OPJ_BOOL p_is_read_stream) | 922 opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream (const char *fn
ame, OPJ_BOOL p_is_read_stream) |
| 921 { | 923 { |
| 922 return opj_stream_create_file_stream_v3(fname, OPJ_J2K_STREAM_CHUNK_SIZE, p_
is_read_stream); | 924 return opj_stream_create_file_stream(fname, OPJ_J2K_STREAM_CHUNK_SIZE, p_is_
read_stream); |
| 923 } | 925 } |
| 924 | 926 |
| 925 opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream_v3 ( | 927 opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream ( |
| 926 const char *fname, | 928 const char *fname, |
| 927 OPJ_SIZE_T p_size, | 929 OPJ_SIZE_T p_size, |
| 928 OPJ_BOOL p_is_read_stream) | 930 OPJ_BOOL p_is_read_stream) |
| 929 { | 931 { |
| 930 opj_stream_t* l_stream = 00; | 932 opj_stream_t* l_stream = 00; |
| 931 FILE *p_file; | 933 FILE *p_file; |
| 932 const char *mode; | 934 const char *mode; |
| 933 | 935 |
| 934 if (! fname) { | 936 if (! fname) { |
| 935 return NULL; | 937 return NULL; |
| 936 } | 938 } |
| 937 | 939 |
| 938 if(p_is_read_stream) mode = "rb"; else mode = "wb"; | 940 if(p_is_read_stream) mode = "rb"; else mode = "wb"; |
| 939 | 941 |
| 940 p_file = fopen(fname, mode); | 942 p_file = fopen(fname, mode); |
| 941 | 943 |
| 942 if (! p_file) { | 944 if (! p_file) { |
| 943 return NULL; | 945 return NULL; |
| 944 } | 946 } |
| 945 | 947 |
| 946 l_stream = opj_stream_create(p_size,p_is_read_stream); | 948 l_stream = opj_stream_create(p_size,p_is_read_stream); |
| 947 if (! l_stream) { | 949 if (! l_stream) { |
| 948 fclose(p_file); | 950 fclose(p_file); |
| 949 return NULL; | 951 return NULL; |
| 950 } | 952 } |
| 951 | 953 |
| 952 opj_stream_set_user_data_v3(l_stream, p_file, (opj_stream_free_user_data_fn)
fclose); | 954 opj_stream_set_user_data(l_stream, p_file, (opj_stream_free_user_data_fn) fc
lose); |
| 953 opj_stream_set_user_data_length(l_stream, opj_get_data_length_from_file(p_fi
le)); | 955 opj_stream_set_user_data_length(l_stream, opj_get_data_length_from_file(p_fi
le)); |
| 954 opj_stream_set_read_function(l_stream, (opj_stream_read_fn) opj_read_from_fi
le); | 956 opj_stream_set_read_function(l_stream, (opj_stream_read_fn) opj_read_from_fi
le); |
| 955 opj_stream_set_write_function(l_stream, (opj_stream_write_fn) opj_write_from
_file); | 957 opj_stream_set_write_function(l_stream, (opj_stream_write_fn) opj_write_from
_file); |
| 956 opj_stream_set_skip_function(l_stream, (opj_stream_skip_fn) opj_skip_from_fi
le); | 958 opj_stream_set_skip_function(l_stream, (opj_stream_skip_fn) opj_skip_from_fi
le); |
| 957 opj_stream_set_seek_function(l_stream, (opj_stream_seek_fn) opj_seek_from_fi
le); | 959 opj_stream_set_seek_function(l_stream, (opj_stream_seek_fn) opj_seek_from_fi
le); |
| 958 | 960 |
| 959 return l_stream; | 961 return l_stream; |
| 960 } | 962 } |
| OLD | NEW |