Skip to content

Commit ac5f900

Browse files
author
Louis Fréneau
committed
Add dummy-run option to application (-d 1)
1 parent 7a5e091 commit ac5f900

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

src/app/cli.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,16 @@ namespace cli {
5050
namespace {
5151

5252
// NOLINTNEXTLINE(cert-err58-cpp)
53-
const std::string short_options = "i:g:l:n:o:s:t:b:";
54-
const std::array<struct option, 10> long_options{{{"input", required_argument, nullptr, 'i'},
53+
const std::string short_options = "i:g:l:n:o:s:t:b:d:";
54+
const std::array<struct option, 11> long_options{{{"input", required_argument, nullptr, 'i'},
5555
{"output", required_argument, nullptr, 'o'},
5656
{"frames", required_argument, nullptr, 'n'},
5757
{"start-frame", required_argument, nullptr, 's'},
5858
{"geo-precision", required_argument, nullptr, 'g'},
5959
{"threads", required_argument, nullptr, 't'},
6060
{"uvgvpcc", required_argument, nullptr, 0},
6161
{"loop-input", required_argument, nullptr, 'l'},
62+
{"dummy-run", required_argument, nullptr, 'd'},
6263
{"help", no_argument, nullptr, 0},
6364
{"version", no_argument, nullptr, 0}}};
6465

@@ -120,7 +121,6 @@ size_t select_start_frame_auto(std::string& file_name) {
120121
/// @brief Parse command line options
121122
/// @return True if the execution should end (for exemple if the flag --help is used).
122123
bool opts_parse(cli::opts_t& opts, const int& argc, const std::span<const char* const>& args) {
123-
124124
for (optind = 0;;) {
125125
int long_options_index = -1;
126126

@@ -175,11 +175,14 @@ bool opts_parse(cli::opts_t& opts, const int& argc, const std::span<const char*
175175
} else if (name == "version") {
176176
cli::print_version();
177177
return true;
178+
} else if (name == "dummy-run") {
179+
opts.dummyRun = static_cast<bool>(std::stoi(optarg));
178180
} else if (name == "help") {
179181
cli::print_help();
180182
return true;
181183
}
182184
}
185+
183186
// Check for extra arguments.
184187
if (args.size() - optind > 0) {
185188
throw std::runtime_error("Input error: Extra argument found: " + std::string(args[optind]) + ".");
@@ -247,6 +250,7 @@ void print_help(void) {
247250
std::cout << " -g, --geo-precision <number> Geometry precision for encoding\n";
248251
std::cout << " -t, --threads <number> Maximum number of threads to be used\n";
249252
std::cout << " -l, --loop-input <number> Number of input loop\n";
253+
std::cout << " -d, --dummy-run <number> Vverify config without encoding\n";
250254
std::cout << " --uvgvpcc <params> Encoder configuration parameters\n";
251255
std::cout << " --help Show this help message\n";
252256
std::cout << " --version Show version information\n";

src/app/cli.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ struct opts_t {
6363
bool version = false;
6464
/** \brief Whether to loop input */
6565
size_t nbLoops = 1;
66+
/** \brief If dummyRun is true, config is verified but no encoding is done */
67+
bool dummyRun = false;
6668
};
6769

6870
bool opts_parse(cli::opts_t& opts, const int& argc, const std::span<const char* const>& args);

src/app/uvgVPCCencAppExample.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ void loadFrameFromPlyFile(const std::shared_ptr<uvgvpcc_enc::Frame>& frame, cons
108108
throw std::runtime_error("\nThis path does not exist: " + frame->pointCloudPath);
109109
}
110110

111-
112111
miniply::PLYReader reader(frame->pointCloudPath.c_str());
113112
if (!reader.valid()) {
114113
throw std::runtime_error("\nThe miniply reader failed to open " + frame->pointCloudPath);
@@ -361,6 +360,12 @@ int main(const int argc, const char* const argv[]) {
361360
return EXIT_FAILURE;
362361
}
363362

363+
364+
if(appParameters.dummyRun) {
365+
uvgvpcc_enc::Logger::log<uvgvpcc_enc::LogLevel::INFO>("APPLICATION","Dummy run finished without errors.\n");
366+
return EXIT_SUCCESS;
367+
}
368+
364369
// Initialize the application input and output threads
365370
const std::shared_ptr<input_handler_args> in_args = std::make_shared<input_handler_args>(appParameters, nullptr, Retval::Running);
366371
std::thread inputTh(&inputReadThread, in_args); // TODO(gg): in_args is read and modified by two threads at the same time

0 commit comments

Comments
 (0)