Index: source/libvpx/test/video_source.h |
diff --git a/source/libvpx/test/video_source.h b/source/libvpx/test/video_source.h |
index b97e1550e2f3af786ad47ca152bc5ba97e66ad7b..63294d14ae07e2debacae1a87cd61d7a865c12ba 100644 |
--- a/source/libvpx/test/video_source.h |
+++ b/source/libvpx/test/video_source.h |
@@ -134,8 +134,13 @@ class VideoSource { |
class DummyVideoSource : public VideoSource { |
public: |
- DummyVideoSource() : img_(NULL), limit_(100), width_(0), height_(0) { |
- SetSize(80, 64); |
+ DummyVideoSource() |
+ : img_(NULL), |
+ limit_(100), |
+ width_(80), |
+ height_(64), |
+ format_(VPX_IMG_FMT_I420) { |
+ ReallocImage(); |
} |
virtual ~DummyVideoSource() { vpx_img_free(img_); } |
@@ -174,23 +179,35 @@ class DummyVideoSource : public VideoSource { |
void SetSize(unsigned int width, unsigned int height) { |
if (width != width_ || height != height_) { |
- vpx_img_free(img_); |
- img_ = vpx_img_alloc(NULL, VPX_IMG_FMT_I420, width, height, 32); |
- raw_sz_ = ((img_->w + 31) & ~31) * img_->h * 3 / 2; |
width_ = width; |
height_ = height; |
+ ReallocImage(); |
+ } |
+ } |
+ |
+ void SetImageFormat(vpx_img_fmt_t format) { |
+ if (format_ != format) { |
+ format_ = format; |
+ ReallocImage(); |
} |
} |
protected: |
virtual void FillFrame() { if (img_) memset(img_->img_data, 0, raw_sz_); } |
+ void ReallocImage() { |
+ vpx_img_free(img_); |
+ img_ = vpx_img_alloc(NULL, format_, width_, height_, 32); |
+ raw_sz_ = ((img_->w + 31) & ~31) * img_->h * img_->bps / 8; |
+ } |
+ |
vpx_image_t *img_; |
size_t raw_sz_; |
unsigned int limit_; |
unsigned int frame_; |
unsigned int width_; |
unsigned int height_; |
+ vpx_img_fmt_t format_; |
}; |