Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: source/libvpx/test/video_source.h

Issue 897063002: Revert "libvpx: Pull from upstream" (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/libvpx/test/test_vectors.cc ('k') | source/libvpx/test/vp9_avg_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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() 137 DummyVideoSource() : img_(NULL), limit_(100), width_(0), height_(0) {
138 : img_(NULL), 138 SetSize(80, 64);
139 limit_(100),
140 width_(80),
141 height_(64),
142 format_(VPX_IMG_FMT_I420) {
143 ReallocImage();
144 } 139 }
145 140
146 virtual ~DummyVideoSource() { vpx_img_free(img_); } 141 virtual ~DummyVideoSource() { vpx_img_free(img_); }
147 142
148 virtual void Begin() { 143 virtual void Begin() {
149 frame_ = 0; 144 frame_ = 0;
150 FillFrame(); 145 FillFrame();
151 } 146 }
152 147
153 virtual void Next() { 148 virtual void Next() {
(...skipping 18 matching lines...) Expand all
172 virtual unsigned int frame() const { return frame_; } 167 virtual unsigned int frame() const { return frame_; }
173 168
174 virtual unsigned int limit() const { return limit_; } 169 virtual unsigned int limit() const { return limit_; }
175 170
176 void set_limit(unsigned int limit) { 171 void set_limit(unsigned int limit) {
177 limit_ = limit; 172 limit_ = limit;
178 } 173 }
179 174
180 void SetSize(unsigned int width, unsigned int height) { 175 void SetSize(unsigned int width, unsigned int height) {
181 if (width != width_ || height != height_) { 176 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;
182 width_ = width; 180 width_ = width;
183 height_ = height; 181 height_ = height;
184 ReallocImage();
185 }
186 }
187
188 void SetImageFormat(vpx_img_fmt_t format) {
189 if (format_ != format) {
190 format_ = format;
191 ReallocImage();
192 } 182 }
193 } 183 }
194 184
195 protected: 185 protected:
196 virtual void FillFrame() { if (img_) memset(img_->img_data, 0, raw_sz_); } 186 virtual void FillFrame() { if (img_) memset(img_->img_data, 0, raw_sz_); }
197 187
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
204 vpx_image_t *img_; 188 vpx_image_t *img_;
205 size_t raw_sz_; 189 size_t raw_sz_;
206 unsigned int limit_; 190 unsigned int limit_;
207 unsigned int frame_; 191 unsigned int frame_;
208 unsigned int width_; 192 unsigned int width_;
209 unsigned int height_; 193 unsigned int height_;
210 vpx_img_fmt_t format_;
211 }; 194 };
212 195
213 196
214 class RandomVideoSource : public DummyVideoSource { 197 class RandomVideoSource : public DummyVideoSource {
215 public: 198 public:
216 RandomVideoSource(int seed = ACMRandom::DeterministicSeed()) 199 RandomVideoSource(int seed = ACMRandom::DeterministicSeed())
217 : rnd_(seed), 200 : rnd_(seed),
218 seed_(seed) { } 201 seed_(seed) { }
219 202
220 protected: 203 protected:
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 virtual const uint8_t *cxdata() const = 0; 241 virtual const uint8_t *cxdata() const = 0;
259 242
260 virtual size_t frame_size() const = 0; 243 virtual size_t frame_size() const = 0;
261 244
262 virtual unsigned int frame_number() const = 0; 245 virtual unsigned int frame_number() const = 0;
263 }; 246 };
264 247
265 } // namespace libvpx_test 248 } // namespace libvpx_test
266 249
267 #endif // TEST_VIDEO_SOURCE_H_ 250 #endif // TEST_VIDEO_SOURCE_H_
OLDNEW
« no previous file with comments | « source/libvpx/test/test_vectors.cc ('k') | source/libvpx/test/vp9_avg_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698