summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorBo Xu <bo_xu@foxitsoftware.com>2014-10-21 12:17:39 -0700
committerBo Xu <bo_xu@foxitsoftware.com>2014-10-21 12:17:39 -0700
commitbff247d92c315f9aab2edb4aeaf0ef0b74ba321f (patch)
tree6965515b4a9e504d5b3088737981df01b0a400a5 /core
parentf71c2d02294fb3ceb7b19a93a6913f97c4ff2b7a (diff)
downloadpdfium-bff247d92c315f9aab2edb4aeaf0ef0b74ba321f.tar.xz
More fixes in sycc422_to_rgb and sycc420_to_rgb when image width is odd
This patch is supplementary to issue 418881 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/645793007
Diffstat (limited to 'core')
-rw-r--r--core/src/fxcodec/codec/fx_codec_jpx_opj.cpp95
1 files changed, 54 insertions, 41 deletions
diff --git a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
index 1180bfc102..8dcecf9061 100644
--- a/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
+++ b/core/src/fxcodec/codec/fx_codec_jpx_opj.cpp
@@ -166,13 +166,19 @@ static void sycc422_to_rgb(opj_image_t *img)
d0 = r = FX_Alloc(int, (size_t)max);
d1 = g = FX_Alloc(int, (size_t)max);
d2 = b = FX_Alloc(int, (size_t)max);
- for(i = 0; i < maxh; ++i) {
- for (j = 0; j < maxw; ++j, ++y, ++r, ++g, ++b) {
- sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
- if (j % 2){
- ++cb;
- ++cr;
- }
+ for(i = 0; i < maxh; ++i)
+ {
+ for (j = 0; (OPJ_UINT32)j < (maxw & ~(OPJ_UINT32)1); j += 2)
+ {
+ sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
+ ++y; ++r; ++g; ++b;
+ sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
+ ++y; ++r; ++g; ++b; ++cb; ++cr;
+ }
+ if (j < maxw)
+ {
+ sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
+ ++y; ++r; ++g; ++b; ++cb; ++cr;
}
}
FX_Free(img->comps[0].data);
@@ -212,40 +218,47 @@ static void sycc420_to_rgb(opj_image_t *img)
d0 = r = FX_Alloc(int, (size_t)max);
d1 = g = FX_Alloc(int, (size_t)max);
d2 = b = FX_Alloc(int, (size_t)max);
- for(i = 0; i < maxh; i += 2) {
- ny = y + maxw;
- nr = r + maxw;
- ng = g + maxw;
- nb = b + maxw;
- for(j = 0; j < maxw; j += 2) {
- sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
- ++y;
- ++r;
- ++g;
- ++b;
- sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
- ++y;
- ++r;
- ++g;
- ++b;
- sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
- ++ny;
- ++nr;
- ++ng;
- ++nb;
- sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
- ++ny;
- ++nr;
- ++ng;
- ++nb;
- ++cb;
- ++cr;
- }
- y += maxw;
- r += maxw;
- g += maxw;
- b += maxw;
- }
+ for (i = 0; (OPJ_UINT32)i < (maxh & ~(OPJ_UINT32)1); i += 2)
+ {
+ ny = y + maxw;
+ nr = r + maxw;
+ ng = g + maxw;
+ nb = b + maxw;
+ for (j = 0; (OPJ_UINT32)j < (maxw & ~(OPJ_UINT32)1); j += 2)
+ {
+ sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
+ ++y; ++r; ++g; ++b;
+ sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
+ ++y; ++r; ++g; ++b;
+ sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
+ ++ny; ++nr; ++ng; ++nb;
+ sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
+ ++ny; ++nr; ++ng; ++nb; ++cb; ++cr;
+ }
+ if (j < maxw)
+ {
+ sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
+ ++y; ++r; ++g; ++b;
+ sycc_to_rgb(offset, upb, *ny, *cb, *cr, nr, ng, nb);
+ ++ny; ++nr; ++ng; ++nb; ++cb; ++cr;
+ }
+ y += maxw; r += maxw; g += maxw; b += maxw;
+ }
+ if (i < maxh)
+ {
+ for (j = 0; (OPJ_UINT32)j < (maxw & ~(OPJ_UINT32)1); j += 2)
+ {
+ sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
+ ++y; ++r; ++g; ++b;
+ sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
+ ++y; ++r; ++g; ++b; ++cb; ++cr;
+ }
+ if (j < maxw)
+ {
+ sycc_to_rgb(offset, upb, *y, *cb, *cr, r, g, b);
+ }
+ }
+
FX_Free(img->comps[0].data);
img->comps[0].data = d0;
FX_Free(img->comps[1].data);