Make video quality analysis unittests print to log instead of stdout.
I think it's best to avoid printing these perf numbers since when we turn on perf measurements for Android, it will be for all tests as far as I understand it works today. TEST=trybots passing tools_unittests BUG=none R=phoglund@webrtc.org Review URL: https://webrtc-codereview.appspot.com/3109005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5072 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
5dd2ecb32d
commit
e2df8b7f01
@ -232,6 +232,11 @@ void RunAnalysis(const char* reference_file_name, const char* test_file_name,
|
|||||||
|
|
||||||
void PrintMaxRepeatedAndSkippedFrames(const std::string& label,
|
void PrintMaxRepeatedAndSkippedFrames(const std::string& label,
|
||||||
const std::string& stats_file_name) {
|
const std::string& stats_file_name) {
|
||||||
|
PrintMaxRepeatedAndSkippedFrames(stdout, label, stats_file_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintMaxRepeatedAndSkippedFrames(FILE* output, const std::string& label,
|
||||||
|
const std::string& stats_file_name) {
|
||||||
FILE* stats_file = fopen(stats_file_name.c_str(), "r");
|
FILE* stats_file = fopen(stats_file_name.c_str(), "r");
|
||||||
if (stats_file == NULL) {
|
if (stats_file == NULL) {
|
||||||
fprintf(stderr, "Couldn't open stats file for reading: %s\n",
|
fprintf(stderr, "Couldn't open stats file for reading: %s\n",
|
||||||
@ -271,33 +276,38 @@ void PrintMaxRepeatedAndSkippedFrames(const std::string& label,
|
|||||||
}
|
}
|
||||||
previous_frame_number = decoded_frame_number;
|
previous_frame_number = decoded_frame_number;
|
||||||
}
|
}
|
||||||
fprintf(stdout, "RESULT Max_repeated: %s= %d\n", label.c_str(),
|
fprintf(output, "RESULT Max_repeated: %s= %d\n", label.c_str(),
|
||||||
max_repeated_frames);
|
max_repeated_frames);
|
||||||
fprintf(stdout, "RESULT Max_skipped: %s= %d\n", label.c_str(),
|
fprintf(output, "RESULT Max_skipped: %s= %d\n", label.c_str(),
|
||||||
max_skipped_frames);
|
max_skipped_frames);
|
||||||
fclose(stats_file);
|
fclose(stats_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintAnalysisResults(const std::string& label, ResultsContainer* results) {
|
void PrintAnalysisResults(const std::string& label, ResultsContainer* results) {
|
||||||
|
PrintAnalysisResults(stdout, label, results);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintAnalysisResults(FILE* output, const std::string& label,
|
||||||
|
ResultsContainer* results) {
|
||||||
std::vector<AnalysisResult>::iterator iter;
|
std::vector<AnalysisResult>::iterator iter;
|
||||||
|
|
||||||
fprintf(stdout, "RESULT Unique_frames_count: %s= %u\n", label.c_str(),
|
fprintf(output, "RESULT Unique_frames_count: %s= %u\n", label.c_str(),
|
||||||
static_cast<unsigned int>(results->frames.size()));
|
static_cast<unsigned int>(results->frames.size()));
|
||||||
|
|
||||||
if (results->frames.size() > 0u) {
|
if (results->frames.size() > 0u) {
|
||||||
fprintf(stdout, "RESULT PSNR: %s= [", label.c_str());
|
fprintf(output, "RESULT PSNR: %s= [", label.c_str());
|
||||||
for (iter = results->frames.begin(); iter != results->frames.end() - 1;
|
for (iter = results->frames.begin(); iter != results->frames.end() - 1;
|
||||||
++iter) {
|
++iter) {
|
||||||
fprintf(stdout, "%f,", iter->psnr_value);
|
fprintf(output, "%f,", iter->psnr_value);
|
||||||
}
|
}
|
||||||
fprintf(stdout, "%f] dB\n", iter->psnr_value);
|
fprintf(output, "%f] dB\n", iter->psnr_value);
|
||||||
|
|
||||||
fprintf(stdout, "RESULT SSIM: %s= [", label.c_str());
|
fprintf(output, "RESULT SSIM: %s= [", label.c_str());
|
||||||
for (iter = results->frames.begin(); iter != results->frames.end() - 1;
|
for (iter = results->frames.begin(); iter != results->frames.end() - 1;
|
||||||
++iter) {
|
++iter) {
|
||||||
fprintf(stdout, "%f,", iter->ssim_value);
|
fprintf(output, "%f,", iter->ssim_value);
|
||||||
}
|
}
|
||||||
fprintf(stdout, "%f]\n", iter->ssim_value);
|
fprintf(output, "%f]\n", iter->ssim_value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,11 +67,19 @@ double CalculateMetrics(VideoAnalysisMetricsType video_metrics_type,
|
|||||||
// no output will be written.
|
// no output will be written.
|
||||||
void PrintAnalysisResults(const std::string& label, ResultsContainer* results);
|
void PrintAnalysisResults(const std::string& label, ResultsContainer* results);
|
||||||
|
|
||||||
|
// Similar to the above, but will print to the specified file handle.
|
||||||
|
void PrintAnalysisResults(FILE* output, const std::string& label,
|
||||||
|
ResultsContainer* results);
|
||||||
|
|
||||||
// Calculates max repeated and skipped frames and prints them to stdout in a
|
// Calculates max repeated and skipped frames and prints them to stdout in a
|
||||||
// format that is compatible with Chromium performance numbers.
|
// format that is compatible with Chromium performance numbers.
|
||||||
void PrintMaxRepeatedAndSkippedFrames(const std::string& label,
|
void PrintMaxRepeatedAndSkippedFrames(const std::string& label,
|
||||||
const std::string& stats_file_name);
|
const std::string& stats_file_name);
|
||||||
|
|
||||||
|
// Similar to the above, but will print to the specified file handle.
|
||||||
|
void PrintMaxRepeatedAndSkippedFrames(FILE* output, const std::string& label,
|
||||||
|
const std::string& stats_file_name);
|
||||||
|
|
||||||
// Gets the next line from an open stats file.
|
// Gets the next line from an open stats file.
|
||||||
bool GetNextStatsLine(FILE* stats_file, char* line);
|
bool GetNextStatsLine(FILE* stats_file, char* line);
|
||||||
|
|
||||||
|
@ -21,41 +21,59 @@
|
|||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
|
// Setup a log file to write the output to instead of stdout because we don't
|
||||||
|
// want those numbers to be picked up as perf numbers.
|
||||||
|
class VideoQualityAnalysisTest : public ::testing::Test {
|
||||||
|
protected:
|
||||||
|
static void SetUpTestCase() {
|
||||||
|
std::string log_filename = webrtc::test::OutputPath() +
|
||||||
|
"VideoQualityAnalysisTest.log";
|
||||||
|
logfile_ = fopen(log_filename.c_str(), "w");
|
||||||
|
ASSERT_TRUE(logfile_ != NULL);
|
||||||
|
}
|
||||||
|
static void TearDownTestCase() {
|
||||||
|
ASSERT_EQ(0, fclose(logfile_));
|
||||||
|
}
|
||||||
|
static FILE* logfile_;
|
||||||
|
};
|
||||||
|
FILE* VideoQualityAnalysisTest::logfile_ = NULL;
|
||||||
|
|
||||||
TEST(VideoQualityAnalysisTest, PrintAnalysisResultsEmpty) {
|
TEST_F(VideoQualityAnalysisTest, PrintAnalysisResultsEmpty) {
|
||||||
ResultsContainer result;
|
ResultsContainer result;
|
||||||
PrintAnalysisResults("Empty", &result);
|
PrintAnalysisResults(logfile_, "Empty", &result);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(VideoQualityAnalysisTest, PrintAnalysisResultsOneFrame) {
|
TEST_F(VideoQualityAnalysisTest, PrintAnalysisResultsOneFrame) {
|
||||||
ResultsContainer result;
|
ResultsContainer result;
|
||||||
result.frames.push_back(AnalysisResult(0, 35.0, 0.9));
|
result.frames.push_back(AnalysisResult(0, 35.0, 0.9));
|
||||||
PrintAnalysisResults("OneFrame", &result);
|
PrintAnalysisResults(logfile_, "OneFrame", &result);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(VideoQualityAnalysisTest, PrintAnalysisResultsThreeFrames) {
|
TEST_F(VideoQualityAnalysisTest, PrintAnalysisResultsThreeFrames) {
|
||||||
ResultsContainer result;
|
ResultsContainer result;
|
||||||
result.frames.push_back(AnalysisResult(0, 35.0, 0.9));
|
result.frames.push_back(AnalysisResult(0, 35.0, 0.9));
|
||||||
result.frames.push_back(AnalysisResult(1, 34.0, 0.8));
|
result.frames.push_back(AnalysisResult(1, 34.0, 0.8));
|
||||||
result.frames.push_back(AnalysisResult(2, 33.0, 0.7));
|
result.frames.push_back(AnalysisResult(2, 33.0, 0.7));
|
||||||
PrintAnalysisResults("ThreeFrames", &result);
|
PrintAnalysisResults(logfile_, "ThreeFrames", &result);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(VideoQualityAnalysisTest, PrintMaxRepeatedAndSkippedFramesInvalidFile) {
|
TEST_F(VideoQualityAnalysisTest, PrintMaxRepeatedAndSkippedFramesInvalidFile) {
|
||||||
std::string stats_filename = OutputPath() + "non-existing-stats-file.txt";
|
std::string stats_filename = OutputPath() + "non-existing-stats-file.txt";
|
||||||
remove(stats_filename.c_str());
|
remove(stats_filename.c_str());
|
||||||
PrintMaxRepeatedAndSkippedFrames("NonExistingStatsFile", stats_filename);
|
PrintMaxRepeatedAndSkippedFrames(logfile_, "NonExistingStatsFile",
|
||||||
|
stats_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(VideoQualityAnalysisTest, PrintMaxRepeatedAndSkippedFramesEmptyStatsFile) {
|
TEST_F(VideoQualityAnalysisTest,
|
||||||
|
PrintMaxRepeatedAndSkippedFramesEmptyStatsFile) {
|
||||||
std::string stats_filename = OutputPath() + "empty-stats.txt";
|
std::string stats_filename = OutputPath() + "empty-stats.txt";
|
||||||
std::ofstream stats_file;
|
std::ofstream stats_file;
|
||||||
stats_file.open(stats_filename.c_str());
|
stats_file.open(stats_filename.c_str());
|
||||||
stats_file.close();
|
stats_file.close();
|
||||||
PrintMaxRepeatedAndSkippedFrames("EmptyStatsFile", stats_filename);
|
PrintMaxRepeatedAndSkippedFrames(logfile_, "EmptyStatsFile", stats_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(VideoQualityAnalysisTest, PrintMaxRepeatedAndSkippedFramesNormalFile) {
|
TEST_F(VideoQualityAnalysisTest, PrintMaxRepeatedAndSkippedFramesNormalFile) {
|
||||||
std::string stats_filename = OutputPath() + "stats.txt";
|
std::string stats_filename = OutputPath() + "stats.txt";
|
||||||
std::ofstream stats_file;
|
std::ofstream stats_file;
|
||||||
stats_file.open(stats_filename.c_str());
|
stats_file.open(stats_filename.c_str());
|
||||||
@ -65,7 +83,7 @@ TEST(VideoQualityAnalysisTest, PrintMaxRepeatedAndSkippedFramesNormalFile) {
|
|||||||
stats_file << "frame_0004 0106\n";
|
stats_file << "frame_0004 0106\n";
|
||||||
stats_file.close();
|
stats_file.close();
|
||||||
|
|
||||||
PrintMaxRepeatedAndSkippedFrames("NormalStatsFile", stats_filename);
|
PrintMaxRepeatedAndSkippedFrames(logfile_, "NormalStatsFile", stats_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user