Chromium Code Reviews| Index: core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp |
| diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp |
| index 1637655e68d9f44642a9c478ce37521371158bf0..e4d20413a6240d9c1dacc64bcdec5fb196cf01b1 100644 |
| --- a/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp |
| +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_loadimage.cpp |
| @@ -314,9 +314,6 @@ int CPDF_DIBSource::StartLoadDIBSource(CPDF_Document* pDoc, const CPDF_Stream* p |
| if (!LoadColorInfo(m_pStream->GetObjNum() != 0 ? NULL : pFormResources, pPageResources)) { |
| return 0; |
| } |
| - if (m_bpc == 0 || m_nComponents == 0) { |
|
Lei Zhang
2015/01/30 06:43:58
If you look in the CL that introduced this:
https
Tom Sepez
2015/01/30 17:25:29
From the original review, I asked the question and
Lei Zhang
2015/01/30 23:00:07
I disagree with that assessment. If you follow the
jun_fang
2015/01/31 04:29:22
According to PDF standard, BitsPerComponent(bpc) i
|
| - return 0; |
| - } |
| FX_SAFE_DWORD src_pitch = m_bpc; |
| src_pitch *= m_nComponents; |
| src_pitch *= m_Width; |
| @@ -567,8 +564,12 @@ int CPDF_DIBSource::CreateDecoder() |
| if (decoder.IsEmpty()) { |
| return 1; |
| } |
| - if (m_bpc == 0) { |
| - return 0; |
| + if (decoder != FX_BSTRC("CCITTFaxDecode") && |
|
Lei Zhang
2015/01/30 06:43:58
I don't think |m_bpc| matters for these decoders,
jun_fang
2015/01/31 04:29:22
It's no need to check bpc for only JPX images and
|
| + decoder != FX_BSTRC("JPXDecode") && |
| + decoder != FX_BSTRC("JBIG2Decode")) { |
| + if (m_bpc == 0) { |
| + return 0; |
| + } |
| } |
| FX_LPCBYTE src_data = m_pStreamAcc->GetData(); |
| FX_DWORD src_size = m_pStreamAcc->GetSize(); |
| @@ -578,7 +579,7 @@ int CPDF_DIBSource::CreateDecoder() |
| } else if (decoder == FX_BSTRC("DCTDecode")) { |
| m_pDecoder = CPDF_ModuleMgr::Get()->GetJpegModule()->CreateDecoder(src_data, src_size, m_Width, m_Height, |
| m_nComponents, pParams ? pParams->GetInteger(FX_BSTR("ColorTransform"), 1) : 1); |
| - if (NULL == m_pDecoder) { |
| + if (!m_pDecoder) { |
| FX_BOOL bTransform = FALSE; |
| int comps, bpc; |
| ICodec_JpegModule* pJpegModule = CPDF_ModuleMgr::Get()->GetJpegModule(); |
| @@ -617,29 +618,29 @@ int CPDF_DIBSource::CreateDecoder() |
| } else if (decoder == FX_BSTRC("RunLengthDecode")) { |
| m_pDecoder = CPDF_ModuleMgr::Get()->GetCodecModule()->GetBasicModule()->CreateRunLengthDecoder(src_data, src_size, m_Width, m_Height, m_nComponents, m_bpc); |
| } |
| - if (m_pDecoder) { |
| - FX_SAFE_DWORD requested_pitch = m_bpc; |
| - requested_pitch *= m_nComponents; |
| - requested_pitch *= m_Width; |
| - requested_pitch += 7; |
| - requested_pitch /= 8; |
| - if (!requested_pitch.IsValid()) { |
| - return 0; |
| - } |
| - FX_SAFE_DWORD provided_pitch = m_pDecoder->GetBPC(); |
| - provided_pitch *= m_pDecoder->CountComps(); |
| - provided_pitch *= m_pDecoder->GetWidth(); |
| - provided_pitch += 7; |
| - provided_pitch /= 8; |
| - if (!provided_pitch.IsValid()) { |
| - return 0; |
| - } |
| - if (provided_pitch.ValueOrDie() < requested_pitch.ValueOrDie()) { |
| - return 0; |
| - } |
| - return 1; |
| + if (!m_pDecoder) |
|
Lei Zhang
2015/01/30 06:43:58
This is just to put all the "return 0" cases befor
|
| + return 0; |
| + |
| + FX_SAFE_DWORD requested_pitch = m_bpc; |
| + requested_pitch *= m_nComponents; |
| + requested_pitch *= m_Width; |
| + requested_pitch += 7; |
| + requested_pitch /= 8; |
| + if (!requested_pitch.IsValid()) { |
| + return 0; |
| } |
| - return 0; |
| + FX_SAFE_DWORD provided_pitch = m_pDecoder->GetBPC(); |
| + provided_pitch *= m_pDecoder->CountComps(); |
| + provided_pitch *= m_pDecoder->GetWidth(); |
| + provided_pitch += 7; |
| + provided_pitch /= 8; |
| + if (!provided_pitch.IsValid()) { |
| + return 0; |
| + } |
| + if (provided_pitch.ValueOrDie() < requested_pitch.ValueOrDie()) { |
| + return 0; |
| + } |
| + return 1; |
| } |
| void CPDF_DIBSource::LoadJpxBitmap() |
| { |