Skip to content

Commit

Permalink
Add option for skipping input, when encoding real-time input but the …
Browse files Browse the repository at this point in the history
…encoder is not fast enough

also clean up CMakeLists.txt
  • Loading branch information
Jovasa committed Jun 17, 2024
1 parent a28ad15 commit fdcca0c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ endif()
target_include_directories(uvg266 PUBLIC src)
target_include_directories(uvg266 PUBLIC src/extras)
target_include_directories(uvg266 PUBLIC src/strategies)
target_include_directories(uvg266 PUBLIC "G:/Local/sainio/Documents/libzmq/out/install/include")

file(GLOB LIB_SOURCES_STRATEGIES_AVX2 RELATIVE ${PROJECT_SOURCE_DIR} "src/strategies/avx2/*.c")
file(GLOB LIB_SOURCES_STRATEGIES_SSE41 RELATIVE ${PROJECT_SOURCE_DIR} "src/strategies/sse41/*.c")
Expand All @@ -166,8 +165,6 @@ endif()

add_executable(uvg266-bin ${CLI_SOURCES})

target_link_libraries(uvg266-bin PUBLIC uvg266 "G:/Local/sainio/Documents/libzmq/out/install/lib/libzmq-mt-4_3_6.lib")

set_target_properties(uvg266-bin PROPERTIES OUTPUT_NAME uvg266)
set_target_properties(uvg266-bin PROPERTIES RUNTIME_OUTPUT_NAME uvg266)

Expand Down
3 changes: 3 additions & 0 deletions src/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ static const struct option long_options[] = {
{ "version", no_argument, NULL, 0 },
{ "help", no_argument, NULL, 0 },
{ "loop-input", no_argument, NULL, 0 },
{ "skip-input", no_argument, NULL, 0 },
{ "mv-constraint", required_argument, NULL, 0 },
{ "hash", required_argument, NULL, 0 },
{"cu-split-termination",required_argument, NULL, 0 },
Expand Down Expand Up @@ -339,6 +340,8 @@ cmdline_opts_t* cmdline_opts_parse(const uvg_api *const api, int argc, char *arg
goto done;
} else if (!strcmp(name, "loop-input")) {
opts->loop_input = true;
} else if (!strcmp(name, "skip-input")) {
opts->skip_input = true;
} else if (!api->config_parse(opts->config, name, optarg)) {
fprintf(stderr, "invalid argument: %s=%s\n", name, optarg);
ok = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ typedef struct cmdline_opts_t {
bool version;
/** \brief Whether to loop input */
bool loop_input;

bool skip_input;
} cmdline_opts_t;

cmdline_opts_t* cmdline_opts_parse(const uvg_api *api, int argc, char *argv[]);
Expand Down
11 changes: 10 additions & 1 deletion src/encmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,20 @@ static void* input_read_thread(void* in_args)
}

#if defined(__GNUC__) && !defined(__MINGW32__)
usleep(33000);
// usleep(33000);
#else
// Sleep(33);
#endif
if (!args->opts->skip_input) {
uvg_sem_wait(args->available_input_slots);
args->img_in = frame_in;
args->retval = retval;
// Unlock main_thread_mutex to notify main thread that the new img_in
// and retval have been placed to args.
uvg_sem_post(args->filled_input_slots);
frame_in = NULL;

} else
// Wait until main thread is ready to receive the next frame.
if (uvg_sem_trywait(args->available_input_slots) == 0) {
args->img_in = frame_in;
Expand Down

0 comments on commit fdcca0c

Please sign in to comment.