OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/tools/omx_test/file_reader_util.h" | 5 #include "media/tools/omx_test/file_reader_util.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 int height, | 39 int height, |
40 int loop_count, | 40 int loop_count, |
41 bool enable_csc) | 41 bool enable_csc) |
42 : BasicFileReader(path), | 42 : BasicFileReader(path), |
43 width_(width), | 43 width_(width), |
44 height_(height), | 44 height_(height), |
45 loop_count_(loop_count), | 45 loop_count_(loop_count), |
46 output_nv21_(enable_csc) { | 46 output_nv21_(enable_csc) { |
47 } | 47 } |
48 | 48 |
| 49 YuvFileReader::~YuvFileReader() {} |
| 50 |
49 void YuvFileReader::Read(uint8** output, int* size) { | 51 void YuvFileReader::Read(uint8** output, int* size) { |
50 if (!file()) { | 52 if (!file()) { |
51 *size = 0; | 53 *size = 0; |
52 *output = NULL; | 54 *output = NULL; |
53 return; | 55 return; |
54 } | 56 } |
55 | 57 |
56 while (true) { | 58 while (true) { |
57 scoped_array<uint8> data; | 59 scoped_array<uint8> data; |
58 int bytes_read = 0; | 60 int bytes_read = 0; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 // H264FileReader | 225 // H264FileReader |
224 const int kH264ReadSize = 1024 * 1024; | 226 const int kH264ReadSize = 1024 * 1024; |
225 | 227 |
226 H264FileReader::H264FileReader(const FilePath& path) | 228 H264FileReader::H264FileReader(const FilePath& path) |
227 : BasicFileReader(path), | 229 : BasicFileReader(path), |
228 read_buf_(new uint8[kH264ReadSize]), | 230 read_buf_(new uint8[kH264ReadSize]), |
229 current_(0), | 231 current_(0), |
230 used_(0) { | 232 used_(0) { |
231 } | 233 } |
232 | 234 |
| 235 H264FileReader::~H264FileReader() {} |
| 236 |
233 void H264FileReader::Read(uint8** output, int *size) { | 237 void H264FileReader::Read(uint8** output, int *size) { |
234 // Fill the buffer when it's less than half full. | 238 // Fill the buffer when it's less than half full. |
235 int read = 0; | 239 int read = 0; |
236 if (used_ < kH264ReadSize / 2) { | 240 if (used_ < kH264ReadSize / 2) { |
237 read = fread(read_buf_.get(), 1, kH264ReadSize - used_, file()); | 241 read = fread(read_buf_.get(), 1, kH264ReadSize - used_, file()); |
238 CHECK(read >= 0); | 242 CHECK(read >= 0); |
239 used_ += read; | 243 used_ += read; |
240 } | 244 } |
241 | 245 |
242 // If we failed to read. | 246 // If we failed to read. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 // If next NALU is not found, assume the remaining data is a NALU | 287 // If next NALU is not found, assume the remaining data is a NALU |
284 // and return the data. | 288 // and return the data. |
285 CHECK(used_ > current_); | 289 CHECK(used_ > current_); |
286 *size = used_ - current_; | 290 *size = used_ - current_; |
287 *output = new uint8[*size]; | 291 *output = new uint8[*size]; |
288 memcpy(*output, read_buf_.get() + current_, *size); | 292 memcpy(*output, read_buf_.get() + current_, *size); |
289 current_ = used_; | 293 current_ = used_; |
290 } | 294 } |
291 | 295 |
292 } // namespace media | 296 } // namespace media |
OLD | NEW |