Skip to content

Commit ea3e356

Browse files
j2k_decompress_reconfigure will check for platform type
j2k_decompress_reconfigure now checks state_decompress_j2k class member platform to see if it is set to j2k_decompress_platform::CPU or j2k_decompress_platform::CUDA prior to calling cmpto_j2k_dec_ctx_cfg_add_cuda_device / cmpto_j2k_dec_ctx_cfg_add_cpu
1 parent d3f1ae4 commit ea3e356

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

Diff for: .vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"string": "cpp",
55
"string_view": "cpp",
66
"vector": "cpp",
7-
"__config": "cpp"
7+
"__config": "cpp",
8+
"locale": "cpp"
89
}
910
}

Diff for: src/video_decompress/cmpto_j2k.cpp

+21-5
Original file line numberDiff line numberDiff line change
@@ -588,11 +588,27 @@ static int j2k_decompress_reconfigure(void *state, struct video_desc desc,
588588

589589
struct cmpto_j2k_dec_ctx_cfg *ctx_cfg = nullptr;
590590
CHECK_OK(cmpto_j2k_dec_ctx_cfg_create(&ctx_cfg), "Error creating dec cfg", return false);
591-
for (unsigned int i = 0; i < cuda_devices_count; ++i) {
592-
CHECK_OK(cmpto_j2k_dec_ctx_cfg_add_cuda_device(
593-
ctx_cfg, cuda_devices[i], s->cuda_mem_limit,
594-
s->cuda_tile_limit),
595-
"Error setting CUDA device", return false);
591+
if (j2k_decompress_platform::CUDA == s->platform) {
592+
for (unsigned int i = 0; i < cuda_devices_count; ++i) {
593+
CHECK_OK(cmpto_j2k_dec_ctx_cfg_add_cuda_device(
594+
ctx_cfg, cuda_devices[i], s->cuda_mem_limit,
595+
s->cuda_tile_limit),
596+
"Error setting CUDA device", return false);
597+
}
598+
}
599+
600+
if (j2k_decompress_platform::CPU == s->platform) {
601+
CHECK_OK(cmpto_j2k_dec_ctx_cfg_add_cpu(
602+
ctx_cfg,
603+
s->cpu_thread_count,
604+
s->cpu_mem_limit,
605+
s->cpu_img_limit),
606+
"Error configuring the CPU",
607+
return false);
608+
609+
MSG(INFO, "Using %s threads on the CPU. Image Limit set to %i.\n",
610+
(s->cpu_thread_count == 0 ? "all available" : std::to_string(s->cpu_thread_count).c_str()),
611+
s->cpu_img_limit);
596612
}
597613

598614

0 commit comments

Comments
 (0)