Skip to content

Commit

Permalink
autoformat
Browse files Browse the repository at this point in the history
  • Loading branch information
jiixyj committed Feb 2, 2021
1 parent 752d842 commit 114a7f5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
10 changes: 5 additions & 5 deletions ebur128/ebur128.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static int safe_size_mul(size_t nmemb, size_t size, size_t* result) {
/* Adapted from OpenBSD reallocarray. */
#define MUL_NO_OVERFLOW (((size_t) 1) << (sizeof(size_t) * 4))
if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) && /**/
nmemb > 0 && ((size_t)(-1)) / nmemb < size) {
nmemb > 0 && ((size_t) (-1)) / nmemb < size) {
return 1;
}
#undef MUL_NO_OVERFLOW
Expand Down Expand Up @@ -1334,8 +1334,8 @@ int ebur128_loudness_range_multiple(ebur128_state** sts,
return EBUR128_SUCCESS;
}

percentile_low = (size_t)((stl_size - 1) * 0.1 + 0.5);
percentile_high = (size_t)((stl_size - 1) * 0.95 + 0.5);
percentile_low = (size_t) ((stl_size - 1) * 0.1 + 0.5);
percentile_high = (size_t) ((stl_size - 1) * 0.95 + 0.5);

stl_size = 0;
j = index;
Expand Down Expand Up @@ -1396,8 +1396,8 @@ int ebur128_loudness_range_multiple(ebur128_state** sts,
}

if (stl_relgated_size) {
h_en = stl_relgated[(size_t)((stl_relgated_size - 1) * 0.95 + 0.5)];
l_en = stl_relgated[(size_t)((stl_relgated_size - 1) * 0.1 + 0.5)];
h_en = stl_relgated[(size_t) ((stl_relgated_size - 1) * 0.95 + 0.5)];
l_en = stl_relgated[(size_t) ((stl_relgated_size - 1) * 0.1 + 0.5)];
free(stl_vector);
*out = ebur128_energy_to_loudness(h_en) - ebur128_energy_to_loudness(l_en);
} else {
Expand Down
14 changes: 6 additions & 8 deletions test/minimal-example.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/* See COPYING file for copyright and license details. */

#include <sndfile.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>

#include "ebur128.h"


int main(int ac, const char* av[]) {
SF_INFO file_info;
SNDFILE* file;
Expand Down Expand Up @@ -36,8 +35,7 @@ int main(int ac, const char* av[]) {
}

sts[i] = ebur128_init((unsigned) file_info.channels,
(unsigned) file_info.samplerate,
EBUR128_MODE_I);
(unsigned) file_info.samplerate, EBUR128_MODE_I);
if (!sts[i]) {
fprintf(stderr, "Could not create ebur128_state!\n");
return 1;
Expand All @@ -52,21 +50,21 @@ int main(int ac, const char* av[]) {
ebur128_set_channel(sts[i], 4, EBUR128_RIGHT_SURROUND);
}

buffer = (double*) malloc(sts[i]->samplerate * sts[i]->channels * sizeof(double));
buffer = (double*) malloc(sts[i]->samplerate * sts[i]->channels *
sizeof(double));
if (!buffer) {
fprintf(stderr, "malloc failed\n");
return 1;
}

while ((nr_frames_read = sf_readf_double(file, buffer,
(sf_count_t) sts[i]->samplerate))) {
while ((nr_frames_read = sf_readf_double(
file, buffer, (sf_count_t) sts[i]->samplerate))) {
ebur128_add_frames_double(sts[i], buffer, (size_t) nr_frames_read);
}

ebur128_loudness_global(sts[i], &loudness);
fprintf(stderr, "%.2f LUFS, %s\n", loudness, av[i + 1]);


free(buffer);
buffer = NULL;

Expand Down

0 comments on commit 114a7f5

Please sign in to comment.