| 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_WEBM_VIDEO_SOURCE_H_ | 10 #ifndef TEST_WEBM_VIDEO_SOURCE_H_ |
| 11 #define TEST_WEBM_VIDEO_SOURCE_H_ | 11 #define TEST_WEBM_VIDEO_SOURCE_H_ |
| 12 #include <cstdarg> | 12 #include <cstdarg> |
| 13 #include <cstdio> | 13 #include <cstdio> |
| 14 #include <cstdlib> | 14 #include <cstdlib> |
| 15 #include <new> | 15 #include <new> |
| 16 #include <string> | 16 #include <string> |
| 17 #include "nestegg/include/nestegg/nestegg.h" | 17 #include "third_party/nestegg/include/nestegg/nestegg.h" |
| 18 #include "test/video_source.h" | 18 #include "test/video_source.h" |
| 19 | 19 |
| 20 namespace libvpx_test { | 20 namespace libvpx_test { |
| 21 | 21 |
| 22 static int | 22 static int |
| 23 nestegg_read_cb(void *buffer, size_t length, void *userdata) { | 23 nestegg_read_cb(void *buffer, size_t length, void *userdata) { |
| 24 FILE *f = reinterpret_cast<FILE *>(userdata); | 24 FILE *f = reinterpret_cast<FILE *>(userdata); |
| 25 | 25 |
| 26 if (fread(buffer, 1, length, f) < length) { | 26 if (fread(buffer, 1, length, f) < length) { |
| 27 if (ferror(f)) | 27 if (ferror(f)) |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 virtual void Init() { | 101 virtual void Init() { |
| 102 } | 102 } |
| 103 | 103 |
| 104 virtual void Begin() { | 104 virtual void Begin() { |
| 105 input_file_ = OpenTestDataFile(file_name_); | 105 input_file_ = OpenTestDataFile(file_name_); |
| 106 ASSERT_TRUE(input_file_ != NULL) << "Input file open failed. Filename: " | 106 ASSERT_TRUE(input_file_ != NULL) << "Input file open failed. Filename: " |
| 107 << file_name_; | 107 << file_name_; |
| 108 | 108 |
| 109 nestegg_io io = {nestegg_read_cb, nestegg_seek_cb, nestegg_tell_cb, | 109 nestegg_io io = {nestegg_read_cb, nestegg_seek_cb, nestegg_tell_cb, |
| 110 input_file_}; | 110 input_file_}; |
| 111 ASSERT_FALSE(nestegg_init(&nestegg_ctx_, io, NULL)) | 111 ASSERT_FALSE(nestegg_init(&nestegg_ctx_, io, NULL, -1)) |
| 112 << "nestegg_init failed"; | 112 << "nestegg_init failed"; |
| 113 | 113 |
| 114 unsigned int n; | 114 unsigned int n; |
| 115 ASSERT_FALSE(nestegg_track_count(nestegg_ctx_, &n)) | 115 ASSERT_FALSE(nestegg_track_count(nestegg_ctx_, &n)) |
| 116 << "failed to get track count"; | 116 << "failed to get track count"; |
| 117 | 117 |
| 118 for (unsigned int i = 0; i < n; i++) { | 118 for (unsigned int i = 0; i < n; i++) { |
| 119 int track_type = nestegg_track_type(nestegg_ctx_, i); | 119 int track_type = nestegg_track_type(nestegg_ctx_, i); |
| 120 ASSERT_GE(track_type, 0) << "failed to get track type"; | 120 ASSERT_GE(track_type, 0) << "failed to get track type"; |
| 121 | 121 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 } | 162 } |
| 163 | 163 |
| 164 ASSERT_FALSE(nestegg_packet_data(pkt_, chunk_, &buf_, &buf_sz_)) | 164 ASSERT_FALSE(nestegg_packet_data(pkt_, chunk_, &buf_, &buf_sz_)) |
| 165 << "nestegg_packet_data failed"; | 165 << "nestegg_packet_data failed"; |
| 166 chunk_++; | 166 chunk_++; |
| 167 } | 167 } |
| 168 | 168 |
| 169 virtual const uint8_t *cxdata() const { | 169 virtual const uint8_t *cxdata() const { |
| 170 return end_of_file_ ? NULL : buf_; | 170 return end_of_file_ ? NULL : buf_; |
| 171 } | 171 } |
| 172 virtual const unsigned int frame_size() const { return buf_sz_; } | 172 virtual size_t frame_size() const { return buf_sz_; } |
| 173 virtual const unsigned int frame_number() const { return frame_; } | 173 virtual unsigned int frame_number() const { return frame_; } |
| 174 | 174 |
| 175 protected: | 175 protected: |
| 176 std::string file_name_; | 176 std::string file_name_; |
| 177 FILE *input_file_; | 177 FILE *input_file_; |
| 178 nestegg *nestegg_ctx_; | 178 nestegg *nestegg_ctx_; |
| 179 nestegg_packet *pkt_; | 179 nestegg_packet *pkt_; |
| 180 unsigned int video_track_; | 180 unsigned int video_track_; |
| 181 unsigned int chunk_; | 181 unsigned int chunk_; |
| 182 unsigned int chunks_; | 182 unsigned int chunks_; |
| 183 uint8_t *buf_; | 183 uint8_t *buf_; |
| 184 size_t buf_sz_; | 184 size_t buf_sz_; |
| 185 unsigned int frame_; | 185 unsigned int frame_; |
| 186 bool end_of_file_; | 186 bool end_of_file_; |
| 187 }; | 187 }; |
| 188 | 188 |
| 189 } // namespace libvpx_test | 189 } // namespace libvpx_test |
| 190 | 190 |
| 191 #endif // TEST_WEBM_VIDEO_SOURCE_H_ | 191 #endif // TEST_WEBM_VIDEO_SOURCE_H_ |
| OLD | NEW |