Loading include/media/stagefright/YUVCanvas.h +12 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,18 @@ public: int32_t destStartX, int32_t destStartY, const YUVImage &srcImage); // Downsamples the srcImage into the canvas' target image (mYUVImage) // The downsampling copies pixels from the source image starting at // (srcOffsetX, srcOffsetY) to the target image, starting at (0, 0). // For each X increment in the target image, skipX pixels are skipped // in the source image. // Similarly for each Y increment in the target image, skipY pixels // are skipped in the source image. void downsample( int32_t srcOffsetX, int32_t srcOffsetY, int32_t skipX, int32_t skipY, const YUVImage &srcImage); private: YUVImage& mYUVImage; Loading media/libstagefright/yuv/YUVCanvas.cpp +29 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #define LOG_NDEBUG 0 #define LOG_TAG "YUVCanvas" #include <media/stagefright/MediaDebug.h> #include <media/stagefright/YUVCanvas.h> #include <media/stagefright/YUVImage.h> #include <ui/Rect.h> Loading Loading @@ -80,4 +81,31 @@ void YUVCanvas::CopyImageRect( } } void YUVCanvas::downsample( int32_t srcOffsetX, int32_t srcOffsetY, int32_t skipX, int32_t skipY, const YUVImage &srcImage) { // TODO: Add a low pass filter for downsampling. // Check that srcImage is big enough to fill mYUVImage. CHECK((srcOffsetX + (mYUVImage.width() - 1) * skipX) < srcImage.width()); CHECK((srcOffsetY + (mYUVImage.height() - 1) * skipY) < srcImage.height()); uint8_t yValue; uint8_t uValue; uint8_t vValue; int32_t srcY = srcOffsetY; for (int32_t y = 0; y < mYUVImage.height(); ++y) { int32_t srcX = srcOffsetX; for (int32_t x = 0; x < mYUVImage.width(); ++x) { srcImage.getPixelValue(srcX, srcY, &yValue, &uValue, &vValue); mYUVImage.setPixelValue(x, y, yValue, uValue, vValue); srcX += skipX; } srcY += skipY; } } } // namespace android Loading
include/media/stagefright/YUVCanvas.h +12 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,18 @@ public: int32_t destStartX, int32_t destStartY, const YUVImage &srcImage); // Downsamples the srcImage into the canvas' target image (mYUVImage) // The downsampling copies pixels from the source image starting at // (srcOffsetX, srcOffsetY) to the target image, starting at (0, 0). // For each X increment in the target image, skipX pixels are skipped // in the source image. // Similarly for each Y increment in the target image, skipY pixels // are skipped in the source image. void downsample( int32_t srcOffsetX, int32_t srcOffsetY, int32_t skipX, int32_t skipY, const YUVImage &srcImage); private: YUVImage& mYUVImage; Loading
media/libstagefright/yuv/YUVCanvas.cpp +29 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ #define LOG_NDEBUG 0 #define LOG_TAG "YUVCanvas" #include <media/stagefright/MediaDebug.h> #include <media/stagefright/YUVCanvas.h> #include <media/stagefright/YUVImage.h> #include <ui/Rect.h> Loading Loading @@ -80,4 +81,31 @@ void YUVCanvas::CopyImageRect( } } void YUVCanvas::downsample( int32_t srcOffsetX, int32_t srcOffsetY, int32_t skipX, int32_t skipY, const YUVImage &srcImage) { // TODO: Add a low pass filter for downsampling. // Check that srcImage is big enough to fill mYUVImage. CHECK((srcOffsetX + (mYUVImage.width() - 1) * skipX) < srcImage.width()); CHECK((srcOffsetY + (mYUVImage.height() - 1) * skipY) < srcImage.height()); uint8_t yValue; uint8_t uValue; uint8_t vValue; int32_t srcY = srcOffsetY; for (int32_t y = 0; y < mYUVImage.height(); ++y) { int32_t srcX = srcOffsetX; for (int32_t x = 0; x < mYUVImage.width(); ++x) { srcImage.getPixelValue(srcX, srcY, &yValue, &uValue, &vValue); mYUVImage.setPixelValue(x, y, yValue, uValue, vValue); srcX += skipX; } srcY += skipY; } } } // namespace android