| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 #ifndef TEST_VIDEO_SOURCE_H_ | 10 #ifndef TEST_VIDEO_SOURCE_H_ |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 // Get the current frame counter, starting at 0. | 127 // Get the current frame counter, starting at 0. |
| 128 virtual unsigned int frame() const = 0; | 128 virtual unsigned int frame() const = 0; |
| 129 | 129 |
| 130 // Get the current file limit. | 130 // Get the current file limit. |
| 131 virtual unsigned int limit() const = 0; | 131 virtual unsigned int limit() const = 0; |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 | 134 |
| 135 class DummyVideoSource : public VideoSource { | 135 class DummyVideoSource : public VideoSource { |
| 136 public: | 136 public: |
| 137 DummyVideoSource() : img_(NULL), limit_(100), width_(0), height_(0) { | 137 DummyVideoSource() |
| 138 SetSize(80, 64); | 138 : img_(NULL), |
| 139 limit_(100), |
| 140 width_(80), |
| 141 height_(64), |
| 142 format_(VPX_IMG_FMT_I420) { |
| 143 ReallocImage(); |
| 139 } | 144 } |
| 140 | 145 |
| 141 virtual ~DummyVideoSource() { vpx_img_free(img_); } | 146 virtual ~DummyVideoSource() { vpx_img_free(img_); } |
| 142 | 147 |
| 143 virtual void Begin() { | 148 virtual void Begin() { |
| 144 frame_ = 0; | 149 frame_ = 0; |
| 145 FillFrame(); | 150 FillFrame(); |
| 146 } | 151 } |
| 147 | 152 |
| 148 virtual void Next() { | 153 virtual void Next() { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 167 virtual unsigned int frame() const { return frame_; } | 172 virtual unsigned int frame() const { return frame_; } |
| 168 | 173 |
| 169 virtual unsigned int limit() const { return limit_; } | 174 virtual unsigned int limit() const { return limit_; } |
| 170 | 175 |
| 171 void set_limit(unsigned int limit) { | 176 void set_limit(unsigned int limit) { |
| 172 limit_ = limit; | 177 limit_ = limit; |
| 173 } | 178 } |
| 174 | 179 |
| 175 void SetSize(unsigned int width, unsigned int height) { | 180 void SetSize(unsigned int width, unsigned int height) { |
| 176 if (width != width_ || height != height_) { | 181 if (width != width_ || height != height_) { |
| 177 vpx_img_free(img_); | |
| 178 img_ = vpx_img_alloc(NULL, VPX_IMG_FMT_I420, width, height, 32); | |
| 179 raw_sz_ = ((img_->w + 31) & ~31) * img_->h * 3 / 2; | |
| 180 width_ = width; | 182 width_ = width; |
| 181 height_ = height; | 183 height_ = height; |
| 184 ReallocImage(); |
| 185 } |
| 186 } |
| 187 |
| 188 void SetImageFormat(vpx_img_fmt_t format) { |
| 189 if (format_ != format) { |
| 190 format_ = format; |
| 191 ReallocImage(); |
| 182 } | 192 } |
| 183 } | 193 } |
| 184 | 194 |
| 185 protected: | 195 protected: |
| 186 virtual void FillFrame() { if (img_) memset(img_->img_data, 0, raw_sz_); } | 196 virtual void FillFrame() { if (img_) memset(img_->img_data, 0, raw_sz_); } |
| 187 | 197 |
| 198 void ReallocImage() { |
| 199 vpx_img_free(img_); |
| 200 img_ = vpx_img_alloc(NULL, format_, width_, height_, 32); |
| 201 raw_sz_ = ((img_->w + 31) & ~31) * img_->h * img_->bps / 8; |
| 202 } |
| 203 |
| 188 vpx_image_t *img_; | 204 vpx_image_t *img_; |
| 189 size_t raw_sz_; | 205 size_t raw_sz_; |
| 190 unsigned int limit_; | 206 unsigned int limit_; |
| 191 unsigned int frame_; | 207 unsigned int frame_; |
| 192 unsigned int width_; | 208 unsigned int width_; |
| 193 unsigned int height_; | 209 unsigned int height_; |
| 210 vpx_img_fmt_t format_; |
| 194 }; | 211 }; |
| 195 | 212 |
| 196 | 213 |
| 197 class RandomVideoSource : public DummyVideoSource { | 214 class RandomVideoSource : public DummyVideoSource { |
| 198 public: | 215 public: |
| 199 RandomVideoSource(int seed = ACMRandom::DeterministicSeed()) | 216 RandomVideoSource(int seed = ACMRandom::DeterministicSeed()) |
| 200 : rnd_(seed), | 217 : rnd_(seed), |
| 201 seed_(seed) { } | 218 seed_(seed) { } |
| 202 | 219 |
| 203 protected: | 220 protected: |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 virtual const uint8_t *cxdata() const = 0; | 258 virtual const uint8_t *cxdata() const = 0; |
| 242 | 259 |
| 243 virtual size_t frame_size() const = 0; | 260 virtual size_t frame_size() const = 0; |
| 244 | 261 |
| 245 virtual unsigned int frame_number() const = 0; | 262 virtual unsigned int frame_number() const = 0; |
| 246 }; | 263 }; |
| 247 | 264 |
| 248 } // namespace libvpx_test | 265 } // namespace libvpx_test |
| 249 | 266 |
| 250 #endif // TEST_VIDEO_SOURCE_H_ | 267 #endif // TEST_VIDEO_SOURCE_H_ |
| OLD | NEW |