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

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

Issue 645793007: More fixes in sycc422_to_rgb and sycc420_to_rgb when image width is odd (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 6 years, 2 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 | « no previous file | no next file » | 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 #include "../fx_libopenjpeg/libopenjpeg20/openjpeg.h" 9 #include "../fx_libopenjpeg/libopenjpeg20/openjpeg.h"
10 #include "../lcms2/include/fx_lcms2.h" 10 #include "../lcms2/include/fx_lcms2.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 upb = (1 << i) - 1; 159 upb = (1 << i) - 1;
160 maxw = (int)img->comps[0].w; 160 maxw = (int)img->comps[0].w;
161 maxh = (int)img->comps[0].h; 161 maxh = (int)img->comps[0].h;
162 max = maxw * maxh; 162 max = maxw * maxh;
163 y = img->comps[0].data; 163 y = img->comps[0].data;
164 cb = img->comps[1].data; 164 cb = img->comps[1].data;
165 cr = img->comps[2].data; 165 cr = img->comps[2].data;
166 d0 = r = FX_Alloc(int, (size_t)max); 166 d0 = r = FX_Alloc(int, (size_t)max);
167 d1 = g = FX_Alloc(int, (size_t)max); 167 d1 = g = FX_Alloc(int, (size_t)max);
168 d2 = b = FX_Alloc(int, (size_t)max); 168 d2 = b = FX_Alloc(int, (size_t)max);
169 for(i = 0; i < maxh; ++i) { 169 for(i = 0; i < maxh; ++i)
170 for (j = 0; j < maxw; ++j, ++y, ++r, ++g, ++b) { 170 {
171 for (j = 0; (OPJ_UINT32)j < (maxw & ~(OPJ_UINT32)1); j += 2)
172 {
171 sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b); 173 sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
172 if (j % 2){ 174 ++y; ++r; ++g; ++b;
173 ++cb; 175 sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
174 ++cr; 176 ++y; ++r; ++g; ++b; ++cb; ++cr;
175 } 177 }
178 if (j < maxw)
179 {
180 sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
181 ++y; ++r; ++g; ++b; ++cb; ++cr;
176 } 182 }
177 } 183 }
178 FX_Free(img->comps[0].data); 184 FX_Free(img->comps[0].data);
179 img->comps[0].data = d0; 185 img->comps[0].data = d0;
180 FX_Free(img->comps[1].data); 186 FX_Free(img->comps[1].data);
181 img->comps[1].data = d1; 187 img->comps[1].data = d1;
182 FX_Free(img->comps[2].data); 188 FX_Free(img->comps[2].data);
183 img->comps[2].data = d2; 189 img->comps[2].data = d2;
184 img->comps[1].w = maxw; 190 img->comps[1].w = maxw;
185 img->comps[1].h = maxh; 191 img->comps[1].h = maxh;
(...skipping 19 matching lines...) Expand all
205 upb = (1 << i) - 1; 211 upb = (1 << i) - 1;
206 maxw = (int)img->comps[0].w; 212 maxw = (int)img->comps[0].w;
207 maxh = (int)img->comps[0].h; 213 maxh = (int)img->comps[0].h;
208 max = maxw * maxh; 214 max = maxw * maxh;
209 y = img->comps[0].data; 215 y = img->comps[0].data;
210 cb = img->comps[1].data; 216 cb = img->comps[1].data;
211 cr = img->comps[2].data; 217 cr = img->comps[2].data;
212 d0 = r = FX_Alloc(int, (size_t)max); 218 d0 = r = FX_Alloc(int, (size_t)max);
213 d1 = g = FX_Alloc(int, (size_t)max); 219 d1 = g = FX_Alloc(int, (size_t)max);
214 d2 = b = FX_Alloc(int, (size_t)max); 220 d2 = b = FX_Alloc(int, (size_t)max);
215 for(i = 0; i < maxh; i += 2) { 221 for (i = 0; (OPJ_UINT32)i < (maxh & ~(OPJ_UINT32)1); i += 2)
222 {
216 ny = y + maxw; 223 ny = y + maxw;
217 nr = r + maxw; 224 nr = r + maxw;
218 ng = g + maxw; 225 ng = g + maxw;
219 nb = b + maxw; 226 nb = b + maxw;
220 for(j = 0; j < maxw; j += 2) { 227 for (j = 0; (OPJ_UINT32)j < (maxw & ~(OPJ_UINT32)1); j += 2)
228 {
221 sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b); 229 sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
222 ++y; 230 ++y; ++r; ++g; ++b;
223 ++r;
224 ++g;
225 ++b;
226 sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b); 231 sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
227 ++y; 232 ++y; ++r; ++g; ++b;
228 ++r;
229 ++g;
230 ++b;
231 sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb); 233 sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
232 ++ny; 234 ++ny; ++nr; ++ng; ++nb;
233 ++nr;
234 ++ng;
235 ++nb;
236 sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb); 235 sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
237 ++ny; 236 ++ny; ++nr; ++ng; ++nb; ++cb; ++cr;
238 ++nr;
239 ++ng;
240 ++nb;
241 ++cb;
242 ++cr;
243 } 237 }
244 y += maxw; 238 if (j < maxw)
245 r += maxw; 239 {
246 g += maxw; 240 sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
247 b += maxw; 241 ++y; ++r; ++g; ++b;
242 sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
243 ++ny; ++nr; ++ng; ++nb; ++cb; ++cr;
244 }
245 y += maxw; r += maxw; g += maxw; b += maxw;
248 } 246 }
247 if (i < maxh)
248 {
249 for (j = 0; (OPJ_UINT32)j < (maxw & ~(OPJ_UINT32)1); j += 2)
250 {
251 sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
252 ++y; ++r; ++g; ++b;
253 sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
254 ++y; ++r; ++g; ++b; ++cb; ++cr;
255 }
256 if (j < maxw)
257 {
258 sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
259 }
260 }
261
249 FX_Free(img->comps[0].data); 262 FX_Free(img->comps[0].data);
250 img->comps[0].data = d0; 263 img->comps[0].data = d0;
251 FX_Free(img->comps[1].data); 264 FX_Free(img->comps[1].data);
252 img->comps[1].data = d1; 265 img->comps[1].data = d1;
253 FX_Free(img->comps[2].data); 266 FX_Free(img->comps[2].data);
254 img->comps[2].data = d2; 267 img->comps[2].data = d2;
255 img->comps[1].w = maxw; 268 img->comps[1].w = maxw;
256 img->comps[1].h = maxh; 269 img->comps[1].h = maxh;
257 img->comps[2].w = maxw; 270 img->comps[2].w = maxw;
258 img->comps[2].h = maxh; 271 img->comps[2].h = maxh;
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 FX_BOOL CCodec_JpxModule::Decode(void* ctx, FX_LPBYTE dest_data, int pitch, FX_B OOL bTranslateColor, FX_LPBYTE offsets) 785 FX_BOOL CCodec_JpxModule::Decode(void* ctx, FX_LPBYTE dest_data, int pitch, FX_B OOL bTranslateColor, FX_LPBYTE offsets)
773 { 786 {
774 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx; 787 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx;
775 return pDecoder->Decode(dest_data, pitch, bTranslateColor, offsets); 788 return pDecoder->Decode(dest_data, pitch, bTranslateColor, offsets);
776 } 789 }
777 void CCodec_JpxModule::DestroyDecoder(void* ctx) 790 void CCodec_JpxModule::DestroyDecoder(void* ctx)
778 { 791 {
779 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx; 792 CJPX_Decoder* pDecoder = (CJPX_Decoder*)ctx;
780 delete pDecoder; 793 delete pDecoder;
781 } 794 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698