Skip to content

Commit fdcca0c

Browse files
committed
Add option for skipping input, when encoding real-time input but the encoder is not fast enough
also clean up CMakeLists.txt
1 parent a28ad15 commit fdcca0c

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

Diff for: CMakeLists.txt

-3
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ endif()
144144
target_include_directories(uvg266 PUBLIC src)
145145
target_include_directories(uvg266 PUBLIC src/extras)
146146
target_include_directories(uvg266 PUBLIC src/strategies)
147-
target_include_directories(uvg266 PUBLIC "G:/Local/sainio/Documents/libzmq/out/install/include")
148147

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

167166
add_executable(uvg266-bin ${CLI_SOURCES})
168167

169-
target_link_libraries(uvg266-bin PUBLIC uvg266 "G:/Local/sainio/Documents/libzmq/out/install/lib/libzmq-mt-4_3_6.lib")
170-
171168
set_target_properties(uvg266-bin PROPERTIES OUTPUT_NAME uvg266)
172169
set_target_properties(uvg266-bin PROPERTIES RUNTIME_OUTPUT_NAME uvg266)
173170

Diff for: src/cli.c

+3
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ static const struct option long_options[] = {
117117
{ "version", no_argument, NULL, 0 },
118118
{ "help", no_argument, NULL, 0 },
119119
{ "loop-input", no_argument, NULL, 0 },
120+
{ "skip-input", no_argument, NULL, 0 },
120121
{ "mv-constraint", required_argument, NULL, 0 },
121122
{ "hash", required_argument, NULL, 0 },
122123
{"cu-split-termination",required_argument, NULL, 0 },
@@ -339,6 +340,8 @@ cmdline_opts_t* cmdline_opts_parse(const uvg_api *const api, int argc, char *arg
339340
goto done;
340341
} else if (!strcmp(name, "loop-input")) {
341342
opts->loop_input = true;
343+
} else if (!strcmp(name, "skip-input")) {
344+
opts->skip_input = true;
342345
} else if (!api->config_parse(opts->config, name, optarg)) {
343346
fprintf(stderr, "invalid argument: %s=%s\n", name, optarg);
344347
ok = 0;

Diff for: src/cli.h

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ typedef struct cmdline_opts_t {
5959
bool version;
6060
/** \brief Whether to loop input */
6161
bool loop_input;
62+
63+
bool skip_input;
6264
} cmdline_opts_t;
6365

6466
cmdline_opts_t* cmdline_opts_parse(const uvg_api *api, int argc, char *argv[]);

Diff for: src/encmain.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,20 @@ static void* input_read_thread(void* in_args)
271271
}
272272

273273
#if defined(__GNUC__) && !defined(__MINGW32__)
274-
usleep(33000);
274+
// usleep(33000);
275275
#else
276276
// Sleep(33);
277277
#endif
278+
if (!args->opts->skip_input) {
279+
uvg_sem_wait(args->available_input_slots);
280+
args->img_in = frame_in;
281+
args->retval = retval;
282+
// Unlock main_thread_mutex to notify main thread that the new img_in
283+
// and retval have been placed to args.
284+
uvg_sem_post(args->filled_input_slots);
285+
frame_in = NULL;
278286

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

0 commit comments

Comments
 (0)