Allow larger encoder configurations.

Allow changing colorspace in the encoder and increasing frame size.

Change-Id: I8e7c3b891af29ce420a15beb4f6f9c250245b2bb
This commit is contained in:
Alex Converse
2015-01-15 13:56:55 -08:00
parent 68340a3470
commit 797a2556eb
7 changed files with 201 additions and 22 deletions

View File

@@ -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_;
};