Switch psnr_ssim_analyzer to ABSL_FLAG.
Bug: webrtc:10616
Change-Id: Ic1a60143c799fc994d8b2411e32ec9435f893906
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/143480
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28363}
diff --git a/rtc_tools/BUILD.gn b/rtc_tools/BUILD.gn
index 9df3843..ffade27 100644
--- a/rtc_tools/BUILD.gn
+++ b/rtc_tools/BUILD.gn
@@ -200,17 +200,19 @@
}
rtc_executable("psnr_ssim_analyzer") {
+ testonly = true
sources = [
"psnr_ssim_analyzer/psnr_ssim_analyzer.cc",
]
deps = [
- ":command_line_parser",
":video_file_reader",
":video_quality_analysis",
"../api:scoped_refptr",
"../api/video:video_frame",
"../api/video:video_rtp_headers",
+ "//third_party/abseil-cpp/absl/flags:flag",
+ "//third_party/abseil-cpp/absl/flags:parse",
]
}
diff --git a/rtc_tools/psnr_ssim_analyzer/psnr_ssim_analyzer.cc b/rtc_tools/psnr_ssim_analyzer/psnr_ssim_analyzer.cc
index ca97161..05180c2 100644
--- a/rtc_tools/psnr_ssim_analyzer/psnr_ssim_analyzer.cc
+++ b/rtc_tools/psnr_ssim_analyzer/psnr_ssim_analyzer.cc
@@ -13,12 +13,26 @@
#include <algorithm>
#include <string>
+#include "absl/flags/flag.h"
+#include "absl/flags/parse.h"
#include "api/scoped_refptr.h"
#include "api/video/video_frame_buffer.h"
#include "rtc_tools/frame_analyzer/video_quality_analysis.h"
-#include "rtc_tools/simple_command_line_parser.h"
#include "rtc_tools/video_file_reader.h"
+ABSL_FLAG(std::string,
+ results_file,
+ "results.txt",
+ "The full name of the file where the results will be written");
+ABSL_FLAG(std::string,
+ reference_file,
+ "ref.yuv",
+ "The reference YUV file to compare against");
+ABSL_FLAG(std::string,
+ test_file,
+ "test.yuv",
+ "The test YUV file to run the analysis for");
+
void CompareFiles(
const rtc::scoped_refptr<webrtc::test::Video>& reference_video,
const rtc::scoped_refptr<webrtc::test::Video>& test_video,
@@ -59,45 +73,27 @@
* --results_file=<name_of_file>
*/
int main(int argc, char* argv[]) {
- std::string program_name = argv[0];
- std::string usage =
- "Runs PSNR and SSIM on two I420 videos and write the"
- "results in a file.\n"
- "Example usage:\n" +
- program_name +
- " --reference_file=ref.yuv "
- "--test_file=test.yuv --results_file=results.txt\n"
- "Command line flags:\n"
- " - reference_file(string): The reference YUV file to compare against."
- " Default: ref.yuv\n"
- " - test_file(string): The test YUV file to run the analysis for."
- " Default: test_file.yuv\n"
- " - results_file(string): The full name of the file where the results "
- "will be written. Default: results.txt\n";
-
- webrtc::test::CommandLineParser parser;
-
- // Init the parser and set the usage message
- parser.Init(argc, argv);
- parser.SetUsageMessage(usage);
-
- parser.SetFlag("results_file", "results.txt");
- parser.SetFlag("reference_file", "ref.yuv");
- parser.SetFlag("test_file", "test.yuv");
- parser.SetFlag("results_file", "results.txt");
- parser.SetFlag("help", "false");
-
- parser.ProcessFlags();
- if (parser.GetFlag("help") == "true") {
- parser.PrintUsageMessage();
- exit(EXIT_SUCCESS);
- }
- parser.PrintEnteredFlags();
+ absl::ParseCommandLine(argc, argv);
+ // TODO(bugs.webrtc.org/10616): Add program usage message when Abseil
+ // flags supports it.
+ // std::string usage =
+ // "Runs PSNR and SSIM on two I420 videos and write the"
+ // "results in a file.\n"
+ // "Example usage:\n" +
+ // program_name +
+ // " --reference_file=ref.yuv "
+ // "--test_file=test.yuv --results_file=results.txt\n"
+ // "Command line flags:\n"
+ // " - reference_file(string): The reference YUV file to compare
+ // against." " Default: ref.yuv\n" " - test_file(string): The test YUV
+ // file to run the analysis for." " Default: test_file.yuv\n" " -
+ // results_file(string): The full name of the file where the results "
+ // "will be written. Default: results.txt\n";
rtc::scoped_refptr<webrtc::test::Video> reference_video =
- webrtc::test::OpenY4mFile(parser.GetFlag("reference_file"));
+ webrtc::test::OpenY4mFile(absl::GetFlag(FLAGS_reference_file));
rtc::scoped_refptr<webrtc::test::Video> test_video =
- webrtc::test::OpenY4mFile(parser.GetFlag("test_file"));
+ webrtc::test::OpenY4mFile(absl::GetFlag(FLAGS_test_file));
if (!reference_video || !test_video) {
fprintf(stderr, "Error opening video files\n");
@@ -114,6 +110,6 @@
}
CompareFiles(reference_video, test_video,
- parser.GetFlag("results_file").c_str());
+ absl::GetFlag(FLAGS_results_file).c_str());
return 0;
}