Index: core/src/fxcodec/jbig2/JBig2_Image.cpp |
diff --git a/core/src/fxcodec/jbig2/JBig2_Image.cpp b/core/src/fxcodec/jbig2/JBig2_Image.cpp |
index 772e4e5f62084b0f7dd11961d23c227cc7baf2f5..f1adfc6152f1a3e2068af00aaf0eeb335328dbda 100644 |
--- a/core/src/fxcodec/jbig2/JBig2_Image.cpp |
+++ b/core/src/fxcodec/jbig2/JBig2_Image.cpp |
@@ -129,547 +129,7 @@ FX_BOOL CJBig2_Image::composeTo(CJBig2_Image* pDst, |
} |
return composeTo_opt2(pDst, x, y, op, pSrcRect); |
} |
-FX_BOOL CJBig2_Image::composeTo_unopt(CJBig2_Image* pDst, |
- int32_t x, |
- int32_t y, |
- JBig2ComposeOp op) { |
- int32_t w, h, dx, dy; |
- int32_t i, j; |
- w = m_nWidth; |
- h = m_nHeight; |
- dx = dy = 0; |
- if (x < 0) { |
- dx += -x; |
- w -= -x; |
- x = 0; |
- } |
- if (y < 0) { |
- dy += -y; |
- h -= -y; |
- y = 0; |
- } |
- if (x + w > pDst->m_nWidth) { |
- w = pDst->m_nWidth - x; |
- } |
- if (y + h > pDst->m_nHeight) { |
- h = pDst->m_nHeight - y; |
- } |
- switch (op) { |
- case JBIG2_COMPOSE_OR: |
- for (j = 0; j < h; j++) { |
- for (i = 0; i < w; i++) { |
- pDst->setPixel( |
- x + i, y + j, |
- (getPixel(i + dx, j + dy) | pDst->getPixel(x + i, y + j)) & 1); |
- } |
- } |
- break; |
- case JBIG2_COMPOSE_AND: |
- for (j = 0; j < h; j++) { |
- for (i = 0; i < w; i++) { |
- pDst->setPixel( |
- x + i, y + j, |
- (getPixel(i + dx, j + dy) & pDst->getPixel(x + i, y + j)) & 1); |
- } |
- } |
- break; |
- case JBIG2_COMPOSE_XOR: |
- for (j = 0; j < h; j++) { |
- for (i = 0; i < w; i++) { |
- pDst->setPixel( |
- x + i, y + j, |
- (getPixel(i + dx, j + dy) ^ pDst->getPixel(x + i, y + j)) & 1); |
- } |
- } |
- break; |
- case JBIG2_COMPOSE_XNOR: |
- for (j = 0; j < h; j++) { |
- for (i = 0; i < w; i++) { |
- pDst->setPixel( |
- x + i, y + j, |
- (~(getPixel(i + dx, j + dy) ^ pDst->getPixel(x + i, y + j))) & 1); |
- } |
- } |
- break; |
- case JBIG2_COMPOSE_REPLACE: |
- for (j = 0; j < h; j++) { |
- for (i = 0; i < w; i++) { |
- pDst->setPixel(x + i, y + j, getPixel(i + dx, j + dy)); |
- } |
- } |
- break; |
- } |
- return TRUE; |
-} |
-FX_BOOL CJBig2_Image::composeTo_opt(CJBig2_Image* pDst, |
- int32_t x, |
- int32_t y, |
- JBig2ComposeOp op) { |
- int32_t x0, x1, y0, y1, xx, yy; |
- uint8_t *pLineSrc, *pLineDst, *srcPtr, *destPtr; |
- FX_DWORD src0, src1, src, dest, s1, s2, m1, m2, m3; |
- FX_BOOL oneByte; |
- if (!m_pData) { |
- return FALSE; |
- } |
- if (y < 0) { |
- y0 = -y; |
- } else { |
- y0 = 0; |
- } |
- if (y + m_nHeight > pDst->m_nHeight) { |
- y1 = pDst->m_nHeight - y; |
- } else { |
- y1 = m_nHeight; |
- } |
- if (y0 >= y1) { |
- return FALSE; |
- } |
- if (x >= 0) { |
- x0 = x & ~7; |
- } else { |
- x0 = 0; |
- } |
- x1 = x + m_nWidth; |
- if (x1 > pDst->m_nWidth) { |
- x1 = pDst->m_nWidth; |
- } |
- if (x0 >= x1) { |
- return FALSE; |
- } |
- s1 = x & 7; |
- s2 = 8 - s1; |
- m1 = 0xff >> (x1 & 7); |
- m2 = 0xff << (((x1 & 7) == 0) ? 0 : 8 - (x1 & 7)); |
- m3 = (0xff >> s1) & m2; |
- oneByte = x0 == ((x1 - 1) & ~7); |
- pLineDst = pDst->m_pData + y * pDst->m_nStride; |
- pLineSrc = m_pData + y0 * m_nStride; |
- if (oneByte) { |
- if (x >= 0) { |
- switch (op) { |
- case JBIG2_COMPOSE_OR: { |
- for (yy = y0; yy < y1; ++yy) { |
- destPtr = pLineDst + (x >> 3); |
- srcPtr = pLineSrc; |
- dest = *destPtr; |
- dest |= (*srcPtr >> s1) & m2; |
- *destPtr = (uint8_t)dest; |
- pLineDst += pDst->m_nStride; |
- pLineSrc += m_nStride; |
- } |
- } break; |
- case JBIG2_COMPOSE_AND: { |
- for (yy = y0; yy < y1; ++yy) { |
- destPtr = pLineDst + (x >> 3); |
- srcPtr = pLineSrc; |
- dest = *destPtr; |
- dest &= ((0xff00 | *srcPtr) >> s1) | m1; |
- *destPtr = (uint8_t)dest; |
- pLineDst += pDst->m_nStride; |
- pLineSrc += m_nStride; |
- } |
- } break; |
- case JBIG2_COMPOSE_XOR: { |
- for (yy = y0; yy < y1; ++yy) { |
- destPtr = pLineDst + (x >> 3); |
- srcPtr = pLineSrc; |
- dest = *destPtr; |
- dest ^= (*srcPtr >> s1) & m2; |
- *destPtr = (uint8_t)dest; |
- pLineDst += pDst->m_nStride; |
- pLineSrc += m_nStride; |
- } |
- } break; |
- case JBIG2_COMPOSE_XNOR: { |
- for (yy = y0; yy < y1; ++yy) { |
- destPtr = pLineDst + (x >> 3); |
- srcPtr = pLineSrc; |
- dest = *destPtr; |
- dest ^= ((*srcPtr ^ 0xff) >> s1) & m2; |
- *destPtr = (uint8_t)dest; |
- pLineDst += pDst->m_nStride; |
- pLineSrc += m_nStride; |
- } |
- } break; |
- case JBIG2_COMPOSE_REPLACE: { |
- for (yy = y0; yy < y1; ++yy) { |
- destPtr = pLineDst + (x >> 3); |
- srcPtr = pLineSrc; |
- dest = *destPtr; |
- dest = (dest & ~m3) | ((*srcPtr >> s1) & m3); |
- *destPtr = (uint8_t)dest; |
- pLineDst += pDst->m_nStride; |
- pLineSrc += m_nStride; |
- } |
- } break; |
- } |
- } else { |
- switch (op) { |
- case JBIG2_COMPOSE_OR: { |
- for (yy = y0; yy < y1; ++yy) { |
- destPtr = pLineDst; |
- srcPtr = pLineSrc + (-x >> 3); |
- dest = *destPtr; |
- dest |= *srcPtr & m2; |
- *destPtr = (uint8_t)dest; |
- pLineDst += pDst->m_nStride; |
- pLineSrc += m_nStride; |
- } |
- } break; |
- case JBIG2_COMPOSE_AND: { |
- for (yy = y0; yy < y1; ++yy) { |
- destPtr = pLineDst; |
- srcPtr = pLineSrc + (-x >> 3); |
- dest = *destPtr; |
- dest &= *srcPtr | m1; |
- *destPtr = (uint8_t)dest; |
- pLineDst += pDst->m_nStride; |
- pLineSrc += m_nStride; |
- } |
- } break; |
- case JBIG2_COMPOSE_XOR: { |
- for (yy = y0; yy < y1; ++yy) { |
- destPtr = pLineDst; |
- srcPtr = pLineSrc + (-x >> 3); |
- dest = *destPtr; |
- dest ^= *srcPtr & m2; |
- *destPtr = (uint8_t)dest; |
- pLineDst += pDst->m_nStride; |
- pLineSrc += m_nStride; |
- } |
- } break; |
- case JBIG2_COMPOSE_XNOR: { |
- for (yy = y0; yy < y1; ++yy) { |
- destPtr = pLineDst; |
- srcPtr = pLineSrc + (-x >> 3); |
- dest = *destPtr; |
- dest ^= (*srcPtr ^ 0xff) & m2; |
- *destPtr = (uint8_t)dest; |
- pLineDst += pDst->m_nStride; |
- pLineSrc += m_nStride; |
- } |
- } break; |
- case JBIG2_COMPOSE_REPLACE: { |
- for (yy = y0; yy < y1; ++yy) { |
- destPtr = pLineDst; |
- srcPtr = pLineSrc + (-x >> 3); |
- dest = *destPtr; |
- dest = (*srcPtr & m2) | (dest & m1); |
- *destPtr = (uint8_t)dest; |
- pLineDst += pDst->m_nStride; |
- pLineSrc += m_nStride; |
- } |
- } break; |
- } |
- } |
- } else { |
- if (x >= 0) { |
- switch (op) { |
- case JBIG2_COMPOSE_OR: { |
- for (yy = y0; yy < y1; ++yy) { |
- destPtr = pLineDst + (x >> 3); |
- srcPtr = pLineSrc; |
- src1 = *srcPtr++; |
- dest = *destPtr; |
- dest |= src1 >> s1; |
- *destPtr++ = (uint8_t)dest; |
- xx = x0 + 8; |
- for (; xx < x1 - 8; xx += 8) { |
- dest = *destPtr; |
- src0 = src1; |
- src1 = *srcPtr++; |
- src = (((src0 << 8) | src1) >> s1) & 0xff; |
- dest |= src; |
- *destPtr++ = (uint8_t)dest; |
- } |
- dest = *destPtr; |
- src0 = src1; |
- if (srcPtr - pLineSrc < m_nStride) { |
- src1 = *srcPtr++; |
- } else { |
- src1 = 0; |
- } |
- src = (((src0 << 8) | src1) >> s1) & 0xff; |
- dest |= src & m2; |
- *destPtr = (uint8_t)dest; |
- pLineDst += pDst->m_nStride; |
- pLineSrc += m_nStride; |
- } |
- } break; |
- case JBIG2_COMPOSE_AND: { |
- for (yy = y0; yy < y1; ++yy) { |
- destPtr = pLineDst + (x >> 3); |
- srcPtr = pLineSrc; |
- src1 = *srcPtr++; |
- dest = *destPtr; |
- dest &= (0xff00 | src1) >> s1; |
- *destPtr++ = (uint8_t)dest; |
- xx = x0 + 8; |
- for (; xx < x1 - 8; xx += 8) { |
- dest = *destPtr; |
- src0 = src1; |
- src1 = *srcPtr++; |
- src = (((src0 << 8) | src1) >> s1) & 0xff; |
- dest &= src; |
- *destPtr++ = (uint8_t)dest; |
- } |
- dest = *destPtr; |
- src0 = src1; |
- if (srcPtr - pLineSrc < m_nStride) { |
- src1 = *srcPtr++; |
- } else { |
- src1 = 0; |
- } |
- src = (((src0 << 8) | src1) >> s1) & 0xff; |
- dest &= src | m1; |
- *destPtr = (uint8_t)dest; |
- pLineDst += pDst->m_nStride; |
- pLineSrc += m_nStride; |
- } |
- } break; |
- case JBIG2_COMPOSE_XOR: { |
- for (yy = y0; yy < y1; ++yy) { |
- destPtr = pLineDst + (x >> 3); |
- srcPtr = pLineSrc; |
- src1 = *srcPtr++; |
- dest = *destPtr; |
- dest ^= src1 >> s1; |
- *destPtr++ = (uint8_t)dest; |
- xx = x0 + 8; |
- for (; xx < x1 - 8; xx += 8) { |
- dest = *destPtr; |
- src0 = src1; |
- src1 = *srcPtr++; |
- src = (((src0 << 8) | src1) >> s1) & 0xff; |
- dest ^= src; |
- *destPtr++ = (uint8_t)dest; |
- } |
- dest = *destPtr; |
- src0 = src1; |
- if (srcPtr - pLineSrc < m_nStride) { |
- src1 = *srcPtr++; |
- } else { |
- src1 = 0; |
- } |
- src = (((src0 << 8) | src1) >> s1) & 0xff; |
- dest ^= src & m2; |
- *destPtr = (uint8_t)dest; |
- pLineDst += pDst->m_nStride; |
- pLineSrc += m_nStride; |
- } |
- } break; |
- case JBIG2_COMPOSE_XNOR: { |
- for (yy = y0; yy < y1; ++yy) { |
- destPtr = pLineDst + (x >> 3); |
- srcPtr = pLineSrc; |
- src1 = *srcPtr++; |
- dest = *destPtr; |
- dest ^= (src1 ^ 0xff) >> s1; |
- *destPtr++ = (uint8_t)dest; |
- xx = x0 + 8; |
- for (; xx < x1 - 8; xx += 8) { |
- dest = *destPtr; |
- src0 = src1; |
- src1 = *srcPtr++; |
- src = (((src0 << 8) | src1) >> s1) & 0xff; |
- dest ^= src ^ 0xff; |
- *destPtr++ = (uint8_t)dest; |
- } |
- dest = *destPtr; |
- src0 = src1; |
- if (srcPtr - pLineSrc < m_nStride) { |
- src1 = *srcPtr++; |
- } else { |
- src1 = 0; |
- } |
- src = (((src0 << 8) | src1) >> s1) & 0xff; |
- dest ^= (src ^ 0xff) & m2; |
- *destPtr = (uint8_t)dest; |
- pLineDst += pDst->m_nStride; |
- pLineSrc += m_nStride; |
- } |
- } break; |
- case JBIG2_COMPOSE_REPLACE: { |
- for (yy = y0; yy < y1; ++yy) { |
- destPtr = pLineDst + (x >> 3); |
- srcPtr = pLineSrc; |
- src1 = *srcPtr++; |
- dest = *destPtr; |
- dest = (dest & (0xff << s2)) | (src1 >> s1); |
- *destPtr++ = (uint8_t)dest; |
- xx = x0 + 8; |
- for (; xx < x1 - 8; xx += 8) { |
- dest = *destPtr; |
- src0 = src1; |
- src1 = *srcPtr++; |
- src = (((src0 << 8) | src1) >> s1) & 0xff; |
- dest = src; |
- *destPtr++ = (uint8_t)dest; |
- } |
- dest = *destPtr; |
- src0 = src1; |
- if (srcPtr - pLineSrc < m_nStride) { |
- src1 = *srcPtr++; |
- } else { |
- src1 = 0; |
- } |
- src = (((src0 << 8) | src1) >> s1) & 0xff; |
- dest = (src & m2) | (dest & m1); |
- *destPtr = (uint8_t)dest; |
- pLineDst += pDst->m_nStride; |
- pLineSrc += m_nStride; |
- } |
- } break; |
- } |
- } else { |
- switch (op) { |
- case JBIG2_COMPOSE_OR: { |
- for (yy = y0; yy < y1; ++yy) { |
- destPtr = pLineDst; |
- srcPtr = pLineSrc + (-x >> 3); |
- src1 = *srcPtr++; |
- xx = x0; |
- for (; xx < x1 - 8; xx += 8) { |
- dest = *destPtr; |
- src0 = src1; |
- src1 = *srcPtr++; |
- src = (((src0 << 8) | src1) >> s1) & 0xff; |
- dest |= src; |
- *destPtr++ = (uint8_t)dest; |
- } |
- dest = *destPtr; |
- src0 = src1; |
- if (srcPtr - pLineSrc < m_nStride) { |
- src1 = *srcPtr++; |
- } else { |
- src1 = 0; |
- } |
- src = (((src0 << 8) | src1) >> s1) & 0xff; |
- dest |= src & m2; |
- *destPtr = (uint8_t)dest; |
- pLineDst += pDst->m_nStride; |
- pLineSrc += m_nStride; |
- } |
- } break; |
- case JBIG2_COMPOSE_AND: { |
- for (yy = y0; yy < y1; ++yy) { |
- destPtr = pLineDst; |
- srcPtr = pLineSrc + (-x >> 3); |
- src1 = *srcPtr++; |
- xx = x0; |
- for (; xx < x1 - 8; xx += 8) { |
- dest = *destPtr; |
- src0 = src1; |
- src1 = *srcPtr++; |
- src = (((src0 << 8) | src1) >> s1) & 0xff; |
- dest &= src; |
- *destPtr++ = (uint8_t)dest; |
- } |
- dest = *destPtr; |
- src0 = src1; |
- if (srcPtr - pLineSrc < m_nStride) { |
- src1 = *srcPtr++; |
- } else { |
- src1 = 0; |
- } |
- src = (((src0 << 8) | src1) >> s1) & 0xff; |
- dest &= src | m1; |
- *destPtr = (uint8_t)dest; |
- pLineDst += pDst->m_nStride; |
- pLineSrc += m_nStride; |
- } |
- } break; |
- case JBIG2_COMPOSE_XOR: { |
- for (yy = y0; yy < y1; ++yy) { |
- destPtr = pLineDst; |
- srcPtr = pLineSrc + (-x >> 3); |
- src1 = *srcPtr++; |
- xx = x0; |
- for (; xx < x1 - 8; xx += 8) { |
- dest = *destPtr; |
- src0 = src1; |
- src1 = *srcPtr++; |
- src = (((src0 << 8) | src1) >> s1) & 0xff; |
- dest ^= src; |
- *destPtr++ = (uint8_t)dest; |
- } |
- dest = *destPtr; |
- src0 = src1; |
- if (srcPtr - pLineSrc < m_nStride) { |
- src1 = *srcPtr++; |
- } else { |
- src1 = 0; |
- } |
- src = (((src0 << 8) | src1) >> s1) & 0xff; |
- dest ^= src & m2; |
- *destPtr = (uint8_t)dest; |
- pLineDst += pDst->m_nStride; |
- pLineSrc += m_nStride; |
- } |
- } break; |
- case JBIG2_COMPOSE_XNOR: { |
- for (yy = y0; yy < y1; ++yy) { |
- destPtr = pLineDst; |
- srcPtr = pLineSrc + (-x >> 3); |
- src1 = *srcPtr++; |
- xx = x0; |
- for (; xx < x1 - 8; xx += 8) { |
- dest = *destPtr; |
- src0 = src1; |
- src1 = *srcPtr++; |
- src = (((src0 << 8) | src1) >> s1) & 0xff; |
- dest ^= src ^ 0xff; |
- *destPtr++ = (uint8_t)dest; |
- } |
- dest = *destPtr; |
- src0 = src1; |
- if (srcPtr - pLineSrc < m_nStride) { |
- src1 = *srcPtr++; |
- } else { |
- src1 = 0; |
- } |
- src = (((src0 << 8) | src1) >> s1) & 0xff; |
- dest ^= (src ^ 0xff) & m2; |
- *destPtr = (uint8_t)dest; |
- pLineDst += pDst->m_nStride; |
- pLineSrc += m_nStride; |
- } |
- } break; |
- case JBIG2_COMPOSE_REPLACE: { |
- for (yy = y0; yy < y1; ++yy) { |
- destPtr = pLineDst; |
- srcPtr = pLineSrc + (-x >> 3); |
- src1 = *srcPtr++; |
- xx = x0; |
- for (; xx < x1 - 8; xx += 8) { |
- dest = *destPtr; |
- src0 = src1; |
- src1 = *srcPtr++; |
- src = (((src0 << 8) | src1) >> s1) & 0xff; |
- dest = src; |
- *destPtr++ = (uint8_t)dest; |
- } |
- dest = *destPtr; |
- src0 = src1; |
- if (srcPtr - pLineSrc < m_nStride) { |
- src1 = *srcPtr++; |
- } else { |
- src1 = 0; |
- } |
- src = (((src0 << 8) | src1) >> s1) & 0xff; |
- dest = (src & m2) | (dest & m1); |
- *destPtr = (uint8_t)dest; |
- pLineDst += pDst->m_nStride; |
- pLineSrc += m_nStride; |
- } |
- } break; |
- } |
- } |
- } |
- return TRUE; |
-} |
FX_BOOL CJBig2_Image::composeFrom(int32_t x, |
int32_t y, |
CJBig2_Image* pSrc, |
@@ -689,20 +149,6 @@ FX_BOOL CJBig2_Image::composeFrom(int32_t x, |
} |
return pSrc->composeTo(this, x, y, op, pSrcRect); |
} |
-CJBig2_Image* CJBig2_Image::subImage_unopt(int32_t x, |
- int32_t y, |
- int32_t w, |
- int32_t h) { |
- CJBig2_Image* pImage; |
- int32_t i, j; |
- JBIG2_ALLOC(pImage, CJBig2_Image(w, h)); |
- for (j = 0; j < h; j++) { |
- for (i = 0; i < w; i++) { |
- pImage->setPixel(i, j, getPixel(x + i, y + j)); |
- } |
- } |
- return pImage; |
-} |
#define JBIG2_GETDWORD(buf) \ |
((FX_DWORD)(((buf)[0] << 24) | ((buf)[1] << 16) | ((buf)[2] << 8) | (buf)[3])) |
CJBig2_Image* CJBig2_Image::subImage(int32_t x, |