summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJUN FANG <jun_fang@foxitsoftware.com>2015-03-16 11:22:52 -0700
committerJUN FANG <jun_fang@foxitsoftware.com>2015-03-16 11:22:52 -0700
commitcd3c4764b87323ec7b712e537d18292d849611b9 (patch)
tree5cc3f51bfb412ce5e8ec1dfe0f9e2c09c678ffb9
parentae5b85a6d5ca1f3c3abd988f19ddc8bfd904464a (diff)
downloadpdfium-cd3c4764b87323ec7b712e537d18292d849611b9.tar.xz
Fix a bug that JPX images can't be shown
In the process of opj_end_decompress, it will return fail when the end of coding stream is reached. However it returns true in the same scenario implemented in openJPEG. So the final solution is from openJPEG. Return true when the end of coding stream is reached. BUG=452671 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/990683002
-rw-r--r--core/src/fxcodec/codec/fx_codec_jpx_opj.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
index c4a0f88201..164fd3e715 100644
--- a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
+++ b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
@@ -52,9 +52,13 @@ static OPJ_SIZE_T opj_write_from_memory (void * p_buffer, OPJ_SIZE_T p_nb_bytes,
static OPJ_OFF_T opj_skip_from_memory (OPJ_OFF_T p_nb_bytes, void* p_user_data)
{
DecodeData* srcData = static_cast<DecodeData*>(p_user_data);
- if (srcData == NULL || srcData->src_size == 0 || srcData->src_data == NULL || srcData->offset >= srcData->src_size) {
+ if (srcData == NULL || srcData->src_size == 0 || srcData->src_data == NULL) {
return -1;
}
+ if (srcData->offset >= srcData->src_size) {
+ srcData->offset = srcData->src_size;
+ return p_nb_bytes;
+ }
OPJ_SIZE_T bufferLength = srcData->src_size - srcData->offset;
OPJ_SIZE_T skipLength = p_nb_bytes < bufferLength ? p_nb_bytes : bufferLength;
srcData->offset += skipLength;
@@ -63,9 +67,12 @@ static OPJ_OFF_T opj_skip_from_memory (OPJ_OFF_T p_nb_bytes, void* p_user_data)
static OPJ_BOOL opj_seek_from_memory (OPJ_OFF_T p_nb_bytes, void* p_user_data)
{
DecodeData* srcData = static_cast<DecodeData*>(p_user_data);
- if (srcData == NULL || srcData->src_size == 0 || srcData->src_data == NULL || srcData->offset >= srcData->src_size) {
+ if (srcData == NULL || srcData->src_size == 0 || srcData->src_data == NULL) {
return OPJ_FALSE;
}
+ if (srcData->offset >= srcData->src_size) {
+ return OPJ_TRUE;
+ }
if (p_nb_bytes >= srcData->src_size) {
return OPJ_FALSE;
}
@@ -629,7 +636,7 @@ FX_BOOL CJPX_Decoder::Init(const unsigned char* src_data, int src_size)
image = NULL;
return FALSE;
}
- if (!(opj_decode(l_codec, l_stream, image) && opj_end_decompress(l_codec, l_stream))) {
+ if (!(opj_decode(l_codec, l_stream, image) && opj_end_decompress(l_codec, l_stream))) {
opj_image_destroy(image);
image = NULL;
return FALSE;