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

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

Issue 671943002: update openjpeg to r2911 (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 6 years, 2 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
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 7072 matching lines...) Expand 10 before | Expand all | Expand 10 after
7083 return l_is_valid; 7083 return l_is_valid;
7084 } 7084 }
7085 7085
7086 OPJ_BOOL opj_j2k_read_header_procedure( opj_j2k_t *p_j2k, 7086 OPJ_BOOL opj_j2k_read_header_procedure( opj_j2k_t *p_j2k,
7087 opj_ stream_private_t *p_stream, 7087 opj_ stream_private_t *p_stream,
7088 opj_ event_mgr_t * p_manager) 7088 opj_ event_mgr_t * p_manager)
7089 { 7089 {
7090 OPJ_UINT32 l_current_marker; 7090 OPJ_UINT32 l_current_marker;
7091 OPJ_UINT32 l_marker_size; 7091 OPJ_UINT32 l_marker_size;
7092 const opj_dec_memory_marker_handler_t * l_marker_handler = 00; 7092 const opj_dec_memory_marker_handler_t * l_marker_handler = 00;
7093 OPJ_BOOL l_has_siz = 0;
7094 OPJ_BOOL l_has_cod = 0;
7095 OPJ_BOOL l_has_qcd = 0;
7093 7096
7094 /* preconditions */ 7097 /* preconditions */
7095 assert(p_stream != 00); 7098 assert(p_stream != 00);
7096 assert(p_j2k != 00); 7099 assert(p_j2k != 00);
7097 assert(p_manager != 00); 7100 assert(p_manager != 00);
7098 7101
7099 /* We enter in the main header */ 7102 /* We enter in the main header */
7100 p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_MHSOC; 7103 p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_MHSOC;
7101 7104
7102 /* Try to read the SOC marker, the codestream must begin with SOC marker */ 7105 /* Try to read the SOC marker, the codestream must begin with SOC marker */
(...skipping 29 matching lines...) Expand all
7132 opj_event_msg(p_manager, EVT_ERROR, "Unknow mark er have been detected and generated error.\n"); 7135 opj_event_msg(p_manager, EVT_ERROR, "Unknow mark er have been detected and generated error.\n");
7133 return OPJ_FALSE; 7136 return OPJ_FALSE;
7134 } 7137 }
7135 7138
7136 if (l_current_marker == J2K_MS_SOT) 7139 if (l_current_marker == J2K_MS_SOT)
7137 break; /* SOT marker is detected main header is completely read */ 7140 break; /* SOT marker is detected main header is completely read */
7138 else /* Get the marker handler from the marker ID */ 7141 else /* Get the marker handler from the marker ID */
7139 l_marker_handler = opj_j2k_get_marker_handler(l_ current_marker); 7142 l_marker_handler = opj_j2k_get_marker_handler(l_ current_marker);
7140 } 7143 }
7141 7144
7145 if (l_marker_handler->id == J2K_MS_SIZ) {
7146 /* Mark required SIZ marker as found */
7147 l_has_siz = 1;
7148 }
7149 if (l_marker_handler->id == J2K_MS_COD) {
7150 /* Mark required COD marker as found */
7151 l_has_cod = 1;
7152 }
7153 if (l_marker_handler->id == J2K_MS_QCD) {
7154 /* Mark required QCD marker as found */
7155 l_has_qcd = 1;
7156 }
7157
7142 /* Check if the marker is known and if it is the right place to find it */ 7158 /* Check if the marker is known and if it is the right place to find it */
7143 if (! (p_j2k->m_specific_param.m_decoder.m_state & l_marker_hand ler->states) ) { 7159 if (! (p_j2k->m_specific_param.m_decoder.m_state & l_marker_hand ler->states) ) {
7144 opj_event_msg(p_manager, EVT_ERROR, "Marker is not compl iant with its position\n"); 7160 opj_event_msg(p_manager, EVT_ERROR, "Marker is not compl iant with its position\n");
7145 return OPJ_FALSE; 7161 return OPJ_FALSE;
7146 } 7162 }
7147 7163
7148 /* Try to read 2 bytes (the marker size) from stream and copy th em into the buffer */ 7164 /* Try to read 2 bytes (the marker size) from stream and copy th em into the buffer */
7149 if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_deco der.m_header_data,2,p_manager) != 2) { 7165 if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_deco der.m_header_data,2,p_manager) != 2) {
7150 opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n" ); 7166 opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n" );
7151 return OPJ_FALSE; 7167 return OPJ_FALSE;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
7194 /* Try to read 2 bytes (the next marker ID) from stream and copy them into the buffer */ 7210 /* Try to read 2 bytes (the next marker ID) from stream and copy them into the buffer */
7195 if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_deco der.m_header_data,2,p_manager) != 2) { 7211 if (opj_stream_read_data(p_stream,p_j2k->m_specific_param.m_deco der.m_header_data,2,p_manager) != 2) {
7196 opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n" ); 7212 opj_event_msg(p_manager, EVT_ERROR, "Stream too short\n" );
7197 return OPJ_FALSE; 7213 return OPJ_FALSE;
7198 } 7214 }
7199 7215
7200 /* read 2 bytes as the new marker ID */ 7216 /* read 2 bytes as the new marker ID */
7201 opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,& l_current_marker,2); 7217 opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data,& l_current_marker,2);
7202 } 7218 }
7203 7219
7220 if (l_has_siz == 0) {
7221 opj_event_msg(p_manager, EVT_ERROR, "required SIZ marker not found i n main header\n");
7222 return OPJ_FALSE;
7223 }
7224 if (l_has_cod == 0) {
7225 opj_event_msg(p_manager, EVT_ERROR, "required COD marker not found i n main header\n");
7226 return OPJ_FALSE;
7227 }
7228 if (l_has_qcd == 0) {
7229 opj_event_msg(p_manager, EVT_ERROR, "required QCD marker not found i n main header\n");
7230 return OPJ_FALSE;
7231 }
7232
7204 opj_event_msg(p_manager, EVT_INFO, "Main header has been correctly decod ed.\n"); 7233 opj_event_msg(p_manager, EVT_INFO, "Main header has been correctly decod ed.\n");
7205 7234
7206 /* Position of the last element if the main header */ 7235 /* Position of the last element if the main header */
7207 p_j2k->cstr_index->main_head_end = (OPJ_UINT32) opj_stream_tell(p_stream ) - 2; 7236 p_j2k->cstr_index->main_head_end = (OPJ_UINT32) opj_stream_tell(p_stream ) - 2;
7208 7237
7209 /* Next step: read a tile-part header */ 7238 /* Next step: read a tile-part header */
7210 p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPHSOT; 7239 p_j2k->m_specific_param.m_decoder.m_state = J2K_STATE_TPHSOT;
7211 7240
7212 return OPJ_TRUE; 7241 return OPJ_TRUE;
7213 } 7242 }
(...skipping 3224 matching lines...) Expand 10 before | Expand all | Expand 10 after
10438 } 10467 }
10439 else { 10468 else {
10440 if (! opj_j2k_post_write_tile(p_j2k,p_data,p_data_size,p_stream, p_manager)) { 10469 if (! opj_j2k_post_write_tile(p_j2k,p_data,p_data_size,p_stream, p_manager)) {
10441 opj_event_msg(p_manager, EVT_ERROR, "Error while opj_j2k _post_write_tile with tile index = %d\n", p_tile_index); 10470 opj_event_msg(p_manager, EVT_ERROR, "Error while opj_j2k _post_write_tile with tile index = %d\n", p_tile_index);
10442 return OPJ_FALSE; 10471 return OPJ_FALSE;
10443 } 10472 }
10444 } 10473 }
10445 10474
10446 return OPJ_TRUE; 10475 return OPJ_TRUE;
10447 } 10476 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698