Loading core/jni/android/graphics/YuvToJpegEncoder.cpp +10 −4 Original line number Diff line number Diff line Loading @@ -90,8 +90,9 @@ void Yuv420SpToJpegEncoder::compress(jpeg_compress_struct* cinfo, // process 16 lines of Y and 8 lines of U/V each time. while (cinfo->next_scanline < cinfo->image_height) { //deitnerleave u and v deinterleave(vuPlanar, uRows, vRows, cinfo->next_scanline, width); deinterleave(vuPlanar, uRows, vRows, cinfo->next_scanline, width, height); // Jpeg library ignores the rows whose indices are greater than height. for (int i = 0; i < 16; i++) { // y row y[i] = yPlanar + (cinfo->next_scanline + i) * fStrides[0]; Loading @@ -112,8 +113,10 @@ void Yuv420SpToJpegEncoder::compress(jpeg_compress_struct* cinfo, } void Yuv420SpToJpegEncoder::deinterleave(uint8_t* vuPlanar, uint8_t* uRows, uint8_t* vRows, int rowIndex, int width) { for (int row = 0; row < 8; ++row) { uint8_t* vRows, int rowIndex, int width, int height) { int numRows = (height - rowIndex) / 2; if (numRows > 8) numRows = 8; for (int row = 0; row < numRows; ++row) { int offset = ((rowIndex >> 1) + row) * fStrides[1]; uint8_t* vu = vuPlanar + offset; for (int i = 0; i < (width >> 1); ++i) { Loading Loading @@ -164,6 +167,7 @@ void Yuv422IToJpegEncoder::compress(jpeg_compress_struct* cinfo, while (cinfo->next_scanline < cinfo->image_height) { deinterleave(yuvOffset, yRows, uRows, vRows, cinfo->next_scanline, width, height); // Jpeg library ignores the rows whose indices are greater than height. for (int i = 0; i < 16; i++) { // y row y[i] = yRows + i * width; Loading @@ -185,7 +189,9 @@ void Yuv422IToJpegEncoder::compress(jpeg_compress_struct* cinfo, void Yuv422IToJpegEncoder::deinterleave(uint8_t* yuv, uint8_t* yRows, uint8_t* uRows, uint8_t* vRows, int rowIndex, int width, int height) { for (int row = 0; row < 16; ++row) { int numRows = height - rowIndex; if (numRows > 16) numRows = 16; for (int row = 0; row < numRows; ++row) { uint8_t* yuvSeg = yuv + (rowIndex + row) * fStrides[0]; for (int i = 0; i < (width >> 1); ++i) { int indexY = row * width + (i << 1); Loading core/jni/android/graphics/YuvToJpegEncoder.h +1 −1 Original line number Diff line number Diff line Loading @@ -55,7 +55,7 @@ private: void deinterleaveYuv(uint8_t* yuv, int width, int height, uint8_t*& yPlanar, uint8_t*& uPlanar, uint8_t*& vPlanar); void deinterleave(uint8_t* vuPlanar, uint8_t* uRows, uint8_t* vRows, int rowIndex, int width); int rowIndex, int width, int height); void compress(jpeg_compress_struct* cinfo, uint8_t* yuv, int* offsets); }; Loading Loading
core/jni/android/graphics/YuvToJpegEncoder.cpp +10 −4 Original line number Diff line number Diff line Loading @@ -90,8 +90,9 @@ void Yuv420SpToJpegEncoder::compress(jpeg_compress_struct* cinfo, // process 16 lines of Y and 8 lines of U/V each time. while (cinfo->next_scanline < cinfo->image_height) { //deitnerleave u and v deinterleave(vuPlanar, uRows, vRows, cinfo->next_scanline, width); deinterleave(vuPlanar, uRows, vRows, cinfo->next_scanline, width, height); // Jpeg library ignores the rows whose indices are greater than height. for (int i = 0; i < 16; i++) { // y row y[i] = yPlanar + (cinfo->next_scanline + i) * fStrides[0]; Loading @@ -112,8 +113,10 @@ void Yuv420SpToJpegEncoder::compress(jpeg_compress_struct* cinfo, } void Yuv420SpToJpegEncoder::deinterleave(uint8_t* vuPlanar, uint8_t* uRows, uint8_t* vRows, int rowIndex, int width) { for (int row = 0; row < 8; ++row) { uint8_t* vRows, int rowIndex, int width, int height) { int numRows = (height - rowIndex) / 2; if (numRows > 8) numRows = 8; for (int row = 0; row < numRows; ++row) { int offset = ((rowIndex >> 1) + row) * fStrides[1]; uint8_t* vu = vuPlanar + offset; for (int i = 0; i < (width >> 1); ++i) { Loading Loading @@ -164,6 +167,7 @@ void Yuv422IToJpegEncoder::compress(jpeg_compress_struct* cinfo, while (cinfo->next_scanline < cinfo->image_height) { deinterleave(yuvOffset, yRows, uRows, vRows, cinfo->next_scanline, width, height); // Jpeg library ignores the rows whose indices are greater than height. for (int i = 0; i < 16; i++) { // y row y[i] = yRows + i * width; Loading @@ -185,7 +189,9 @@ void Yuv422IToJpegEncoder::compress(jpeg_compress_struct* cinfo, void Yuv422IToJpegEncoder::deinterleave(uint8_t* yuv, uint8_t* yRows, uint8_t* uRows, uint8_t* vRows, int rowIndex, int width, int height) { for (int row = 0; row < 16; ++row) { int numRows = height - rowIndex; if (numRows > 16) numRows = 16; for (int row = 0; row < numRows; ++row) { uint8_t* yuvSeg = yuv + (rowIndex + row) * fStrides[0]; for (int i = 0; i < (width >> 1); ++i) { int indexY = row * width + (i << 1); Loading
core/jni/android/graphics/YuvToJpegEncoder.h +1 −1 Original line number Diff line number Diff line Loading @@ -55,7 +55,7 @@ private: void deinterleaveYuv(uint8_t* yuv, int width, int height, uint8_t*& yPlanar, uint8_t*& uPlanar, uint8_t*& vPlanar); void deinterleave(uint8_t* vuPlanar, uint8_t* uRows, uint8_t* vRows, int rowIndex, int width); int rowIndex, int width, int height); void compress(jpeg_compress_struct* cinfo, uint8_t* yuv, int* offsets); }; Loading