mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 11:24:05 +00:00
Maybe this would work with VC++
Our threadwrapper does not support PTHREAD_MUTEX_INITIALIZER, apparently that's a toughie to implement on Windows or something, dunno. Use dynamic initialization instead, then.
This commit is contained in:
parent
20758a77e3
commit
fa8cfb92e8
25
src/rdo.c
25
src/rdo.c
|
@ -47,7 +47,7 @@
|
||||||
#define RD_SAMPLING_MAX_LAST_QP 50
|
#define RD_SAMPLING_MAX_LAST_QP 50
|
||||||
|
|
||||||
static FILE *fastrd_learning_outfile[RD_SAMPLING_MAX_LAST_QP + 1] = {NULL};
|
static FILE *fastrd_learning_outfile[RD_SAMPLING_MAX_LAST_QP + 1] = {NULL};
|
||||||
static pthread_mutex_t outfile_mutex[RD_SAMPLING_MAX_LAST_QP + 1] = {PTHREAD_MUTEX_INITIALIZER};
|
static pthread_mutex_t outfile_mutex[RD_SAMPLING_MAX_LAST_QP + 1];
|
||||||
|
|
||||||
const uint32_t kvz_g_go_rice_range[5] = { 7, 14, 26, 46, 78 };
|
const uint32_t kvz_g_go_rice_range[5] = { 7, 14, 26, 46, 78 };
|
||||||
const uint32_t kvz_g_go_rice_prefix_len[5] = { 8, 7, 6, 5, 4 };
|
const uint32_t kvz_g_go_rice_prefix_len[5] = { 8, 7, 6, 5, 4 };
|
||||||
|
@ -165,6 +165,17 @@ int kvz_init_rdcost_outfiles(const char *dir_path)
|
||||||
strncpy(fn_template, dir_path, RD_SAMPLING_MAX_FN_LENGTH);
|
strncpy(fn_template, dir_path, RD_SAMPLING_MAX_FN_LENGTH);
|
||||||
strncat(fn_template, basename_tmpl, RD_SAMPLING_MAX_FN_LENGTH - strlen(dir_path));
|
strncat(fn_template, basename_tmpl, RD_SAMPLING_MAX_FN_LENGTH - strlen(dir_path));
|
||||||
|
|
||||||
|
for (qp = 0; qp <= RD_SAMPLING_MAX_LAST_QP; qp++) {
|
||||||
|
pthread_mutex_t *curr = outfile_mutex + qp;
|
||||||
|
|
||||||
|
if (pthread_mutex_init(curr, NULL) != 0) {
|
||||||
|
fprintf(stderr, "Failed to create mutex\n");
|
||||||
|
rv = -1;
|
||||||
|
qp--;
|
||||||
|
goto out_destroy_mutexes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (qp = 0; qp <= RD_SAMPLING_MAX_LAST_QP; qp++) {
|
for (qp = 0; qp <= RD_SAMPLING_MAX_LAST_QP; qp++) {
|
||||||
FILE *curr;
|
FILE *curr;
|
||||||
|
|
||||||
|
@ -186,6 +197,14 @@ out_close_files:
|
||||||
fclose(fastrd_learning_outfile[qp]);
|
fclose(fastrd_learning_outfile[qp]);
|
||||||
fastrd_learning_outfile[qp] = NULL;
|
fastrd_learning_outfile[qp] = NULL;
|
||||||
}
|
}
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
out_destroy_mutexes:
|
||||||
|
for (; qp >= 0; qp--) {
|
||||||
|
pthread_mutex_destroy(outfile_mutex + qp);
|
||||||
|
}
|
||||||
|
goto out;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
return rv;
|
return rv;
|
||||||
#undef RD_SAMPLING_MAX_FN_LENGTH
|
#undef RD_SAMPLING_MAX_FN_LENGTH
|
||||||
|
@ -1151,8 +1170,12 @@ void kvz_close_rdcost_outfiles(void)
|
||||||
|
|
||||||
for (i = 0; i < RD_SAMPLING_MAX_LAST_QP; i++) {
|
for (i = 0; i < RD_SAMPLING_MAX_LAST_QP; i++) {
|
||||||
FILE *curr = fastrd_learning_outfile[i];
|
FILE *curr = fastrd_learning_outfile[i];
|
||||||
|
pthread_mutex_t *curr_mtx = outfile_mutex + i;
|
||||||
if (curr != NULL) {
|
if (curr != NULL) {
|
||||||
fclose(curr);
|
fclose(curr);
|
||||||
}
|
}
|
||||||
|
if (curr_mtx != NULL) {
|
||||||
|
pthread_mutex_destroy(curr_mtx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue