From 4588792ebfcfdd628b76f005fa0e1d7935739139 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Mon, 11 Sep 2017 16:12:14 -0400 Subject: Address nits missed from original review BUG=chromium:761005 Change-Id: I538e49f1eeb32891b33677d8587d2bed110b1fc1 Reviewed-on: https://pdfium-review.googlesource.com/13692 Reviewed-by: Tom Sepez Commit-Queue: Ryan Harrison --- core/fxcodec/codec/fx_codec_jpx_opj.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/core/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/fxcodec/codec/fx_codec_jpx_opj.cpp index b421e8fb2d..21d971bc8c 100644 --- a/core/fxcodec/codec/fx_codec_jpx_opj.cpp +++ b/core/fxcodec/codec/fx_codec_jpx_opj.cpp @@ -510,8 +510,9 @@ bool CJPX_Decoder::Decode(uint8_t* dest_buf, return false; if (pitch(m_Image->comps[0].w * 8 * m_Image->numcomps + 31)>> - 5 << 2) + 5 << 2) { return false; + } if (!m_Parameters.nb_tile_to_decode) { if (!opj_set_decode_area(m_Codec, m_Image, m_Parameters.DA_x0, @@ -527,11 +528,9 @@ bool CJPX_Decoder::Decode(uint8_t* dest_buf, m_Image = nullptr; return false; } - } else { - if (!opj_get_decoded_tile(m_Codec, m_Stream, m_Image, - m_Parameters.tile_index)) { - return false; - } + } else if (!opj_get_decoded_tile(m_Codec, m_Stream, m_Image, + m_Parameters.tile_index)) { + return false; } opj_stream_destroy(m_Stream); @@ -609,11 +608,7 @@ bool CJPX_Decoder::Decode(uint8_t* dest_buf, } else { int tmpPixel = (src >> adjust_comps[channel]) + ((src >> (adjust_comps[channel] - 1)) % 2); - if (tmpPixel > 255) { - tmpPixel = 255; - } else if (tmpPixel < 0) { - tmpPixel = 0; - } + tmpPixel = pdfium::clamp(tmpPixel, 0, 255); *pPixel = static_cast(tmpPixel); } } -- cgit v1.2.3