Update openjpeg
[pdfium.git] / core / src / fxcodec / fx_libopenjpeg / libopenjpeg20 / openjpeg.c
index 89bb75a..4907c0c 100644 (file)
@@ -132,7 +132,7 @@ static OPJ_BOOL opj_seek_from_file (OPJ_OFF_T p_nb_bytes, FILE * p_user_data)
 #ifdef _WIN32
 #ifndef OPJ_STATIC
 BOOL APIENTRY
-DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
+DllMain(HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
 
        OPJ_ARG_NOT_USED(lpReserved);
        OPJ_ARG_NOT_USED(hModule);
@@ -169,7 +169,6 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format)
        if (!l_codec){
                return 00;
        }
-       memset(l_codec, 0, sizeof(opj_codec_private_t));
 
        l_codec->is_decompressor = 1;
 
@@ -546,7 +545,6 @@ opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT p_format)
        if (!l_codec) {
                return 00;
        }
-       memset(l_codec, 0, sizeof(opj_codec_private_t));
        
        l_codec->is_decompressor = 0;
 
@@ -574,7 +572,7 @@ opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT p_format)
 
                        l_codec->m_codec_data.m_compression.opj_destroy = (void (*) (void *)) opj_j2k_destroy;
 
-                       l_codec->m_codec_data.m_compression.opj_setup_encoder = (void (*) (     void *,
+                       l_codec->m_codec_data.m_compression.opj_setup_encoder = (OPJ_BOOL (*) ( void *,
                                                                                                                                                                opj_cparameters_t *,
                                                                                                                                                                struct opj_image *,
                                                                                                                                                                struct opj_event_mgr * )) opj_j2k_setup_encoder;
@@ -611,7 +609,7 @@ opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT p_format)
 
                        l_codec->m_codec_data.m_compression.opj_destroy = (void (*) (void *)) opj_jp2_destroy;
 
-                       l_codec->m_codec_data.m_compression.opj_setup_encoder = (void (*) (     void *,
+                       l_codec->m_codec_data.m_compression.opj_setup_encoder = (OPJ_BOOL (*) ( void *,
                                                                                                                                                                opj_cparameters_t *,
                                                                                                                                                                struct opj_image *,
                                                                                                                                                                struct opj_event_mgr * )) opj_jp2_setup_encoder;
@@ -639,10 +637,11 @@ void OPJ_CALLCONV opj_set_default_encoder_parameters(opj_cparameters_t *paramete
        if(parameters) {
                memset(parameters, 0, sizeof(opj_cparameters_t));
                /* default coding parameters */
-               parameters->cp_cinema = OPJ_OFF; 
+        parameters->cp_cinema = OPJ_OFF; /* DEPRECATED */
+        parameters->rsiz = OPJ_PROFILE_NONE;
                parameters->max_comp_size = 0;
                parameters->numresolution = 6;
-               parameters->cp_rsiz = OPJ_STD_RSIZ;
+        parameters->cp_rsiz = OPJ_STD_RSIZ; /* DEPRECATED */
                parameters->cblockw_init = 64;
                parameters->cblockh_init = 64;
                parameters->prog_order = OPJ_LRCP;
@@ -793,8 +792,11 @@ OPJ_BOOL OPJ_CALLCONV opj_set_MCT(opj_cparameters_t *parameters,
        OPJ_UINT32 l_mct_total_size = l_matrix_size + l_dc_shift_size;
 
        /* add MCT capability */
-       OPJ_INT32 rsiz = (OPJ_INT32)parameters->cp_rsiz | (OPJ_INT32)OPJ_MCT;
-       parameters->cp_rsiz = (OPJ_RSIZ_CAPABILITIES)rsiz;
+    if (OPJ_IS_PART2(parameters->rsiz)) {
+        parameters->rsiz |= OPJ_EXTENSION_MCT;
+    } else {
+        parameters->rsiz = ((OPJ_PROFILE_PART2) | (OPJ_EXTENSION_MCT));
+    }
        parameters->irreversible = 1;
 
        /* use array based MCT */
@@ -917,12 +919,12 @@ void OPJ_CALLCONV opj_destroy_cstr_index(opj_codestream_index_t **p_cstr_index)
        }
 }
 
-opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream_v3 (const char *fname, OPJ_BOOL p_is_read_stream)
+opj_stream_t* OPJ_CALLCONV opj_stream_create_default_file_stream (const char *fname, OPJ_BOOL p_is_read_stream)
 {
-    return opj_stream_create_file_stream_v3(fname, OPJ_J2K_STREAM_CHUNK_SIZE, p_is_read_stream);
+    return opj_stream_create_file_stream(fname, OPJ_J2K_STREAM_CHUNK_SIZE, p_is_read_stream);
 }
 
-opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream_v3 (
+opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream (
         const char *fname, 
                OPJ_SIZE_T p_size, 
         OPJ_BOOL p_is_read_stream)
@@ -949,7 +951,7 @@ opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream_v3 (
         return NULL;
     }
 
-    opj_stream_set_user_data_v3(l_stream, p_file, (opj_stream_free_user_data_fn) fclose);
+    opj_stream_set_user_data(l_stream, p_file, (opj_stream_free_user_data_fn) fclose);
     opj_stream_set_user_data_length(l_stream, opj_get_data_length_from_file(p_file));
     opj_stream_set_read_function(l_stream, (opj_stream_read_fn) opj_read_from_file);
     opj_stream_set_write_function(l_stream, (opj_stream_write_fn) opj_write_from_file);