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) 2002-2014, Universite catholique de Louvain (UCL), Belgium | 7 * Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium |
8 * Copyright (c) 2002-2014, Professor Benoit Macq | 8 * Copyright (c) 2002-2014, Professor Benoit Macq |
9 * Copyright (c) 2001-2003, David Janssens | 9 * Copyright (c) 2001-2003, David Janssens |
10 * Copyright (c) 2002-2003, Yannick Verschueren | 10 * Copyright (c) 2002-2003, Yannick Verschueren |
(...skipping 4118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4129 p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_numb
er].tileno = p_j2k->m_current_tile_number; | 4129 p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_numb
er].tileno = p_j2k->m_current_tile_number; |
4130 p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_numb
er].current_tpsno = l_current_part; | 4130 p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_numb
er].current_tpsno = l_current_part; |
4131 | 4131 |
4132 if (l_num_parts != 0){ | 4132 if (l_num_parts != 0){ |
4133 p_j2k->cstr_index->tile_index[p_j2k->m_current_t
ile_number].nb_tps = l_num_parts; | 4133 p_j2k->cstr_index->tile_index[p_j2k->m_current_t
ile_number].nb_tps = l_num_parts; |
4134 p_j2k->cstr_index->tile_index[p_j2k->m_current_t
ile_number].current_nb_tps = l_num_parts; | 4134 p_j2k->cstr_index->tile_index[p_j2k->m_current_t
ile_number].current_nb_tps = l_num_parts; |
4135 | 4135 |
4136 if (!p_j2k->cstr_index->tile_index[p_j2k->m_curr
ent_tile_number].tp_index) { | 4136 if (!p_j2k->cstr_index->tile_index[p_j2k->m_curr
ent_tile_number].tp_index) { |
4137 p_j2k->cstr_index->tile_index[p_j2k->m_c
urrent_tile_number].tp_index = | 4137 p_j2k->cstr_index->tile_index[p_j2k->m_c
urrent_tile_number].tp_index = |
4138 (opj_tp_index_t*)opj_calloc(l_nu
m_parts, sizeof(opj_tp_index_t)); | 4138 (opj_tp_index_t*)opj_calloc(l_nu
m_parts, sizeof(opj_tp_index_t)); |
| 4139 if (!p_j2k->cstr_index->tile_index[p_j2k
->m_current_tile_number].tp_index) { |
| 4140 opj_event_msg(p_manager, EVT_ERR
OR, "Not enough memory to read SOT marker. Tile index allocation failed\n"); |
| 4141 return OPJ_FALSE; |
| 4142
} |
4139 } | 4143 } |
4140 else { | 4144 else { |
4141 opj_tp_index_t *new_tp_index = (opj_tp_i
ndex_t *) opj_realloc( | 4145 opj_tp_index_t *new_tp_index = (opj_tp_i
ndex_t *) opj_realloc( |
4142 p_j2k->cstr_index->tile_
index[p_j2k->m_current_tile_number].tp_index, l_num_parts* sizeof(opj_tp_index_t
)); | 4146 p_j2k->cstr_index->tile_
index[p_j2k->m_current_tile_number].tp_index, l_num_parts* sizeof(opj_tp_index_t
)); |
4143 if (! new_tp_index) { | 4147 if (! new_tp_index) { |
4144 opj_free(p_j2k->cstr_index->tile
_index[p_j2k->m_current_tile_number].tp_index); | 4148 opj_free(p_j2k->cstr_index->tile
_index[p_j2k->m_current_tile_number].tp_index); |
4145 p_j2k->cstr_index->tile_index[p_
j2k->m_current_tile_number].tp_index = NULL; | 4149 p_j2k->cstr_index->tile_index[p_
j2k->m_current_tile_number].tp_index = NULL; |
4146 opj_event_msg(p_manager, EVT_ERR
OR, "Not enough memory to read PPT marker\n"); | 4150 opj_event_msg(p_manager, EVT_ERR
OR, "Not enough memory to read SOT marker. Tile index allocation failed\n"); |
4147 return OPJ_FALSE; | 4151 return OPJ_FALSE; |
4148 } | 4152 } |
4149 p_j2k->cstr_index->tile_index[p_j2k->m_c
urrent_tile_number].tp_index = new_tp_index; | 4153 p_j2k->cstr_index->tile_index[p_j2k->m_c
urrent_tile_number].tp_index = new_tp_index; |
4150 } | 4154 } |
4151 } | 4155 } |
4152 else{ | 4156 else{ |
4153 /*if (!p_j2k->cstr_index->tile_index[p_j2k->m_cu
rrent_tile_number].tp_index)*/ { | 4157 /*if (!p_j2k->cstr_index->tile_index[p_j2k->m_cu
rrent_tile_number].tp_index)*/ { |
4154 | 4158 |
4155 if (!p_j2k->cstr_index->tile_index[p_j2k
->m_current_tile_number].tp_index) { | 4159 if (!p_j2k->cstr_index->tile_index[p_j2k
->m_current_tile_number].tp_index) { |
4156 p_j2k->cstr_index->tile_index[p_
j2k->m_current_tile_number].current_nb_tps = 10; | 4160 p_j2k->cstr_index->tile_index[p_
j2k->m_current_tile_number].current_nb_tps = 10; |
4157 p_j2k->cstr_index->tile_index[p_
j2k->m_current_tile_number].tp_index = | 4161 p_j2k->cstr_index->tile_index[p_
j2k->m_current_tile_number].tp_index = |
4158 (opj_tp_index_t*)opj_cal
loc( p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps, | 4162 (opj_tp_index_t*)opj_cal
loc( p_j2k->cstr_index->tile_index[p_j2k->m_current_tile_number].current_nb_tps, |
4159 sizeof(o
pj_tp_index_t)); | 4163 sizeof(o
pj_tp_index_t)); |
| 4164
if (!p_j2k->cstr_index->tile_index[p_j2k->m_curr
ent_tile_number].tp_index) { |
| 4165 p_j2k->cstr_index->tile_
index[p_j2k->m_current_tile_number].current_nb_tps = 0; |
| 4166 opj_event_msg(p_manager,
EVT_ERROR, "Not enough memory to read SOT marker. Tile index allocation failed\
n"); |
| 4167 return OPJ_FALSE; |
| 4168
} |
4160 } | 4169 } |
4161 | 4170 |
4162 if ( l_current_part >= p_j2k->cstr_index
->tile_index[p_j2k->m_current_tile_number].current_nb_tps ){ | 4171 if ( l_current_part >= p_j2k->cstr_index
->tile_index[p_j2k->m_current_tile_number].current_nb_tps ){ |
4163 opj_tp_index_t *new_tp_index; | 4172 opj_tp_index_t *new_tp_index; |
4164 p_j2k->cstr_index->tile_index[p_
j2k->m_current_tile_number].current_nb_tps = l_current_part + 1; | 4173 p_j2k->cstr_index->tile_index[p_
j2k->m_current_tile_number].current_nb_tps = l_current_part + 1; |
4165 new_tp_index = (opj_tp_index_t *
) opj_realloc( | 4174 new_tp_index = (opj_tp_index_t *
) opj_realloc( |
4166 p_j2k->cstr_inde
x->tile_index[p_j2k->m_current_tile_number].tp_index, | 4175 p_j2k->cstr_inde
x->tile_index[p_j2k->m_current_tile_number].tp_index, |
4167 p_j2k->cstr_inde
x->tile_index[p_j2k->m_current_tile_number].current_nb_tps * sizeof(opj_tp_index
_t)); | 4176 p_j2k->cstr_inde
x->tile_index[p_j2k->m_current_tile_number].current_nb_tps * sizeof(opj_tp_index
_t)); |
4168 if (! new_tp_index) { | 4177 if (! new_tp_index) { |
4169 opj_free(p_j2k->cstr_ind
ex->tile_index[p_j2k->m_current_tile_number].tp_index); | 4178 opj_free(p_j2k->cstr_ind
ex->tile_index[p_j2k->m_current_tile_number].tp_index); |
4170 p_j2k->cstr_index->tile_
index[p_j2k->m_current_tile_number].tp_index = NULL; | 4179 p_j2k->cstr_index->tile_
index[p_j2k->m_current_tile_number].tp_index = NULL; |
4171 p_j2k->cstr_index->tile_
index[p_j2k->m_current_tile_number].current_nb_tps = 0; | 4180 p_j2k->cstr_index->tile_
index[p_j2k->m_current_tile_number].current_nb_tps = 0; |
4172 opj_event_msg(p_manager,
EVT_ERROR, "Not enough memory to read PPT marker\n"); | 4181 opj_event_msg(p_manager,
EVT_ERROR, "Not enough memory to read SOT marker. Tile index allocation failed\
n"); |
4173 return OPJ_FALSE; | 4182 return OPJ_FALSE; |
4174 } | 4183 } |
4175 p_j2k->cstr_index->tile_index[p_
j2k->m_current_tile_number].tp_index = new_tp_index; | 4184 p_j2k->cstr_index->tile_index[p_
j2k->m_current_tile_number].tp_index = new_tp_index; |
4176 } | 4185 } |
4177 } | 4186 } |
4178 | 4187 |
4179 } | 4188 } |
4180 | 4189 |
4181 } | 4190 } |
4182 | 4191 |
(...skipping 1963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6146 return OPJ_FALSE; | 6155 return OPJ_FALSE; |
6147 } | 6156 } |
6148 break; | 6157 break; |
6149 default : | 6158 default : |
6150 break; | 6159 break; |
6151 } | 6160 } |
6152 | 6161 |
6153 return OPJ_TRUE; | 6162 return OPJ_TRUE; |
6154 } | 6163 } |
6155 | 6164 |
6156 void opj_j2k_setup_encoder( opj_j2k_t *p_j2k, | 6165 OPJ_BOOL opj_j2k_setup_encoder( opj_j2k_t *p_j2k, |
6157 opj_cparameters_t *parameter
s, | 6166 opj_cparameters_t *parameter
s, |
6158 opj_image_t *image, | 6167 opj_image_t *image, |
6159 opj_event_mgr_t * p_manager) | 6168 opj_event_mgr_t * p_manager) |
6160 { | 6169 { |
6161 OPJ_UINT32 i, j, tileno, numpocs_tile; | 6170 OPJ_UINT32 i, j, tileno, numpocs_tile; |
6162 opj_cp_t *cp = 00; | 6171 opj_cp_t *cp = 00; |
6163 | 6172 |
6164 if(!p_j2k || !parameters || ! image) { | 6173 if(!p_j2k || !parameters || ! image) { |
6165 return; | 6174 return OPJ_FALSE; |
6166 } | 6175 } |
6167 | 6176 |
6168 /* keep a link to cp so that we can destroy it later in j2k_destroy_comp
ress */ | 6177 /* keep a link to cp so that we can destroy it later in j2k_destroy_comp
ress */ |
6169 cp = &(p_j2k->m_cp); | 6178 cp = &(p_j2k->m_cp); |
6170 | 6179 |
6171 /* set default values for cp */ | 6180 /* set default values for cp */ |
6172 cp->tw = 1; | 6181 cp->tw = 1; |
6173 cp->th = 1; | 6182 cp->th = 1; |
6174 | 6183 |
6175 /* set cinema parameters if required */ | 6184 /* set cinema parameters if required */ |
(...skipping 11 matching lines...) Expand all Loading... |
6187 cp->m_specific_param.m_enc.m_max_comp_size = (OPJ_UINT32)parameters->max
_comp_size; | 6196 cp->m_specific_param.m_enc.m_max_comp_size = (OPJ_UINT32)parameters->max
_comp_size; |
6188 cp->rsiz = parameters->cp_rsiz; | 6197 cp->rsiz = parameters->cp_rsiz; |
6189 cp->m_specific_param.m_enc.m_disto_alloc = (OPJ_UINT32)parameters->cp_di
sto_alloc & 1u; | 6198 cp->m_specific_param.m_enc.m_disto_alloc = (OPJ_UINT32)parameters->cp_di
sto_alloc & 1u; |
6190 cp->m_specific_param.m_enc.m_fixed_alloc = (OPJ_UINT32)parameters->cp_fi
xed_alloc & 1u; | 6199 cp->m_specific_param.m_enc.m_fixed_alloc = (OPJ_UINT32)parameters->cp_fi
xed_alloc & 1u; |
6191 cp->m_specific_param.m_enc.m_fixed_quality = (OPJ_UINT32)parameters->cp_
fixed_quality & 1u; | 6200 cp->m_specific_param.m_enc.m_fixed_quality = (OPJ_UINT32)parameters->cp_
fixed_quality & 1u; |
6192 | 6201 |
6193 /* mod fixed_quality */ | 6202 /* mod fixed_quality */ |
6194 if (parameters->cp_fixed_alloc && parameters->cp_matrice) { | 6203 if (parameters->cp_fixed_alloc && parameters->cp_matrice) { |
6195 size_t array_size = (size_t)parameters->tcp_numlayers * (size_t)
parameters->numresolution * 3 * sizeof(OPJ_INT32); | 6204 size_t array_size = (size_t)parameters->tcp_numlayers * (size_t)
parameters->numresolution * 3 * sizeof(OPJ_INT32); |
6196 cp->m_specific_param.m_enc.m_matrice = (OPJ_INT32 *) opj_malloc(
array_size); | 6205 cp->m_specific_param.m_enc.m_matrice = (OPJ_INT32 *) opj_malloc(
array_size); |
| 6206 if (!cp->m_speci
fic_param.m_enc.m_matrice) { |
| 6207 opj_even
t_msg(p_manager, EVT_ERROR, "Not enough memory to allocate copy of user encoding
parameters matrix \n"); |
| 6208 return O
PJ_FALSE; |
| 6209 } |
6197 memcpy(cp->m_specific_param.m_enc.m_matrice, parameters->cp_matr
ice, array_size); | 6210 memcpy(cp->m_specific_param.m_enc.m_matrice, parameters->cp_matr
ice, array_size); |
6198 } | 6211 } |
6199 | 6212 |
6200 /* tiles */ | 6213 /* tiles */ |
6201 cp->tdx = (OPJ_UINT32)parameters->cp_tdx; | 6214 cp->tdx = (OPJ_UINT32)parameters->cp_tdx; |
6202 cp->tdy = (OPJ_UINT32)parameters->cp_tdy; | 6215 cp->tdy = (OPJ_UINT32)parameters->cp_tdy; |
6203 | 6216 |
6204 /* tile offset */ | 6217 /* tile offset */ |
6205 cp->tx0 = (OPJ_UINT32)parameters->cp_tx0; | 6218 cp->tx0 = (OPJ_UINT32)parameters->cp_tx0; |
6206 cp->ty0 = (OPJ_UINT32)parameters->cp_ty0; | 6219 cp->ty0 = (OPJ_UINT32)parameters->cp_ty0; |
6207 | 6220 |
6208 /* comment string */ | 6221 /* comment string */ |
6209 if(parameters->cp_comment) { | 6222 if(parameters->cp_comment) { |
6210 cp->comment = (char*)opj_malloc(strlen(parameters->cp_comment) +
1); | 6223 cp->comment = (char*)opj_malloc(strlen(parameters->cp_comment) +
1U); |
6211 if(cp->comment) { | 6224 » » » » » » » » if(!cp->comment)
{ |
6212 strcpy(cp->comment, parameters->cp_comment); | 6225 » » » » » » » » opj_even
t_msg(p_manager, EVT_ERROR, "Not enough memory to allocate copy of comment strin
g\n"); |
6213 } | 6226 » » » » » » » » return O
PJ_FALSE; |
6214 } | 6227 » » » » » » » » } |
| 6228 strcpy(cp->comment, parameters->cp_comment); |
| 6229 } else { |
| 6230 /* Create default comment for codestream */ |
| 6231 const char comment[] = "Created by OpenJPEG version "; |
| 6232 const size_t clen = strlen(comment); |
| 6233 const char *version = opj_version(); |
| 6234 |
| 6235 /* UniPG>> */ |
| 6236 #ifdef USE_JPWL |
| 6237 cp->comment = (char*)opj_malloc(clen+strlen(version)+11); |
| 6238 » » » » » » » » if(!cp->comment)
{ |
| 6239 » » » » » » » » opj_even
t_msg(p_manager, EVT_ERROR, "Not enough memory to allocate comment string\n"); |
| 6240 » » » » » » » » return O
PJ_FALSE; |
| 6241 » » » » » » » » } |
| 6242 sprintf(cp->comment,"%s%s with JPWL", comment, version); |
| 6243 #else |
| 6244 cp->comment = (char*)opj_malloc(clen+strlen(version)+1); |
| 6245 » » » » » » » » if(!cp->comment)
{ |
| 6246 » » » » » » » » opj_even
t_msg(p_manager, EVT_ERROR, "Not enough memory to allocate comment string\n"); |
| 6247 » » » » » » » » return O
PJ_FALSE; |
| 6248 » » » » » » » » } |
| 6249 sprintf(cp->comment,"%s%s", comment, version); |
| 6250 #endif |
| 6251 /* <<UniPG */ |
| 6252 » » » » } |
6215 | 6253 |
6216 /* | 6254 /* |
6217 calculate other encoding parameters | 6255 calculate other encoding parameters |
6218 */ | 6256 */ |
6219 | 6257 |
6220 if (parameters->tile_size_on) { | 6258 if (parameters->tile_size_on) { |
6221 cp->tw = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(image->x1 - cp-
>tx0), (OPJ_INT32)cp->tdx); | 6259 cp->tw = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(image->x1 - cp-
>tx0), (OPJ_INT32)cp->tdx); |
6222 cp->th = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(image->y1 - cp-
>ty0), (OPJ_INT32)cp->tdy); | 6260 cp->th = (OPJ_UINT32)opj_int_ceildiv((OPJ_INT32)(image->y1 - cp-
>ty0), (OPJ_INT32)cp->tdy); |
6223 } else { | 6261 } else { |
6224 cp->tdx = image->x1 - cp->tx0; | 6262 cp->tdx = image->x1 - cp->tx0; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6282 cp->red_on = OPJ_FALSE; | 6320 cp->red_on = OPJ_FALSE; |
6283 | 6321 |
6284 } else { | 6322 } else { |
6285 cp->epc_on = OPJ_FALSE; | 6323 cp->epc_on = OPJ_FALSE; |
6286 } | 6324 } |
6287 #endif /* USE_JPWL */ | 6325 #endif /* USE_JPWL */ |
6288 | 6326 |
6289 /* initialize the mutiple tiles */ | 6327 /* initialize the mutiple tiles */ |
6290 /* ---------------------------- */ | 6328 /* ---------------------------- */ |
6291 cp->tcps = (opj_tcp_t*) opj_calloc(cp->tw * cp->th, sizeof(opj_tcp_t)); | 6329 cp->tcps = (opj_tcp_t*) opj_calloc(cp->tw * cp->th, sizeof(opj_tcp_t)); |
| 6330 if (!cp->tcps) { |
| 6331 opj_event_msg(p_manager, EVT_ERROR, "Not enough memory to alloca
te tile coding parameters\n"); |
| 6332 return OPJ_FALSE; |
| 6333 } |
6292 if (parameters->numpocs) { | 6334 if (parameters->numpocs) { |
6293 /* initialisation of POC */ | 6335 /* initialisation of POC */ |
6294 opj_j2k_check_poc_val(parameters->POC,parameters->numpocs, (OPJ_
UINT32)parameters->numresolution, image->numcomps, (OPJ_UINT32)parameters->tcp_n
umlayers, p_manager); | 6336 opj_j2k_check_poc_val(parameters->POC,parameters->numpocs, (OPJ_
UINT32)parameters->numresolution, image->numcomps, (OPJ_UINT32)parameters->tcp_n
umlayers, p_manager); |
6295 /* TODO MSD use the return value*/ | 6337 /* TODO MSD use the return value*/ |
6296 } | 6338 } |
6297 | 6339 |
6298 for (tileno = 0; tileno < cp->tw * cp->th; tileno++) { | 6340 for (tileno = 0; tileno < cp->tw * cp->th; tileno++) { |
6299 opj_tcp_t *tcp = &cp->tcps[tileno]; | 6341 opj_tcp_t *tcp = &cp->tcps[tileno]; |
6300 tcp->numlayers = (OPJ_UINT32)parameters->tcp_numlayers; | 6342 tcp->numlayers = (OPJ_UINT32)parameters->tcp_numlayers; |
6301 | 6343 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6339 numpocs_tile++; | 6381 numpocs_tile++; |
6340 } | 6382 } |
6341 } | 6383 } |
6342 | 6384 |
6343 tcp->numpocs = numpocs_tile -1 ; | 6385 tcp->numpocs = numpocs_tile -1 ; |
6344 }else{ | 6386 }else{ |
6345 tcp->numpocs = 0; | 6387 tcp->numpocs = 0; |
6346 } | 6388 } |
6347 | 6389 |
6348 tcp->tccps = (opj_tccp_t*) opj_calloc(image->numcomps, sizeof(op
j_tccp_t)); | 6390 tcp->tccps = (opj_tccp_t*) opj_calloc(image->numcomps, sizeof(op
j_tccp_t)); |
6349 | 6391 if (!tcp->tccps) { |
| 6392 opj_event_msg(p_manager, EVT_ERROR, "Not enough memory t
o allocate tile component coding parameters\n"); |
| 6393 return OPJ_FALSE; |
| 6394 } |
6350 if (parameters->mct_data) { | 6395 if (parameters->mct_data) { |
6351 | 6396 |
6352 OPJ_UINT32 lMctSize = image->numcomps * image->numcomps * (O
PJ_UINT32)sizeof(OPJ_FLOAT32); | 6397 OPJ_UINT32 lMctSize = image->numcomps * image->numcomps * (O
PJ_UINT32)sizeof(OPJ_FLOAT32); |
6353 OPJ_FLOAT32 * lTmpBuf = (OPJ_FLOAT32*)opj_malloc(lMctSize); | 6398 OPJ_FLOAT32 * lTmpBuf = (OPJ_FLOAT32*)opj_malloc(lMctSize); |
6354 OPJ_INT32 * l_dc_shift = (OPJ_INT32 *) ((OPJ_BYTE *) paramet
ers->mct_data + lMctSize); | 6399 OPJ_INT32 * l_dc_shift = (OPJ_INT32 *) ((OPJ_BYTE *) paramet
ers->mct_data + lMctSize); |
6355 | 6400 |
| 6401
if (!lTmpBuf) { |
| 6402 opj_event_msg(p_manager, EVT_ERROR, "Not enough memo
ry to allocate temp buffer\n"); |
| 6403 return OPJ_FALSE; |
| 6404 } |
| 6405 |
6356 tcp->mct = 2; | 6406 tcp->mct = 2; |
6357 tcp->m_mct_coding_matrix = (OPJ_FLOAT32*)opj_malloc(lMctSize
); | 6407 tcp->m_mct_coding_matrix = (OPJ_FLOAT32*)opj_malloc(lMctSize
); |
| 6408
if (! tcp->m_mct_coding_matrix) { |
| 6409 opj_free(lTmpBuf); |
| 6410
lTmpBuf = NULL; |
| 6411 opj_event_msg(p_manager, EVT_ERROR, "Not enough memo
ry to allocate encoder MCT coding matrix \n"); |
| 6412 return OPJ_FALSE; |
| 6413 } |
6358 memcpy(tcp->m_mct_coding_matrix,parameters->mct_data,lMctSiz
e); | 6414 memcpy(tcp->m_mct_coding_matrix,parameters->mct_data,lMctSiz
e); |
6359 memcpy(lTmpBuf,parameters->mct_data,lMctSize); | 6415 memcpy(lTmpBuf,parameters->mct_data,lMctSize); |
6360 | 6416 |
6361 tcp->m_mct_decoding_matrix = (OPJ_FLOAT32*)opj_malloc(lMctSi
ze); | 6417 tcp->m_mct_decoding_matrix = (OPJ_FLOAT32*)opj_malloc(lMctSi
ze); |
6362 assert(opj_matrix_inversion_f(lTmpBuf,(tcp->m_mct_decoding_m
atrix),image->numcomps)); | 6418 » » » » » » » » » »
if (! tcp->m_mct_decoding_matrix) { |
| 6419 » » » » » » » » » »
» » » » opj_free(lTmpBuf); |
| 6420 » » » » » » » » » »
» » » » lTmpBuf = NULL; |
| 6421 opj_event_msg(p_manager, EVT_ERROR, "Not enough memo
ry to allocate encoder MCT decoding matrix \n"); |
| 6422 return OPJ_FALSE; |
| 6423 } |
| 6424 if(opj_matrix_inversion_f(lTmpBuf,(tcp->m_mct_decoding_matri
x),image->numcomps) == OPJ_FALSE) { |
| 6425 opj_free(lTmpBuf); |
| 6426 » » » » » » » » » »
» » » » lTmpBuf = NULL; |
| 6427 opj_event_msg(p_manager, EVT_ERROR, "Failed to inver
se encoder MCT decoding matrix \n"); |
| 6428 return OPJ_FALSE; |
| 6429 » » » » » » » » » »
} |
6363 | 6430 |
6364 tcp->mct_norms = (OPJ_FLOAT64*) | 6431 tcp->mct_norms = (OPJ_FLOAT64*) |
6365 opj_malloc(image->numcomps * sizeof(OPJ_FLOA
T64)); | 6432 opj_malloc(image->numcomps * sizeof(OPJ_FLOA
T64)); |
6366 | 6433 » » » » » » » » » »
if (! tcp->mct_norms) { |
| 6434 opj_free(lTmpBuf); |
| 6435 » » » » » » » » » »
» » » » lTmpBuf = NULL; |
| 6436 opj_event_msg(p_manager, EVT_ERROR, "Not enough memo
ry to allocate encoder MCT norms \n"); |
| 6437 return OPJ_FALSE; |
| 6438 } |
6367 opj_calculate_norms(tcp->mct_norms,image->numcomps,tcp->m_mc
t_decoding_matrix); | 6439 opj_calculate_norms(tcp->mct_norms,image->numcomps,tcp->m_mc
t_decoding_matrix); |
6368 opj_free(lTmpBuf); | 6440 opj_free(lTmpBuf); |
6369 | 6441 |
6370 for (i = 0; i < image->numcomps; i++) { | 6442 for (i = 0; i < image->numcomps; i++) { |
6371 opj_tccp_t *tccp = &tcp->tccps[i]; | 6443 opj_tccp_t *tccp = &tcp->tccps[i]; |
6372 tccp->m_dc_level_shift = l_dc_shift[i]; | 6444 tccp->m_dc_level_shift = l_dc_shift[i]; |
6373 } | 6445 } |
6374 | 6446 |
6375 opj_j2k_setup_mct_encoding(tcp,image);
| 6447 if (opj_j2k_setup_mct_encoding(tcp,image) == OPJ_FALSE) { |
| 6448 /* free will be handled by opj_j2k_destroy */ |
| 6449 » » » » » » » » » »
» » opj_event_msg(p_manager, EVT_ERROR, "Failed to setup j2k mct enc
oding\n"); |
| 6450 return OPJ_FALSE; |
| 6451 } |
6376 } | 6452 } |
6377 else { | 6453 else { |
6378 for (i = 0; i < image->numcomps; i++) { | 6454 for (i = 0; i < image->numcomps; i++) { |
6379 opj_tccp_t *tccp = &tcp->tccps[i]; | 6455 opj_tccp_t *tccp = &tcp->tccps[i]; |
6380 opj_image_comp_t * l_comp = &(image->comps[i]); | 6456 opj_image_comp_t * l_comp = &(image->comps[i]); |
6381 | 6457 |
6382 if (! l_comp->sgnd) { | 6458 if (! l_comp->sgnd) { |
6383 tccp->m_dc_level_shift = 1 << (l_comp->p
rec - 1); | 6459 tccp->m_dc_level_shift = 1 << (l_comp->p
rec - 1); |
6384 } | 6460 } |
6385 } | 6461 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6454 } | 6530 } |
6455 | 6531 |
6456 opj_dwt_calc_explicit_stepsizes(tccp, image->comps[i].pr
ec); | 6532 opj_dwt_calc_explicit_stepsizes(tccp, image->comps[i].pr
ec); |
6457 } | 6533 } |
6458 } | 6534 } |
6459 | 6535 |
6460 if (parameters->mct_data) { | 6536 if (parameters->mct_data) { |
6461 opj_free(parameters->mct_data); | 6537 opj_free(parameters->mct_data); |
6462 parameters->mct_data = 00; | 6538 parameters->mct_data = 00; |
6463 } | 6539 } |
| 6540 return OPJ_TRUE; |
6464 } | 6541 } |
6465 | 6542 |
6466 static OPJ_BOOL opj_j2k_add_mhmarker(opj_codestream_index_t *cstr_index, OPJ_UIN
T32 type, OPJ_OFF_T pos, OPJ_UINT32 len) | 6543 static OPJ_BOOL opj_j2k_add_mhmarker(opj_codestream_index_t *cstr_index, OPJ_UIN
T32 type, OPJ_OFF_T pos, OPJ_UINT32 len) |
6467 { | 6544 { |
6468 assert(cstr_index != 00); | 6545 assert(cstr_index != 00); |
6469 | 6546 |
6470 /* expand the list? */ | 6547 /* expand the list? */ |
6471 if ((cstr_index->marknum + 1) > cstr_index->maxmarknum) { | 6548 if ((cstr_index->marknum + 1) > cstr_index->maxmarknum) { |
6472 opj_marker_info_t *new_marker; | 6549 opj_marker_info_t *new_marker; |
6473 cstr_index->maxmarknum = (OPJ_UINT32)(100 + (OPJ_FLOAT32) cstr_i
ndex->maxmarknum); | 6550 cstr_index->maxmarknum = (OPJ_UINT32)(100 + (OPJ_FLOAT32) cstr_i
ndex->maxmarknum); |
(...skipping 1683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8157 } | 8234 } |
8158 | 8235 |
8159 l_j2k->m_specific_param.m_decoder.m_header_data_size = OPJ_J2K_DEFAULT_H
EADER_SIZE; | 8236 l_j2k->m_specific_param.m_decoder.m_header_data_size = OPJ_J2K_DEFAULT_H
EADER_SIZE; |
8160 | 8237 |
8161 l_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec = -1 ; | 8238 l_j2k->m_specific_param.m_decoder.m_tile_ind_to_dec = -1 ; |
8162 | 8239 |
8163 l_j2k->m_specific_param.m_decoder.m_last_sot_read_pos = 0 ; | 8240 l_j2k->m_specific_param.m_decoder.m_last_sot_read_pos = 0 ; |
8164 | 8241 |
8165 /* codestream index creation */ | 8242 /* codestream index creation */ |
8166 l_j2k->cstr_index = opj_j2k_create_cstr_index(); | 8243 l_j2k->cstr_index = opj_j2k_create_cstr_index(); |
8167 | |
8168 /*(opj_codestream_index_t*) opj_malloc(sizeof(opj_codest
ream_index_t)); | |
8169 if (!l_j2k->cstr_index){ | 8244 if (!l_j2k->cstr_index){ |
8170 opj_j2k_destroy(l_j2k); | 8245 opj_j2k_destroy(l_j2k); |
8171 return NULL; | 8246 return 00; |
8172 } | 8247 } |
8173 | 8248 |
8174 l_j2k->cstr_index->marker = (opj_marker_info_t*) opj_malloc(100 * sizeof
(opj_marker_info_t)); | |
8175 */ | |
8176 | |
8177 /* validation list creation */ | 8249 /* validation list creation */ |
8178 l_j2k->m_validation_list = opj_procedure_list_create(); | 8250 l_j2k->m_validation_list = opj_procedure_list_create(); |
8179 if (! l_j2k->m_validation_list) { | 8251 if (! l_j2k->m_validation_list) { |
8180 opj_j2k_destroy(l_j2k); | 8252 opj_j2k_destroy(l_j2k); |
8181 return 00; | 8253 return 00; |
8182 } | 8254 } |
8183 | 8255 |
8184 /* execution list creation */ | 8256 /* execution list creation */ |
8185 l_j2k->m_procedure_list = opj_procedure_list_create(); | 8257 l_j2k->m_procedure_list = opj_procedure_list_create(); |
8186 if (! l_j2k->m_procedure_list) { | 8258 if (! l_j2k->m_procedure_list) { |
(...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9581 opj_stream_private_t
*p_stream, | 9653 opj_stream_private_t
*p_stream, |
9582 opj_image_t * p_imag
e, | 9654 opj_image_t * p_imag
e, |
9583 opj_event_mgr_t * p_
manager) | 9655 opj_event_mgr_t * p_
manager) |
9584 { | 9656 { |
9585 /* preconditions */ | 9657 /* preconditions */ |
9586 assert(p_j2k != 00); | 9658 assert(p_j2k != 00); |
9587 assert(p_stream != 00); | 9659 assert(p_stream != 00); |
9588 assert(p_manager != 00); | 9660 assert(p_manager != 00); |
9589 | 9661 |
9590 p_j2k->m_private_image = opj_image_create0(); | 9662 p_j2k->m_private_image = opj_image_create0(); |
| 9663 if (! p_j2k->m_private_image) { |
| 9664 opj_event_msg(p_manager, EVT_ERROR, "Failed to allocate image he
ader." ); |
| 9665 return OPJ_FALSE; |
| 9666 } |
9591 opj_copy_image_header(p_image, p_j2k->m_private_image); | 9667 opj_copy_image_header(p_image, p_j2k->m_private_image); |
9592 | 9668 |
9593 /* TODO_MSD: Find a better way */ | 9669 /* TODO_MSD: Find a better way */ |
9594 if (p_image->comps) { | 9670 if (p_image->comps) { |
9595 OPJ_UINT32 it_comp; | 9671 OPJ_UINT32 it_comp; |
9596 for (it_comp = 0 ; it_comp < p_image->numcomps; it_comp++) { | 9672 for (it_comp = 0 ; it_comp < p_image->numcomps; it_comp++) { |
9597 if (p_image->comps[it_comp].data) { | 9673 if (p_image->comps[it_comp].data) { |
9598 p_j2k->m_private_image->comps[it_comp].data =p_i
mage->comps[it_comp].data; | 9674 p_j2k->m_private_image->comps[it_comp].data =p_i
mage->comps[it_comp].data; |
9599 p_image->comps[it_comp].data = NULL; | 9675 p_image->comps[it_comp].data = NULL; |
9600 | 9676 |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10246 } | 10322 } |
10247 else { | 10323 else { |
10248 if (! opj_j2k_post_write_tile(p_j2k,p_data,p_data_size,p_stream,
p_manager)) { | 10324 if (! opj_j2k_post_write_tile(p_j2k,p_data,p_data_size,p_stream,
p_manager)) { |
10249 opj_event_msg(p_manager, EVT_ERROR, "Error while opj_j2k
_post_write_tile with tile index = %d\n", p_tile_index); | 10325 opj_event_msg(p_manager, EVT_ERROR, "Error while opj_j2k
_post_write_tile with tile index = %d\n", p_tile_index); |
10250 return OPJ_FALSE; | 10326 return OPJ_FALSE; |
10251 } | 10327 } |
10252 } | 10328 } |
10253 | 10329 |
10254 return OPJ_TRUE; | 10330 return OPJ_TRUE; |
10255 } | 10331 } |
OLD | NEW |