mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Merge pull request #2117 from bitbank2/master
imlib/jpegd: Fix jpeg decode for non-multiple of 8.
This commit is contained in:
commit
b792c592b2
@ -2031,8 +2031,7 @@ static void JPEGPixel2LE(uint16_t *pDest, int iY1, int iY2, int iCb, int iCr) {
|
|||||||
static void JPEGPutMCU11(JPEGIMAGE *pJPEG, int x, int y) {
|
static void JPEGPutMCU11(JPEGIMAGE *pJPEG, int x, int y) {
|
||||||
int iCr, iCb;
|
int iCr, iCb;
|
||||||
signed int Y;
|
signed int Y;
|
||||||
int iCol;
|
int iCol, iRow, cx, cy;
|
||||||
int iRow;
|
|
||||||
const int iPitch = pJPEG->iWidth;
|
const int iPitch = pJPEG->iWidth;
|
||||||
uint8_t *pY, *pCr, *pCb;
|
uint8_t *pY, *pCr, *pCb;
|
||||||
uint16_t *pOutput = (uint16_t *) &pJPEG->pImage[(y * iPitch * 2) + x * 2];
|
uint16_t *pOutput = (uint16_t *) &pJPEG->pImage[(y * iPitch * 2) + x * 2];
|
||||||
@ -2090,15 +2089,23 @@ static void JPEGPutMCU11(JPEGIMAGE *pJPEG, int x, int y) {
|
|||||||
JPEGPixelLE(pOutput + 1 + iPitch, Y, iCb, iCr);
|
JPEGPixelLE(pOutput + 1 + iPitch, Y, iCb, iCr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (iRow = 0; iRow < 8; iRow++) {
|
cx = cy = 8; // assume full size fits
|
||||||
|
if (x + cx > pJPEG->iWidth) {
|
||||||
|
cx = pJPEG->iWidth - x;
|
||||||
|
}
|
||||||
|
if (y + cy > pJPEG->iHeight) {
|
||||||
|
cy = pJPEG->iHeight - y;
|
||||||
|
}
|
||||||
|
for (iRow = 0; iRow < cy; iRow++) {
|
||||||
// up to 8 rows to do
|
// up to 8 rows to do
|
||||||
for (iCol = 0; iCol < 8; iCol++) {
|
for (iCol = 0; iCol < cx; iCol++) {
|
||||||
// up to 4x2 cols to do
|
// up to 4x2 cols to do
|
||||||
iCr = *pCr++;
|
iCr = pCr[iCol];
|
||||||
iCb = *pCb++;
|
iCb = pCb[iCol];
|
||||||
Y = (int) (*pY++) << 12;
|
Y = (int) (pY[iCol]) << 12;
|
||||||
JPEGPixelLE(pOutput + iCol, Y, iCb, iCr);
|
JPEGPixelLE(pOutput + iCol, Y, iCb, iCr);
|
||||||
} // for col
|
} // for col
|
||||||
|
pCr += 8; pCb += 8; pY += 8; // next row
|
||||||
pOutput += iPitch;
|
pOutput += iPitch;
|
||||||
} // for row
|
} // for row
|
||||||
} /* JPEGPutMCU11() */
|
} /* JPEGPutMCU11() */
|
||||||
@ -2389,6 +2396,13 @@ static void JPEGPutMCU12(JPEGIMAGE *pJPEG, int x, int y) {
|
|||||||
/* Convert YCC pixels into RGB pixels and store in output image */
|
/* Convert YCC pixels into RGB pixels and store in output image */
|
||||||
iYCount = 16;
|
iYCount = 16;
|
||||||
iXCount = 8;
|
iXCount = 8;
|
||||||
|
// crop last MCU to reported image size
|
||||||
|
if (x + 8 > pJPEG->iWidth) {
|
||||||
|
iXCount = pJPEG->iWidth - x;
|
||||||
|
}
|
||||||
|
if (y + 16 > pJPEG->iHeight) {
|
||||||
|
iYCount = pJPEG->iHeight - y;
|
||||||
|
}
|
||||||
for (iRow = 0; iRow < iYCount; iRow += 2) {
|
for (iRow = 0; iRow < iYCount; iRow += 2) {
|
||||||
// up to 16 rows to do
|
// up to 16 rows to do
|
||||||
for (iCol = 0; iCol < iXCount; iCol++) {
|
for (iCol = 0; iCol < iXCount; iCol++) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user