Reduce the runtime of some ACM tests in modules_tests
By reducing the length of the audio input, the total runtime of $ out/Debug/modules_tests --gtest_filter=AudioCodingModuleTest.* is reduced by more than 10x, when run single-threaded. The PCMFile helper class is extended with a FastForward method (to skip initial silence in the test files) and a limiter on how much to read. BUG=webrtc:2463 R=ivoc@webrtc.org Review URL: https://codereview.webrtc.org/1513223002 . Cr-Commit-Position: refs/heads/master@{#10973}
This commit is contained in:
@ -16,6 +16,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "webrtc/base/optional.h"
|
||||
#include "webrtc/modules/include/module_common_types.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
@ -45,12 +46,21 @@ class PCMFile {
|
||||
bool EndOfFile() const {
|
||||
return end_of_file_;
|
||||
}
|
||||
// Moves forward the specified number of 10 ms blocks. If a limit has been set
|
||||
// with SetNum10MsBlocksToRead, fast-forwarding does not count towards this
|
||||
// limit.
|
||||
void FastForward(int num_10ms_blocks);
|
||||
void Rewind();
|
||||
static int16_t ChooseFile(std::string* file_name, int16_t max_len,
|
||||
uint16_t* frequency_hz);
|
||||
bool Rewinded();
|
||||
void SaveStereo(bool is_stereo = true);
|
||||
void ReadStereo(bool is_stereo = true);
|
||||
// If set, the reading will stop after the specified number of blocks have
|
||||
// been read. When that has happened, EndOfFile() will return true. Calling
|
||||
// Rewind() will reset the counter and start over.
|
||||
void SetNum10MsBlocksToRead(int value);
|
||||
|
||||
private:
|
||||
FILE* pcm_file_;
|
||||
uint16_t samples_10ms_;
|
||||
@ -61,6 +71,8 @@ class PCMFile {
|
||||
uint32_t timestamp_;
|
||||
bool read_stereo_;
|
||||
bool save_stereo_;
|
||||
rtc::Optional<int> num_10ms_blocks_to_read_;
|
||||
int blocks_read_ = 0;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
Reference in New Issue
Block a user