summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/media/stagefright/YUVImage.h12
-rw-r--r--media/libstagefright/yuv/YUVImage.cpp9
2 files changed, 17 insertions, 4 deletions
diff --git a/include/media/stagefright/YUVImage.h b/include/media/stagefright/YUVImage.h
index afeac3f..4e98618 100644
--- a/include/media/stagefright/YUVImage.h
+++ b/include/media/stagefright/YUVImage.h
@@ -67,18 +67,22 @@ public:
// memory.
static size_t bufferSize(YUVFormat yuvFormat, int32_t width, int32_t height);
- int32_t width() {return mWidth;}
- int32_t height() {return mHeight;}
+ int32_t width() const {return mWidth;}
+ int32_t height() const {return mHeight;}
+
+ // Returns true if pixel is the range [0, width-1] x [0, height-1]
+ // and false otherwise.
+ bool validPixel(int32_t x, int32_t y) const;
// Get the pixel YUV value at pixel (x,y).
// Note that the range of x is [0, width-1] and the range of y is [0, height-1].
- // Returns true if get was succesful and false otherwise.
+ // Returns true if get was successful and false otherwise.
bool getPixelValue(int32_t x, int32_t y,
uint8_t *yPtr, uint8_t *uPtr, uint8_t *vPtr) const;
// Set the pixel YUV value at pixel (x,y).
// Note that the range of x is [0, width-1] and the range of y is [0, height-1].
- // Returns true if set was succesful and false otherwise.
+ // Returns true if set was successful and false otherwise.
bool setPixelValue(int32_t x, int32_t y,
uint8_t yValue, uint8_t uValue, uint8_t vValue);
diff --git a/media/libstagefright/yuv/YUVImage.cpp b/media/libstagefright/yuv/YUVImage.cpp
index 73e3297..b712062 100644
--- a/media/libstagefright/yuv/YUVImage.cpp
+++ b/media/libstagefright/yuv/YUVImage.cpp
@@ -155,8 +155,15 @@ bool YUVImage::getYUVAddresses(int32_t x, int32_t y,
return true;
}
+bool YUVImage::validPixel(int32_t x, int32_t y) const {
+ return (x >= 0 && x < mWidth &&
+ y >= 0 && y < mHeight);
+}
+
bool YUVImage::getPixelValue(int32_t x, int32_t y,
uint8_t *yPtr, uint8_t *uPtr, uint8_t *vPtr) const {
+ CHECK(validPixel(x, y));
+
uint8_t *yAddr;
uint8_t *uAddr;
uint8_t *vAddr;
@@ -171,6 +178,8 @@ bool YUVImage::getPixelValue(int32_t x, int32_t y,
bool YUVImage::setPixelValue(int32_t x, int32_t y,
uint8_t yValue, uint8_t uValue, uint8_t vValue) {
+ CHECK(validPixel(x, y));
+
uint8_t *yAddr;
uint8_t *uAddr;
uint8_t *vAddr;