| 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_ |
| 11 #define TEST_VIDEO_SOURCE_H_ | 11 #define TEST_VIDEO_SOURCE_H_ |
| 12 | 12 |
| 13 #include <cstdio> | 13 #include <cstdio> |
| 14 #include <cstdlib> | 14 #include <cstdlib> |
| 15 #include <string> | 15 #include <string> |
| 16 #include "test/acm_random.h" | 16 #include "test/acm_random.h" |
| 17 #include "vpx/vpx_encoder.h" | 17 #include "vpx/vpx_encoder.h" |
| 18 | 18 |
| 19 namespace libvpx_test { | 19 namespace libvpx_test { |
| 20 | 20 |
| 21 // Helper macros to ensure LIBVPX_TEST_DATA_PATH is a quoted string. |
| 22 // These are undefined right below GetDataPath |
| 23 // NOTE: LIBVPX_TEST_DATA_PATH MUST NOT be a quoted string before |
| 24 // Stringification or the GetDataPath will fail at runtime |
| 25 #define TO_STRING(S) #S |
| 26 #define STRINGIFY(S) TO_STRING(S) |
| 27 |
| 28 // A simple function to encapsulate cross platform retrieval of test data path |
| 29 static std::string GetDataPath() { |
| 30 const char *const data_path = getenv("LIBVPX_TEST_DATA_PATH"); |
| 31 if (data_path == NULL) { |
| 32 #ifdef LIBVPX_TEST_DATA_PATH |
| 33 // In some environments, we cannot set environment variables |
| 34 // Instead, we set the data path by using a preprocessor symbol |
| 35 // which can be set from make files |
| 36 return STRINGIFY(LIBVPX_TEST_DATA_PATH); |
| 37 #else |
| 38 return "."; |
| 39 #endif |
| 40 } |
| 41 return data_path; |
| 42 } |
| 43 |
| 44 // Undefining stringification macros because they are not used elsewhere |
| 45 #undef TO_STRING |
| 46 #undef STRINGIFY |
| 47 |
| 21 static FILE *OpenTestDataFile(const std::string& file_name) { | 48 static FILE *OpenTestDataFile(const std::string& file_name) { |
| 22 std::string path_to_source = file_name; | 49 const std::string path_to_source = GetDataPath() + "/" + file_name; |
| 23 const char *kDataPath = getenv("LIBVPX_TEST_DATA_PATH"); | |
| 24 | |
| 25 if (kDataPath) { | |
| 26 path_to_source = kDataPath; | |
| 27 path_to_source += "/"; | |
| 28 path_to_source += file_name; | |
| 29 } | |
| 30 | |
| 31 return fopen(path_to_source.c_str(), "rb"); | 50 return fopen(path_to_source.c_str(), "rb"); |
| 32 } | 51 } |
| 33 | 52 |
| 34 // Abstract base class for test video sources, which provide a stream of | 53 // Abstract base class for test video sources, which provide a stream of |
| 35 // vpx_image_t images with associated timestamps and duration. | 54 // vpx_image_t images with associated timestamps and duration. |
| 36 class VideoSource { | 55 class VideoSource { |
| 37 public: | 56 public: |
| 38 virtual ~VideoSource() {} | 57 virtual ~VideoSource() {} |
| 39 | 58 |
| 40 // Prepare the stream for reading, rewind/open as necessary. | 59 // Prepare the stream for reading, rewind/open as necessary. |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 virtual const uint8_t *cxdata() const = 0; | 185 virtual const uint8_t *cxdata() const = 0; |
| 167 | 186 |
| 168 virtual const unsigned int frame_size() const = 0; | 187 virtual const unsigned int frame_size() const = 0; |
| 169 | 188 |
| 170 virtual const unsigned int frame_number() const = 0; | 189 virtual const unsigned int frame_number() const = 0; |
| 171 }; | 190 }; |
| 172 | 191 |
| 173 } // namespace libvpx_test | 192 } // namespace libvpx_test |
| 174 | 193 |
| 175 #endif // TEST_VIDEO_SOURCE_H_ | 194 #endif // TEST_VIDEO_SOURCE_H_ |
| OLD | NEW |