Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions libvmaf/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ elif host_machine.system() == 'darwin'
endif

# Header checks
if cc.has_header('malloc.h', args: test_args)
add_project_arguments('-DHAVE_MALLOC_H', language: ['c', 'cpp'])
endif
if cc.has_header('alloca.h', args: test_args)
add_project_arguments('-DHAVE_ALLOCA_H', language: ['c', 'cpp'])
endif

stdatomic_dependency = []
if not cc.check_header('stdatomic.h')
if cc.get_id() == 'msvc'
Expand Down
8 changes: 7 additions & 1 deletion libvmaf/src/libvmaf.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
#include <string.h>
#include <time.h>

Expand Down Expand Up @@ -893,7 +899,7 @@ int vmaf_score_pooled_model_collection(VmafContext *vmaf,
const char *suffix_stddev = "_stddev";
const size_t name_sz =
strlen(model_collection->name) + strlen(suffix_lo) + 1;
char name[name_sz];
char *name = alloca(name_sz);
memset(name, 0, name_sz);

snprintf(name, name_sz, "%s%s", model_collection->name, suffix_bagging);
Expand Down
10 changes: 8 additions & 2 deletions libvmaf/src/predict.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif

#include "dict.h"
#include "feature/alias.h"
Expand Down Expand Up @@ -358,7 +364,7 @@ static int vmaf_bootstrap_predict_score_at_index(
VmafModelCollectionScore *score)
{
int err = 0;
double scores[model_collection->cnt];
double *scores = alloca(model_collection->cnt * sizeof(*scores));

for (unsigned i = 0; i < model_collection->cnt; i++) {
// mean, stddev, etc. are calculated on untransformed/unclipped scores
Expand Down Expand Up @@ -424,7 +430,7 @@ static int vmaf_bootstrap_predict_score_at_index(
const char *suffix_stddev = "_stddev";
const size_t name_sz =
strlen(model_collection->name) + strlen(suffix_lo) + 1;
char name[name_sz];
char *name = alloca(name_sz);
memset(name, 0, name_sz);

snprintf(name, name_sz, "%s%s", model_collection->name, suffix_bagging);
Expand Down
10 changes: 8 additions & 2 deletions libvmaf/src/read_json_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@

#include <errno.h>
#include <stdlib.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
#include <string.h>

#define MAX_FEATURE_COUNT 64 //FIXME
Expand Down Expand Up @@ -493,9 +499,9 @@ static int model_collection_parse(json_stream *s, VmafModel **model,
if (!c.name) return -ENOMEM;

const size_t cfg_name_sz = strlen(name) + 5 + 1;
char cfg_name[cfg_name_sz];
char *cfg_name = alloca(cfg_name_sz);

const size_t generated_key_sz = 4 + 1;
enum { generated_key_sz = 4 + 1 };
char generated_key[generated_key_sz];

unsigned i = 0;
Expand Down
2 changes: 1 addition & 1 deletion libvmaf/test/test_cambi.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ static char *test_decimate_generic()
static char *test_filter_mode()
{
VmafPicture filtered_image, image;
unsigned w = 5, h = 5;
enum { w = 5, h = 5 };
uint16_t buffer[3 * w];

int err = 0;
Expand Down
2 changes: 1 addition & 1 deletion libvmaf/test/test_feature_extractor.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static char *test_feature_extractor_context_pool()
{
int err = 0;

const unsigned n_threads = 8;
enum { n_threads = 8 };
VmafFeatureExtractorContextPool *pool;
err = vmaf_fex_ctx_pool_create(&pool, n_threads);
mu_assert("problem during vmaf_fex_ctx_pool_create", !err);
Expand Down
8 changes: 7 additions & 1 deletion libvmaf/tools/vmaf.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h> // alloca()
#endif
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
#include <unistd.h>

#include "cli_parse.h"
Expand Down Expand Up @@ -268,7 +274,7 @@ int main(int argc, char *argv[])
model_collection = malloc(model_sz);
memset(model_collection, 0, model_collection_sz);

const char *model_collection_label[c.model_cnt];
const char **model_collection_label = alloca(c.model_cnt * sizeof(*model_collection_label));
unsigned model_collection_cnt = 0;

for (unsigned i = 0; i < c.model_cnt; i++) {
Expand Down
Loading