Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/j2k.c

Issue 1232063010: Merge to M44: Upgrade openjpeg to r3002 (Closed) Base URL: https://pdfium.googlesource.com/pdfium@2403
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/j2k.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2413 matching lines...) Expand 10 before | Expand all | Expand 10 after
2424 assert(p_j2k != 00); 2424 assert(p_j2k != 00);
2425 assert(p_manager != 00); 2425 assert(p_manager != 00);
2426 2426
2427 l_image = p_j2k->m_private_image; 2427 l_image = p_j2k->m_private_image;
2428 l_cp = &(p_j2k->m_cp); 2428 l_cp = &(p_j2k->m_cp);
2429 2429
2430 /* If we are in the first tile-part header of the current tile */ 2430 /* If we are in the first tile-part header of the current tile */
2431 l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH) ? 2431 l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_STATE_TPH) ?
2432 &l_cp->tcps[p_j2k->m_current_tile_number] : 2432 &l_cp->tcps[p_j2k->m_current_tile_number] :
2433 p_j2k->m_specific_param.m_decoder.m_default_tcp; 2433 p_j2k->m_specific_param.m_decoder.m_default_tcp;
2434 2434 »
2435 /* Only one COD per tile */
2436 if (l_tcp->cod) {
2437 opj_event_msg(p_manager, EVT_ERROR, "COD marker already read. No more than one COD marker per tile.\n");
2438 return OPJ_FALSE;
2439 }
2440 l_tcp->cod = 1;
2441 »
2435 /* Make sure room is sufficient */ 2442 /* Make sure room is sufficient */
2436 if (p_header_size < 5) { 2443 if (p_header_size < 5) {
2437 opj_event_msg(p_manager, EVT_ERROR, "Error reading COD marker\n" ); 2444 opj_event_msg(p_manager, EVT_ERROR, "Error reading COD marker\n" );
2438 return OPJ_FALSE; 2445 return OPJ_FALSE;
2439 } 2446 }
2440 2447
2441 opj_read_bytes(p_header_data,&l_tcp->csty,1); /* Scod */ 2448 opj_read_bytes(p_header_data,&l_tcp->csty,1); /* Scod */
2442 ++p_header_data; 2449 ++p_header_data;
2443 /* Make sure we know how to decode this */ 2450 /* Make sure we know how to decode this */
2444 if ((l_tcp->csty & ~(OPJ_UINT32)(J2K_CP_CSTY_PRT | J2K_CP_CSTY_SOP | J2K _CP_CSTY_EPH)) != 0U) { 2451 if ((l_tcp->csty & ~(OPJ_UINT32)(J2K_CP_CSTY_PRT | J2K_CP_CSTY_SOP | J2K _CP_CSTY_EPH)) != 0U) {
2445 opj_event_msg(p_manager, EVT_ERROR, "Unknown Scod value in COD m arker\n"); 2452 opj_event_msg(p_manager, EVT_ERROR, "Unknown Scod value in COD m arker\n");
2446 return OPJ_FALSE; 2453 return OPJ_FALSE;
2447 } 2454 }
2448 opj_read_bytes(p_header_data,&l_tmp,1); /* SGcod (A) */ 2455 opj_read_bytes(p_header_data,&l_tmp,1); /* SGcod (A) */
2449 ++p_header_data; 2456 ++p_header_data;
2450 l_tcp->prg = (OPJ_PROG_ORDER) l_tmp; 2457 l_tcp->prg = (OPJ_PROG_ORDER) l_tmp;
2451 /* Make sure progression order is valid */ 2458 /* Make sure progression order is valid */
2452 if (l_tcp->prg > OPJ_CPRL ) { 2459 if (l_tcp->prg > OPJ_CPRL ) {
2453 opj_event_msg(p_manager, EVT_ERROR, "Unknown progression order i n COD marker\n"); 2460 opj_event_msg(p_manager, EVT_ERROR, "Unknown progression order i n COD marker\n");
2454 l_tcp->prg = OPJ_PROG_UNKNOWN; 2461 l_tcp->prg = OPJ_PROG_UNKNOWN;
2455 } 2462 }
2456 opj_read_bytes(p_header_data,&l_tcp->numlayers,2); /* SGcod (B) */ 2463 opj_read_bytes(p_header_data,&l_tcp->numlayers,2); /* SGcod (B) */
2457 p_header_data+=2; 2464 p_header_data+=2;
2465
2466 if ((l_tcp->numlayers < 1U) || (l_tcp->numlayers > 65535U)) {
2467 opj_event_msg(p_manager, EVT_ERROR, "Invalid number of layers in COD marker : %d not in range [1-65535]\n", l_tcp->numlayers);
2468 return OPJ_FALSE;
2469 }
2458 2470
2459 /* If user didn't set a number layer to decode take the max specify in t he codestream. */ 2471 /* If user didn't set a number layer to decode take the max specify in t he codestream. */
2460 if (l_cp->m_specific_param.m_dec.m_layer) { 2472 if (l_cp->m_specific_param.m_dec.m_layer) {
2461 l_tcp->num_layers_to_decode = l_cp->m_specific_param.m_dec.m_lay er; 2473 l_tcp->num_layers_to_decode = l_cp->m_specific_param.m_dec.m_lay er;
2462 } 2474 }
2463 else { 2475 else {
2464 l_tcp->num_layers_to_decode = l_tcp->numlayers; 2476 l_tcp->num_layers_to_decode = l_tcp->numlayers;
2465 } 2477 }
2466 2478
2467 opj_read_bytes(p_header_data,&l_tcp->mct,1); /* SGcod (C) */ 2479 opj_read_bytes(p_header_data,&l_tcp->mct,1); /* SGcod (C) */
(...skipping 4875 matching lines...) Expand 10 before | Expand all | Expand 10 after
7343 l_default_tcp = p_j2k->m_specific_param.m_decoder.m_default_tcp; 7355 l_default_tcp = p_j2k->m_specific_param.m_decoder.m_default_tcp;
7344 l_mct_size = l_image->numcomps * l_image->numcomps * (OPJ_UINT32)sizeof( OPJ_FLOAT32); 7356 l_mct_size = l_image->numcomps * l_image->numcomps * (OPJ_UINT32)sizeof( OPJ_FLOAT32);
7345 7357
7346 /* For each tile */ 7358 /* For each tile */
7347 for (i=0; i<l_nb_tiles; ++i) { 7359 for (i=0; i<l_nb_tiles; ++i) {
7348 /* keep the tile-compo coding parameters pointer of the current tile coding parameters*/ 7360 /* keep the tile-compo coding parameters pointer of the current tile coding parameters*/
7349 l_current_tccp = l_tcp->tccps; 7361 l_current_tccp = l_tcp->tccps;
7350 /*Copy default coding parameters into the current tile coding pa rameters*/ 7362 /*Copy default coding parameters into the current tile coding pa rameters*/
7351 memcpy(l_tcp, l_default_tcp, sizeof(opj_tcp_t)); 7363 memcpy(l_tcp, l_default_tcp, sizeof(opj_tcp_t));
7352 /* Initialize some values of the current tile coding parameters* / 7364 /* Initialize some values of the current tile coding parameters* /
7365 l_tcp->cod = 0;
7353 l_tcp->ppt = 0; 7366 l_tcp->ppt = 0;
7354 l_tcp->ppt_data = 00; 7367 l_tcp->ppt_data = 00;
7355 /* Remove memory not owned by this tile in case of early error r eturn. */ 7368 /* Remove memory not owned by this tile in case of early error r eturn. */
7356 l_tcp->m_mct_decoding_matrix = 00; 7369 l_tcp->m_mct_decoding_matrix = 00;
7357 l_tcp->m_nb_max_mct_records = 0; 7370 l_tcp->m_nb_max_mct_records = 0;
7358 l_tcp->m_mct_records = 00; 7371 l_tcp->m_mct_records = 00;
7359 l_tcp->m_nb_max_mcc_records = 0; 7372 l_tcp->m_nb_max_mcc_records = 0;
7360 l_tcp->m_mcc_records = 00; 7373 l_tcp->m_mcc_records = 00;
7361 /* Reconnect the tile-compo coding parameters pointer to the cur rent tile coding parameters*/ 7374 /* Reconnect the tile-compo coding parameters pointer to the cur rent tile coding parameters*/
7362 l_tcp->tccps = l_current_tccp; 7375 l_tcp->tccps = l_current_tccp;
(...skipping 25 matching lines...) Expand all
7388 7401
7389 l_dest_mct_rec->m_data = (OPJ_BYTE*) opj_malloc( l_src_mct_rec->m_data_size); 7402 l_dest_mct_rec->m_data = (OPJ_BYTE*) opj_malloc( l_src_mct_rec->m_data_size);
7390 if(! l_dest_mct_rec->m_data) { 7403 if(! l_dest_mct_rec->m_data) {
7391 return OPJ_FALSE; 7404 return OPJ_FALSE;
7392 } 7405 }
7393 memcpy(l_dest_mct_rec->m_data,l_src_mct_rec->m_d ata,l_src_mct_rec->m_data_size); 7406 memcpy(l_dest_mct_rec->m_data,l_src_mct_rec->m_d ata,l_src_mct_rec->m_data_size);
7394 } 7407 }
7395 7408
7396 ++l_src_mct_rec; 7409 ++l_src_mct_rec;
7397 ++l_dest_mct_rec; 7410 ++l_dest_mct_rec;
7398
7399 /* Update with each pass to free exactly what has been a llocated on early return. */ 7411 /* Update with each pass to free exactly what has been a llocated on early return. */
7400 l_tcp->m_nb_max_mct_records += 1; 7412 l_tcp->m_nb_max_mct_records += 1;
7401 } 7413 }
7402 7414
7403 /* Get the mcc_record of the dflt_tile_cp and copy them into the current tile cp*/ 7415 /* Get the mcc_record of the dflt_tile_cp and copy them into the current tile cp*/
7404 l_mcc_records_size = l_default_tcp->m_nb_max_mcc_records * (OPJ_ UINT32)sizeof(opj_simple_mcc_decorrelation_data_t); 7416 l_mcc_records_size = l_default_tcp->m_nb_max_mcc_records * (OPJ_ UINT32)sizeof(opj_simple_mcc_decorrelation_data_t);
7405 l_tcp->m_mcc_records = (opj_simple_mcc_decorrelation_data_t*) op j_malloc(l_mcc_records_size); 7417 l_tcp->m_mcc_records = (opj_simple_mcc_decorrelation_data_t*) op j_malloc(l_mcc_records_size);
7406 if (! l_tcp->m_mcc_records) { 7418 if (! l_tcp->m_mcc_records) {
7407 return OPJ_FALSE; 7419 return OPJ_FALSE;
7408 } 7420 }
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
8011 OPJ_INT32 * l_dest_ptr; 8023 OPJ_INT32 * l_dest_ptr;
8012 opj_tcd_resolution_t* l_res= 00; 8024 opj_tcd_resolution_t* l_res= 00;
8013 8025
8014 l_tilec = p_tcd->tcd_image->tiles->comps; 8026 l_tilec = p_tcd->tcd_image->tiles->comps;
8015 l_image_src = p_tcd->image; 8027 l_image_src = p_tcd->image;
8016 l_img_comp_src = l_image_src->comps; 8028 l_img_comp_src = l_image_src->comps;
8017 8029
8018 l_img_comp_dest = p_output_image->comps; 8030 l_img_comp_dest = p_output_image->comps;
8019 8031
8020 for (i=0; i<l_image_src->numcomps; i++) { 8032 for (i=0; i<l_image_src->numcomps; i++) {
8033
8021 /* Allocate output component buffer if necessary */ 8034 /* Allocate output component buffer if necessary */
8022 if (!l_img_comp_dest->data) { 8035 if (!l_img_comp_dest->data) {
8023 OPJ_UINT32 width = l_img_comp_dest->w; 8036 OPJ_UINT32 width = l_img_comp_dest->w;
8024 OPJ_UINT32 height = l_img_comp_dest->h; 8037 OPJ_UINT32 height = l_img_comp_dest->h;
8025 const OPJ_UINT32 MAX_SIZE = UINT32_MAX / sizeof(OPJ_INT32); 8038 const OPJ_UINT32 MAX_SIZE = UINT32_MAX / sizeof(OPJ_INT32);
8026 if (height == 0 || width > MAX_SIZE / height) { 8039 if (height == 0 || width > MAX_SIZE / height) {
8027 return OPJ_FALSE; 8040 return OPJ_FALSE;
8028 } 8041 }
8029 l_img_comp_dest->data = (OPJ_INT32*) opj_calloc(width * heig ht, sizeof(OPJ_INT32)); 8042 l_img_comp_dest->data = (OPJ_INT32*) opj_calloc(width * heig ht, sizeof(OPJ_INT32));
8030 if (!l_img_comp_dest->data) { 8043 if (!l_img_comp_dest->data) {
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
8630 } 8643 }
8631 8644
8632 opj_read_bytes(l_current_ptr,&l_tccp->cblkw ,1); /* SPcoc (E) */ 8645 opj_read_bytes(l_current_ptr,&l_tccp->cblkw ,1); /* SPcoc (E) */
8633 ++l_current_ptr; 8646 ++l_current_ptr;
8634 l_tccp->cblkw += 2; 8647 l_tccp->cblkw += 2;
8635 8648
8636 opj_read_bytes(l_current_ptr,&l_tccp->cblkh ,1); /* SPcoc (F) */ 8649 opj_read_bytes(l_current_ptr,&l_tccp->cblkh ,1); /* SPcoc (F) */
8637 ++l_current_ptr; 8650 ++l_current_ptr;
8638 l_tccp->cblkh += 2; 8651 l_tccp->cblkh += 2;
8639 8652
8653 if ((l_tccp->cblkw > 10) || (l_tccp->cblkh > 10) || ((l_tccp->cblkw + l_ tccp->cblkh) > 12)) {
8654 opj_event_msg(p_manager, EVT_ERROR, "Error reading SPCod SPCoc e lement, Invalid cblkw/cblkh combination\n");
8655 return OPJ_FALSE;
8656 }
8657
8658
8640 opj_read_bytes(l_current_ptr,&l_tccp->cblksty ,1); /* SPcoc (G) */ 8659 opj_read_bytes(l_current_ptr,&l_tccp->cblksty ,1); /* SPcoc (G) */
8641 ++l_current_ptr; 8660 ++l_current_ptr;
8642 8661
8643 opj_read_bytes(l_current_ptr,&l_tccp->qmfbid ,1); /* SPcoc (H) */ 8662 opj_read_bytes(l_current_ptr,&l_tccp->qmfbid ,1); /* SPcoc (H) */
8644 ++l_current_ptr; 8663 ++l_current_ptr;
8645 8664
8646 *p_header_size = *p_header_size - 5; 8665 *p_header_size = *p_header_size - 5;
8647 8666
8648 /* use custom precinct size ? */ 8667 /* use custom precinct size ? */
8649 if (l_tccp->csty & J2K_CCP_CSTY_PRT) { 8668 if (l_tccp->csty & J2K_CCP_CSTY_PRT) {
(...skipping 1938 matching lines...) Expand 10 before | Expand all | Expand 10 after
10588 return OPJ_FALSE; 10607 return OPJ_FALSE;
10589 } 10608 }
10590 if (! opj_j2k_post_write_tile(p_j2k,p_stream,p_manager)) { 10609 if (! opj_j2k_post_write_tile(p_j2k,p_stream,p_manager)) {
10591 opj_event_msg(p_manager, EVT_ERROR, "Error while opj_j2k _post_write_tile with tile index = %d\n", p_tile_index); 10610 opj_event_msg(p_manager, EVT_ERROR, "Error while opj_j2k _post_write_tile with tile index = %d\n", p_tile_index);
10592 return OPJ_FALSE; 10611 return OPJ_FALSE;
10593 } 10612 }
10594 } 10613 }
10595 10614
10596 return OPJ_TRUE; 10615 return OPJ_TRUE;
10597 } 10616 }
OLDNEW
« no previous file with comments | « core/src/fxcodec/fx_libopenjpeg/libopenjpeg20/j2k.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698