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

Side by Side Diff: core/src/fxcodec/codec/fx_codec_jpeg.cpp

Issue 1529553003: Merge to XFA: Get rid of most instance of 'foo != NULL' (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years 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 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include <setjmp.h> 7 #include <setjmp.h>
8 8
9 #include "codec_int.h" 9 #include "codec_int.h"
10 #include "core/include/fxcodec/fx_codec.h" 10 #include "core/include/fxcodec/fx_codec.h"
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 if (ret != JPEG_HEADER_OK) { 290 if (ret != JPEG_HEADER_OK) {
291 jpeg_destroy_decompress(&cinfo); 291 jpeg_destroy_decompress(&cinfo);
292 return FALSE; 292 return FALSE;
293 } 293 }
294 width = cinfo.image_width; 294 width = cinfo.image_width;
295 height = cinfo.image_height; 295 height = cinfo.image_height;
296 num_components = cinfo.num_components; 296 num_components = cinfo.num_components;
297 color_transform = 297 color_transform =
298 cinfo.jpeg_color_space == JCS_YCbCr || cinfo.jpeg_color_space == JCS_YCCK; 298 cinfo.jpeg_color_space == JCS_YCbCr || cinfo.jpeg_color_space == JCS_YCCK;
299 bits_per_components = cinfo.data_precision; 299 bits_per_components = cinfo.data_precision;
300 if (icc_buf_ptr != NULL) { 300 if (icc_buf_ptr) {
301 *icc_buf_ptr = NULL; 301 *icc_buf_ptr = NULL;
302 } 302 }
303 if (icc_length != NULL) { 303 if (icc_length) {
304 *icc_length = 0; 304 *icc_length = 0;
305 } 305 }
306 jpeg_destroy_decompress(&cinfo); 306 jpeg_destroy_decompress(&cinfo);
307 return TRUE; 307 return TRUE;
308 } 308 }
309 309
310 class CCodec_JpegDecoder : public CCodec_ScanlineDecoder { 310 class CCodec_JpegDecoder : public CCodec_ScanlineDecoder {
311 public: 311 public:
312 CCodec_JpegDecoder(); 312 CCodec_JpegDecoder();
313 ~CCodec_JpegDecoder() override; 313 ~CCodec_JpegDecoder() override;
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 return _JpegLoadInfo(src_buf, src_size, width, height, num_components, 539 return _JpegLoadInfo(src_buf, src_size, width, height, num_components,
540 bits_per_components, color_transform, icc_buf_ptr, 540 bits_per_components, color_transform, icc_buf_ptr,
541 icc_length); 541 icc_length);
542 } 542 }
543 FX_BOOL CCodec_JpegModule::Encode(const CFX_DIBSource* pSource, 543 FX_BOOL CCodec_JpegModule::Encode(const CFX_DIBSource* pSource,
544 uint8_t*& dest_buf, 544 uint8_t*& dest_buf,
545 FX_STRSIZE& dest_size, 545 FX_STRSIZE& dest_size,
546 int quality, 546 int quality,
547 const uint8_t* icc_buf, 547 const uint8_t* icc_buf,
548 FX_DWORD icc_length) { 548 FX_DWORD icc_length) {
549 if (pSource->GetBPP() < 8 || pSource->GetPalette() != NULL) { 549 if (pSource->GetBPP() < 8 || pSource->GetPalette()) {
550 ASSERT(pSource->GetBPP() >= 8 && pSource->GetPalette() == NULL); 550 ASSERT(pSource->GetBPP() >= 8 && pSource->GetPalette() == NULL);
551 return FALSE; 551 return FALSE;
552 } 552 }
553 _JpegEncode(pSource, dest_buf, dest_size, quality, icc_buf, icc_length); 553 _JpegEncode(pSource, dest_buf, dest_size, quality, icc_buf, icc_length);
554 return TRUE; 554 return TRUE;
555 } 555 }
556 struct FXJPEG_Context { 556 struct FXJPEG_Context {
557 jmp_buf m_JumpMark; 557 jmp_buf m_JumpMark;
558 jpeg_decompress_struct m_Info; 558 jpeg_decompress_struct m_Info;
559 jpeg_error_mgr m_ErrMgr; 559 jpeg_error_mgr m_ErrMgr;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 unsigned char* dest_buf) { 675 unsigned char* dest_buf) {
676 FXJPEG_Context* p = (FXJPEG_Context*)pContext; 676 FXJPEG_Context* p = (FXJPEG_Context*)pContext;
677 if (setjmp(p->m_JumpMark) == -1) { 677 if (setjmp(p->m_JumpMark) == -1) {
678 return FALSE; 678 return FALSE;
679 } 679 }
680 int nlines = jpeg_read_scanlines(&p->m_Info, &dest_buf, 1); 680 int nlines = jpeg_read_scanlines(&p->m_Info, &dest_buf, 1);
681 return nlines == 1; 681 return nlines == 1;
682 } 682 }
683 FX_DWORD CCodec_JpegModule::GetAvailInput(void* pContext, 683 FX_DWORD CCodec_JpegModule::GetAvailInput(void* pContext,
684 uint8_t** avail_buf_ptr) { 684 uint8_t** avail_buf_ptr) {
685 if (avail_buf_ptr != NULL) { 685 if (avail_buf_ptr) {
686 *avail_buf_ptr = NULL; 686 *avail_buf_ptr = NULL;
687 if (((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) { 687 if (((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) {
688 *avail_buf_ptr = 688 *avail_buf_ptr =
689 (uint8_t*)((FXJPEG_Context*)pContext)->m_SrcMgr.next_input_byte; 689 (uint8_t*)((FXJPEG_Context*)pContext)->m_SrcMgr.next_input_byte;
690 } 690 }
691 } 691 }
692 return (FX_DWORD)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer; 692 return (FX_DWORD)((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer;
693 } 693 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698