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

Side by Side Diff: third_party/libopenjpeg20/cio.c

Issue 1338973005: upgrade openjpeg to commit# cf352af (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 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 28 matching lines...) Expand all
39 39
40 #include "opj_includes.h" 40 #include "opj_includes.h"
41 41
42 /* ----------------------------------------------------------------------- */ 42 /* ----------------------------------------------------------------------- */
43 43
44 44
45 /* ----------------------------------------------------------------------- */ 45 /* ----------------------------------------------------------------------- */
46 46
47 void opj_write_bytes_BE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_n b_bytes) 47 void opj_write_bytes_BE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_n b_bytes)
48 { 48 {
49 » const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value) + p_nb_bytes ; 49 » const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value)+sizeof(OPJ_U INT32)-p_nb_bytes;
50 50
51 assert(p_nb_bytes > 0 && p_nb_bytes <= sizeof(OPJ_UINT32)); 51 assert(p_nb_bytes > 0 && p_nb_bytes <= sizeof(OPJ_UINT32));
52 52
53 memcpy(p_buffer,l_data_ptr,p_nb_bytes); 53 memcpy(p_buffer,l_data_ptr,p_nb_bytes);
54 } 54 }
55 55
56 void opj_write_bytes_LE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_n b_bytes) 56 void opj_write_bytes_LE (OPJ_BYTE * p_buffer, OPJ_UINT32 p_value, OPJ_UINT32 p_n b_bytes)
57 { 57 {
58 const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value) + p_nb_bytes - 1; 58 const OPJ_BYTE * l_data_ptr = ((const OPJ_BYTE *) &p_value) + p_nb_bytes - 1;
59 OPJ_UINT32 i; 59 OPJ_UINT32 i;
60 60
61 assert(p_nb_bytes > 0 && p_nb_bytes <= sizeof(OPJ_UINT32)); 61 assert(p_nb_bytes > 0 && p_nb_bytes <= sizeof(OPJ_UINT32));
62 62
63 for (i=0;i<p_nb_bytes;++i) { 63 for (i=0;i<p_nb_bytes;++i) {
64 *(p_buffer++) = *(l_data_ptr--); 64 *(p_buffer++) = *(l_data_ptr--);
65 } 65 }
66 } 66 }
67 67
68 void opj_read_bytes_BE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT 32 p_nb_bytes) 68 void opj_read_bytes_BE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT 32 p_nb_bytes)
69 { 69 {
70 OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value); 70 OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value);
71 71
72 assert(p_nb_bytes > 0 && p_nb_bytes <= sizeof(OPJ_UINT32)); 72 assert(p_nb_bytes > 0 && p_nb_bytes <= sizeof(OPJ_UINT32));
73 73
74 *p_value = 0; 74 *p_value = 0;
75 » memcpy(l_data_ptr+4-p_nb_bytes,p_buffer,p_nb_bytes); 75 » memcpy(l_data_ptr+sizeof(OPJ_UINT32)-p_nb_bytes,p_buffer,p_nb_bytes);
76 } 76 }
77 77
78 void opj_read_bytes_LE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT 32 p_nb_bytes) 78 void opj_read_bytes_LE(const OPJ_BYTE * p_buffer, OPJ_UINT32 * p_value, OPJ_UINT 32 p_nb_bytes)
79 { 79 {
80 OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value) + p_nb_bytes-1; 80 OPJ_BYTE * l_data_ptr = ((OPJ_BYTE *) p_value) + p_nb_bytes-1;
81 OPJ_UINT32 i; 81 OPJ_UINT32 i;
82 82
83 assert(p_nb_bytes > 0 && p_nb_bytes <= sizeof(OPJ_UINT32)); 83 assert(p_nb_bytes > 0 && p_nb_bytes <= sizeof(OPJ_UINT32));
84 84
85 *p_value = 0; 85 *p_value = 0;
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 p_stream->m_byte_offset += (OPJ_OFF_T)p_stream->m_bytes_in_buffe r; 295 p_stream->m_byte_offset += (OPJ_OFF_T)p_stream->m_bytes_in_buffe r;
296 p_stream->m_bytes_in_buffer = 0; 296 p_stream->m_bytes_in_buffer = 0;
297 } 297 }
298 else { 298 else {
299 /* case where we are already at the end of the buffer 299 /* case where we are already at the end of the buffer
300 so reset the m_current_data to point to the start of the 300 so reset the m_current_data to point to the start of the
301 stored buffer to get ready to read from disk*/ 301 stored buffer to get ready to read from disk*/
302 p_stream->m_current_data = p_stream->m_stored_data; 302 p_stream->m_current_data = p_stream->m_stored_data;
303 } 303 }
304 304
305 » while(1){ 305 » for (;;) {
306 /* we should read less than a chunk -> read a chunk */ 306 /* we should read less than a chunk -> read a chunk */
307 if (p_size < p_stream->m_buffer_size) { 307 if (p_size < p_stream->m_buffer_size) {
308 /* we should do an actual read on the media */ 308 /* we should do an actual read on the media */
309 p_stream->m_bytes_in_buffer = p_stream->m_read_fn(p_stre am->m_stored_data,p_stream->m_buffer_size,p_stream->m_user_data); 309 p_stream->m_bytes_in_buffer = p_stream->m_read_fn(p_stre am->m_stored_data,p_stream->m_buffer_size,p_stream->m_user_data);
310 310
311 if (p_stream->m_bytes_in_buffer == (OPJ_SIZE_T)-1) { 311 if (p_stream->m_bytes_in_buffer == (OPJ_SIZE_T)-1) {
312 /* end of stream */ 312 /* end of stream */
313 opj_event_msg(p_event_mgr, EVT_INFO, "Stream rea ched its end !\n"); 313 opj_event_msg(p_event_mgr, EVT_INFO, "Stream rea ched its end !\n");
314 314
315 p_stream->m_bytes_in_buffer = 0; 315 p_stream->m_bytes_in_buffer = 0;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 OPJ_SIZE_T p_s ize, 375 OPJ_SIZE_T p_s ize,
376 opj_event_mgr_ t * p_event_mgr) 376 opj_event_mgr_ t * p_event_mgr)
377 { 377 {
378 OPJ_SIZE_T l_remaining_bytes = 0; 378 OPJ_SIZE_T l_remaining_bytes = 0;
379 OPJ_SIZE_T l_write_nb_bytes = 0; 379 OPJ_SIZE_T l_write_nb_bytes = 0;
380 380
381 if (p_stream->m_status & opj_stream_e_error) { 381 if (p_stream->m_status & opj_stream_e_error) {
382 return (OPJ_SIZE_T)-1; 382 return (OPJ_SIZE_T)-1;
383 } 383 }
384 384
385 » while(1) { 385 » for (;;) {
386 l_remaining_bytes = p_stream->m_buffer_size - p_stream->m_bytes_ in_buffer; 386 l_remaining_bytes = p_stream->m_buffer_size - p_stream->m_bytes_ in_buffer;
387 387
388 /* we have more memory than required */ 388 /* we have more memory than required */
389 if (l_remaining_bytes >= p_size) { 389 if (l_remaining_bytes >= p_size) {
390 memcpy(p_stream->m_current_data, p_buffer, p_size); 390 memcpy(p_stream->m_current_data, p_buffer, p_size);
391 391
392 p_stream->m_current_data += p_size; 392 p_stream->m_current_data += p_size;
393 p_stream->m_bytes_in_buffer += p_size; 393 p_stream->m_bytes_in_buffer += p_size;
394 l_write_nb_bytes += p_size; 394 l_write_nb_bytes += p_size;
395 p_stream->m_byte_offset += (OPJ_OFF_T)p_size; 395 p_stream->m_byte_offset += (OPJ_OFF_T)p_size;
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 OPJ_ARG_NOT_USED(p_user_data); 635 OPJ_ARG_NOT_USED(p_user_data);
636 return (OPJ_OFF_T) -1; 636 return (OPJ_OFF_T) -1;
637 } 637 }
638 638
639 OPJ_BOOL opj_stream_default_seek (OPJ_OFF_T p_nb_bytes, void * p_user_data) 639 OPJ_BOOL opj_stream_default_seek (OPJ_OFF_T p_nb_bytes, void * p_user_data)
640 { 640 {
641 OPJ_ARG_NOT_USED(p_nb_bytes); 641 OPJ_ARG_NOT_USED(p_nb_bytes);
642 OPJ_ARG_NOT_USED(p_user_data); 642 OPJ_ARG_NOT_USED(p_user_data);
643 return OPJ_FALSE; 643 return OPJ_FALSE;
644 } 644 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698