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

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

Issue 1171733003: Remove typdefs for pointer types in fx_system.h (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual fixes. Created 5 years, 6 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
« no previous file with comments | « core/src/fxcodec/codec/codec_int.h ('k') | core/src/fxcodec/codec/fx_codec_fax.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "../../../include/fxcodec/fx_codec.h" 7 #include "../../../include/fxcodec/fx_codec.h"
8 #include "codec_int.h" 8 #include "codec_int.h"
9 CCodec_ModuleMgr::CCodec_ModuleMgr() 9 CCodec_ModuleMgr::CCodec_ModuleMgr()
10 { 10 {
(...skipping 29 matching lines...) Expand all
40 m_NextLine = -1; 40 m_NextLine = -1;
41 m_pDataCache = NULL; 41 m_pDataCache = NULL;
42 m_pLastScanline = NULL; 42 m_pLastScanline = NULL;
43 } 43 }
44 CCodec_ScanlineDecoder::~CCodec_ScanlineDecoder() 44 CCodec_ScanlineDecoder::~CCodec_ScanlineDecoder()
45 { 45 {
46 if (m_pDataCache) { 46 if (m_pDataCache) {
47 FX_Free(m_pDataCache); 47 FX_Free(m_pDataCache);
48 } 48 }
49 } 49 }
50 FX_LPBYTE CCodec_ScanlineDecoder::GetScanline(int line) 50 uint8_t* CCodec_ScanlineDecoder::GetScanline(int line)
51 { 51 {
52 if (m_pDataCache && line < m_pDataCache->m_nCachedLines) { 52 if (m_pDataCache && line < m_pDataCache->m_nCachedLines) {
53 return &m_pDataCache->m_Data + line * m_Pitch; 53 return &m_pDataCache->m_Data + line * m_Pitch;
54 } 54 }
55 if (m_NextLine == line + 1) { 55 if (m_NextLine == line + 1) {
56 return m_pLastScanline; 56 return m_pLastScanline;
57 } 57 }
58 if (m_NextLine < 0 || m_NextLine > line) { 58 if (m_NextLine < 0 || m_NextLine > line) {
59 if (!v_Rewind()) { 59 if (!v_Rewind()) {
60 return NULL; 60 return NULL;
(...skipping 23 matching lines...) Expand all
84 m_pLastScanline = NULL; 84 m_pLastScanline = NULL;
85 while (m_NextLine < line) { 85 while (m_NextLine < line) {
86 m_pLastScanline = ReadNextLine(); 86 m_pLastScanline = ReadNextLine();
87 m_NextLine ++; 87 m_NextLine ++;
88 if (pPause && pPause->NeedToPauseNow()) { 88 if (pPause && pPause->NeedToPauseNow()) {
89 return TRUE; 89 return TRUE;
90 } 90 }
91 } 91 }
92 return FALSE; 92 return FALSE;
93 } 93 }
94 FX_LPBYTE CCodec_ScanlineDecoder::ReadNextLine() 94 uint8_t* CCodec_ScanlineDecoder::ReadNextLine()
95 { 95 {
96 FX_LPBYTE pLine = v_GetNextLine(); 96 uint8_t* pLine = v_GetNextLine();
97 if (pLine == NULL) { 97 if (pLine == NULL) {
98 return NULL; 98 return NULL;
99 } 99 }
100 if (m_pDataCache && m_NextLine == m_pDataCache->m_nCachedLines) { 100 if (m_pDataCache && m_NextLine == m_pDataCache->m_nCachedLines) {
101 FXSYS_memcpy32(&m_pDataCache->m_Data + m_NextLine * m_Pitch, pLine, m_Pi tch); 101 FXSYS_memcpy32(&m_pDataCache->m_Data + m_NextLine * m_Pitch, pLine, m_Pi tch);
102 m_pDataCache->m_nCachedLines ++; 102 m_pDataCache->m_nCachedLines ++;
103 } 103 }
104 return pLine; 104 return pLine;
105 } 105 }
106 void CCodec_ScanlineDecoder::DownScale(int dest_width, int dest_height) 106 void CCodec_ScanlineDecoder::DownScale(int dest_width, int dest_height)
(...skipping 13 matching lines...) Expand all
120 m_pDataCache = NULL; 120 m_pDataCache = NULL;
121 } 121 }
122 m_pDataCache = (CCodec_ImageDataCache*)FX_TryAlloc(uint8_t, sizeof(CCodec_Im ageDataCache) + m_Pitch * m_OutputHeight); 122 m_pDataCache = (CCodec_ImageDataCache*)FX_TryAlloc(uint8_t, sizeof(CCodec_Im ageDataCache) + m_Pitch * m_OutputHeight);
123 if (m_pDataCache == NULL) { 123 if (m_pDataCache == NULL) {
124 return; 124 return;
125 } 125 }
126 m_pDataCache->m_Height = m_OutputHeight; 126 m_pDataCache->m_Height = m_OutputHeight;
127 m_pDataCache->m_Width = m_OutputWidth; 127 m_pDataCache->m_Width = m_OutputWidth;
128 m_pDataCache->m_nCachedLines = 0; 128 m_pDataCache->m_nCachedLines = 0;
129 } 129 }
130 FX_BOOL CCodec_BasicModule::RunLengthEncode(const uint8_t* src_buf, FX_DWORD src _size, FX_LPBYTE& dest_buf, 130 FX_BOOL CCodec_BasicModule::RunLengthEncode(const uint8_t* src_buf, FX_DWORD src _size, uint8_t*& dest_buf,
131 FX_DWORD& dest_size) 131 FX_DWORD& dest_size)
132 { 132 {
133 return FALSE; 133 return FALSE;
134 } 134 }
135 extern "C" double FXstrtod(const char* nptr, char** endptr) 135 extern "C" double FXstrtod(const char* nptr, char** endptr)
136 { 136 {
137 double ret = 0.0; 137 double ret = 0.0;
138 const char* ptr = nptr; 138 const char* ptr = nptr;
139 const char* exp_ptr = NULL; 139 const char* exp_ptr = NULL;
140 int e_number = 0, 140 int e_number = 0,
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 while(exp_ret--) { 229 while(exp_ret--) {
230 ret *= 10.0; 230 ret *= 10.0;
231 } 231 }
232 } else { 232 } else {
233 while(exp_ret--) { 233 while(exp_ret--) {
234 ret /= 10.0; 234 ret /= 10.0;
235 } 235 }
236 } 236 }
237 return is_negative ? -ret : ret; 237 return is_negative ? -ret : ret;
238 } 238 }
239 FX_BOOL CCodec_BasicModule::A85Encode(const uint8_t* src_buf, FX_DWORD src_size, FX_LPBYTE& dest_buf, 239 FX_BOOL CCodec_BasicModule::A85Encode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_buf,
240 FX_DWORD& dest_size) 240 FX_DWORD& dest_size)
241 { 241 {
242 return FALSE; 242 return FALSE;
243 } 243 }
244 CCodec_ModuleMgr* CCodec_ModuleMgr::Create() 244 CCodec_ModuleMgr* CCodec_ModuleMgr::Create()
245 { 245 {
246 return new CCodec_ModuleMgr; 246 return new CCodec_ModuleMgr;
247 } 247 }
248 void CCodec_ModuleMgr::Destroy() 248 void CCodec_ModuleMgr::Destroy()
249 { 249 {
250 delete this; 250 delete this;
251 } 251 }
252 class CCodec_RLScanlineDecoder : public CCodec_ScanlineDecoder 252 class CCodec_RLScanlineDecoder : public CCodec_ScanlineDecoder
253 { 253 {
254 public: 254 public:
255 CCodec_RLScanlineDecoder(); 255 CCodec_RLScanlineDecoder();
256 virtual ~CCodec_RLScanlineDecoder(); 256 virtual ~CCodec_RLScanlineDecoder();
257 FX_BOOL» » » » Create(FX_LPCBYTE src_buf, FX_DWORD src_ size, int width, int height, int nComps, int bpc); 257 FX_BOOL» » » » Create(const uint8_t* src_buf, FX_DWORD src_size, int width, int height, int nComps, int bpc);
258 virtual void v_DownScale(int dest_width, int dest_height) {} 258 virtual void v_DownScale(int dest_width, int dest_height) {}
259 virtual FX_BOOL v_Rewind(); 259 virtual FX_BOOL v_Rewind();
260 virtual FX_LPBYTE» v_GetNextLine(); 260 virtual uint8_t*» v_GetNextLine();
261 virtual FX_DWORD GetSrcOffset() 261 virtual FX_DWORD GetSrcOffset()
262 { 262 {
263 return m_SrcOffset; 263 return m_SrcOffset;
264 } 264 }
265 protected: 265 protected:
266 FX_BOOL CheckDestSize(); 266 FX_BOOL CheckDestSize();
267 void GetNextOperator(); 267 void GetNextOperator();
268 void UpdateOperator(uint8_t used_bytes); 268 void UpdateOperator(uint8_t used_bytes);
269 269
270 FX_LPBYTE» » » m_pScanline; 270 uint8_t*» » » m_pScanline;
271 FX_LPCBYTE» » » m_pSrcBuf; 271 const uint8_t*» » » m_pSrcBuf;
272 FX_DWORD m_SrcSize; 272 FX_DWORD m_SrcSize;
273 FX_DWORD m_dwLineBytes; 273 FX_DWORD m_dwLineBytes;
274 FX_DWORD m_SrcOffset; 274 FX_DWORD m_SrcOffset;
275 FX_BOOL m_bEOD; 275 FX_BOOL m_bEOD;
276 uint8_t m_Operator; 276 uint8_t m_Operator;
277 }; 277 };
278 CCodec_RLScanlineDecoder::CCodec_RLScanlineDecoder() 278 CCodec_RLScanlineDecoder::CCodec_RLScanlineDecoder()
279 : m_pScanline(NULL) 279 : m_pScanline(NULL)
280 , m_pSrcBuf(NULL) 280 , m_pSrcBuf(NULL)
281 , m_SrcSize(0) 281 , m_SrcSize(0)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 i += 2; 313 i += 2;
314 } else { 314 } else {
315 break; 315 break;
316 } 316 }
317 } 317 }
318 if (((FX_DWORD)m_OrigWidth * m_nComps * m_bpc * m_OrigHeight + 7) / 8 > dest _size) { 318 if (((FX_DWORD)m_OrigWidth * m_nComps * m_bpc * m_OrigHeight + 7) / 8 > dest _size) {
319 return FALSE; 319 return FALSE;
320 } 320 }
321 return TRUE; 321 return TRUE;
322 } 322 }
323 FX_BOOL CCodec_RLScanlineDecoder::Create(FX_LPCBYTE src_buf, FX_DWORD src_size, int width, int height, int nComps, int bpc) 323 FX_BOOL CCodec_RLScanlineDecoder::Create(const uint8_t* src_buf, FX_DWORD src_si ze, int width, int height, int nComps, int bpc)
324 { 324 {
325 m_pSrcBuf = src_buf; 325 m_pSrcBuf = src_buf;
326 m_SrcSize = src_size; 326 m_SrcSize = src_size;
327 m_OutputWidth = m_OrigWidth = width; 327 m_OutputWidth = m_OrigWidth = width;
328 m_OutputHeight = m_OrigHeight = height; 328 m_OutputHeight = m_OrigHeight = height;
329 m_nComps = nComps; 329 m_nComps = nComps;
330 m_bpc = bpc; 330 m_bpc = bpc;
331 m_bColorTransformed = FALSE; 331 m_bColorTransformed = FALSE;
332 m_DownScale = 1; 332 m_DownScale = 1;
333 m_Pitch = (width * nComps * bpc + 31) / 32 * 4; 333 m_Pitch = (width * nComps * bpc + 31) / 32 * 4;
334 m_dwLineBytes = (width * nComps * bpc + 7) / 8; 334 m_dwLineBytes = (width * nComps * bpc + 7) / 8;
335 m_pScanline = FX_Alloc(uint8_t, m_Pitch); 335 m_pScanline = FX_Alloc(uint8_t, m_Pitch);
336 return CheckDestSize(); 336 return CheckDestSize();
337 } 337 }
338 FX_BOOL CCodec_RLScanlineDecoder::v_Rewind() 338 FX_BOOL CCodec_RLScanlineDecoder::v_Rewind()
339 { 339 {
340 FXSYS_memset32(m_pScanline, 0, m_Pitch); 340 FXSYS_memset32(m_pScanline, 0, m_Pitch);
341 m_SrcOffset = 0; 341 m_SrcOffset = 0;
342 m_bEOD = FALSE; 342 m_bEOD = FALSE;
343 m_Operator = 0; 343 m_Operator = 0;
344 return TRUE; 344 return TRUE;
345 } 345 }
346 FX_LPBYTE CCodec_RLScanlineDecoder::v_GetNextLine() 346 uint8_t* CCodec_RLScanlineDecoder::v_GetNextLine()
347 { 347 {
348 if (m_SrcOffset == 0) { 348 if (m_SrcOffset == 0) {
349 GetNextOperator(); 349 GetNextOperator();
350 } else { 350 } else {
351 if (m_bEOD) { 351 if (m_bEOD) {
352 return NULL; 352 return NULL;
353 } 353 }
354 } 354 }
355 FXSYS_memset32(m_pScanline, 0, m_Pitch); 355 FXSYS_memset32(m_pScanline, 0, m_Pitch);
356 FX_DWORD col_pos = 0; 356 FX_DWORD col_pos = 0;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 uint8_t count = 257 - m_Operator; 420 uint8_t count = 257 - m_Operator;
421 FXSYS_assert((FX_DWORD)count >= used_bytes); 421 FXSYS_assert((FX_DWORD)count >= used_bytes);
422 if (used_bytes == count) { 422 if (used_bytes == count) {
423 m_SrcOffset ++; 423 m_SrcOffset ++;
424 GetNextOperator(); 424 GetNextOperator();
425 return; 425 return;
426 } 426 }
427 count -= used_bytes; 427 count -= used_bytes;
428 m_Operator = 257 - count; 428 m_Operator = 257 - count;
429 } 429 }
430 ICodec_ScanlineDecoder* CCodec_BasicModule::CreateRunLengthDecoder(FX_LPCBYTE sr c_buf, FX_DWORD src_size, int width, int height, 430 ICodec_ScanlineDecoder* CCodec_BasicModule::CreateRunLengthDecoder(const uint8_t * src_buf, FX_DWORD src_size, int width, int height,
431 int nComps, int bpc) 431 int nComps, int bpc)
432 { 432 {
433 CCodec_RLScanlineDecoder* pRLScanlineDecoder = new CCodec_RLScanlineDecoder; 433 CCodec_RLScanlineDecoder* pRLScanlineDecoder = new CCodec_RLScanlineDecoder;
434 if (!pRLScanlineDecoder->Create(src_buf, src_size, width, height, nComps, bp c)) { 434 if (!pRLScanlineDecoder->Create(src_buf, src_size, width, height, nComps, bp c)) {
435 delete pRLScanlineDecoder; 435 delete pRLScanlineDecoder;
436 return NULL; 436 return NULL;
437 } 437 }
438 return pRLScanlineDecoder; 438 return pRLScanlineDecoder;
439 } 439 }
OLDNEW
« no previous file with comments | « core/src/fxcodec/codec/codec_int.h ('k') | core/src/fxcodec/codec/fx_codec_fax.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698