OLD | NEW |
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 "core/fxcodec/codec/include/ccodec_progressivedecoder.h" | 7 #include "core/fxcodec/codec/include/ccodec_progressivedecoder.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 for (; i < width; i++, j += 3) { | 30 for (; i < width; i++, j += 3) { |
31 temp = buffer[j]; | 31 temp = buffer[j]; |
32 buffer[j] = buffer[j + 2]; | 32 buffer[j] = buffer[j + 2]; |
33 buffer[j + 2] = temp; | 33 buffer[j + 2] = temp; |
34 } | 34 } |
35 } | 35 } |
36 } | 36 } |
37 | 37 |
38 } // namespace | 38 } // namespace |
39 | 39 |
| 40 CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::CFXCODEC_WeightTable() {} |
| 41 |
| 42 CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::~CFXCODEC_WeightTable() {} |
| 43 |
40 void CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::Calc(int dest_len, | 44 void CCodec_ProgressiveDecoder::CFXCODEC_WeightTable::Calc(int dest_len, |
41 int dest_min, | 45 int dest_min, |
42 int dest_max, | 46 int dest_max, |
43 int src_len, | 47 int src_len, |
44 int src_min, | 48 int src_min, |
45 int src_max, | 49 int src_max, |
46 FX_BOOL bInterpol) { | 50 FX_BOOL bInterpol) { |
47 double scale, base; | 51 double scale, base; |
48 scale = (FX_FLOAT)src_len / (FX_FLOAT)dest_len; | 52 scale = (FX_FLOAT)src_len / (FX_FLOAT)dest_len; |
49 if (dest_len < 0) { | 53 if (dest_len < 0) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 if (weight == 0 && j == end_i) { | 133 if (weight == 0 && j == end_i) { |
130 pixel_weights.m_SrcEnd--; | 134 pixel_weights.m_SrcEnd--; |
131 break; | 135 break; |
132 } | 136 } |
133 pixel_weights.m_Weights[j - start_i] = | 137 pixel_weights.m_Weights[j - start_i] = |
134 FXSYS_round((FX_FLOAT)(weight * 65536)); | 138 FXSYS_round((FX_FLOAT)(weight * 65536)); |
135 } | 139 } |
136 } | 140 } |
137 } | 141 } |
138 | 142 |
| 143 CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::CFXCODEC_HorzTable() {} |
| 144 |
| 145 CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::~CFXCODEC_HorzTable() {} |
| 146 |
139 void CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::Calc(int dest_len, | 147 void CCodec_ProgressiveDecoder::CFXCODEC_HorzTable::Calc(int dest_len, |
140 int src_len, | 148 int src_len, |
141 FX_BOOL bInterpol) { | 149 FX_BOOL bInterpol) { |
142 double scale = (double)dest_len / (double)src_len; | 150 double scale = (double)dest_len / (double)src_len; |
143 m_ItemSize = sizeof(int) * 4; | 151 m_ItemSize = sizeof(int) * 4; |
144 int size = dest_len * m_ItemSize + 4; | 152 int size = dest_len * m_ItemSize + 4; |
145 m_pWeightTables.resize(size, 0); | 153 m_pWeightTables.resize(size, 0); |
146 if (scale > 1) { | 154 if (scale > 1) { |
147 int pre_des_col = 0; | 155 int pre_des_col = 0; |
148 for (int src_col = 0; src_col < src_len; src_col++) { | 156 for (int src_col = 0; src_col < src_len; src_col++) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 for (int des_col = 0; des_col < dest_len; des_col++) { | 190 for (int des_col = 0; des_col < dest_len; des_col++) { |
183 double src_col_f = des_col / scale; | 191 double src_col_f = des_col / scale; |
184 int src_col = FXSYS_round((FX_FLOAT)src_col_f); | 192 int src_col = FXSYS_round((FX_FLOAT)src_col_f); |
185 PixelWeight* pWeight = GetPixelWeight(des_col); | 193 PixelWeight* pWeight = GetPixelWeight(des_col); |
186 pWeight->m_SrcStart = pWeight->m_SrcEnd = src_col; | 194 pWeight->m_SrcStart = pWeight->m_SrcEnd = src_col; |
187 pWeight->m_Weights[0] = 65536; | 195 pWeight->m_Weights[0] = 65536; |
188 pWeight->m_Weights[1] = 0; | 196 pWeight->m_Weights[1] = 0; |
189 } | 197 } |
190 } | 198 } |
191 | 199 |
| 200 CCodec_ProgressiveDecoder::CFXCODEC_VertTable::CFXCODEC_VertTable() {} |
| 201 |
| 202 CCodec_ProgressiveDecoder::CFXCODEC_VertTable::~CFXCODEC_VertTable() {} |
| 203 |
192 void CCodec_ProgressiveDecoder::CFXCODEC_VertTable::Calc(int dest_len, | 204 void CCodec_ProgressiveDecoder::CFXCODEC_VertTable::Calc(int dest_len, |
193 int src_len) { | 205 int src_len) { |
194 double scale = (double)dest_len / (double)src_len; | 206 double scale = (double)dest_len / (double)src_len; |
195 m_ItemSize = sizeof(int) * 4; | 207 m_ItemSize = sizeof(int) * 4; |
196 int size = dest_len * m_ItemSize + 4; | 208 int size = dest_len * m_ItemSize + 4; |
197 m_pWeightTables.resize(size, 0); | 209 m_pWeightTables.resize(size, 0); |
198 if (scale <= 1) { | 210 if (scale <= 1) { |
199 for (int des_row = 0; des_row < dest_len; des_row++) { | 211 for (int des_row = 0; des_row < dest_len; des_row++) { |
200 PixelWeight* pWeight = GetPixelWeight(des_row); | 212 PixelWeight* pWeight = GetPixelWeight(des_row); |
201 pWeight->m_SrcStart = des_row; | 213 pWeight->m_SrcStart = des_row; |
(...skipping 2149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2351 return m_status; | 2363 return m_status; |
2352 } | 2364 } |
2353 default: | 2365 default: |
2354 return FXCODEC_STATUS_ERROR; | 2366 return FXCODEC_STATUS_ERROR; |
2355 } | 2367 } |
2356 } | 2368 } |
2357 | 2369 |
2358 CCodec_ProgressiveDecoder* CCodec_ModuleMgr::CreateProgressiveDecoder() { | 2370 CCodec_ProgressiveDecoder* CCodec_ModuleMgr::CreateProgressiveDecoder() { |
2359 return new CCodec_ProgressiveDecoder(this); | 2371 return new CCodec_ProgressiveDecoder(this); |
2360 } | 2372 } |
OLD | NEW |