History

avfilter/af_atempo: improve RE_MALLOC_OR_FAIL macro

Make use of third parameter of av_calloc() call.

Paul B Mahol committed 3 years ago

Commit ef3b5781 parent f2642041 file · +12 −12Browse files

Unified · Split

libavfilter/af_atempo.c+12−12
@@ -247,10 +247,10 @@ static void yae_release_buffers(ATempoContext *atempo) · 246 unmodified lines
247 247
248/* av_realloc is not aligned enough; fortunately, the data does not need to248/* av_realloc is not aligned enough; fortunately, the data does not need to
249 * be preserved */249 * be preserved */
250#define RE_MALLOC_OR_FAIL(field, field_size) \250#define RE_MALLOC_OR_FAIL(field, field_size, element_size) \
251 do { \251 do { \
252 av_freep(&field); \252 av_freep(&field); \
253 field = av_calloc(field_size, 1); \253 field = av_calloc(field_size, element_size); \
254 if (!field) { \254 if (!field) { \
255 yae_release_buffers(atempo); \255 yae_release_buffers(atempo); \
256 return AVERROR(ENOMEM); \256 return AVERROR(ENOMEM); \
@@ -290,12 +290,12 @@ static int yae_reset(ATempoContext *atempo, · 33 unmodified lines
290 }290 }
291 291
292 // initialize audio fragment buffers:292 // initialize audio fragment buffers:
293 RE_MALLOC_OR_FAIL(atempo->frag[0].data, atempo->window * atempo->stride);293 RE_MALLOC_OR_FAIL(atempo->frag[0].data, atempo->window, atempo->stride);
294 RE_MALLOC_OR_FAIL(atempo->frag[1].data, atempo->window * atempo->stride);294 RE_MALLOC_OR_FAIL(atempo->frag[1].data, atempo->window, atempo->stride);
295 RE_MALLOC_OR_FAIL(atempo->frag[0].xdat_in, (atempo->window + 1) * sizeof(AVComplexFloat));295 RE_MALLOC_OR_FAIL(atempo->frag[0].xdat_in, (atempo->window + 1), sizeof(AVComplexFloat));
296 RE_MALLOC_OR_FAIL(atempo->frag[1].xdat_in, (atempo->window + 1) * sizeof(AVComplexFloat));296 RE_MALLOC_OR_FAIL(atempo->frag[1].xdat_in, (atempo->window + 1), sizeof(AVComplexFloat));
297 RE_MALLOC_OR_FAIL(atempo->frag[0].xdat, (atempo->window + 1) * sizeof(AVComplexFloat));297 RE_MALLOC_OR_FAIL(atempo->frag[0].xdat, (atempo->window + 1), sizeof(AVComplexFloat));
298 RE_MALLOC_OR_FAIL(atempo->frag[1].xdat, (atempo->window + 1) * sizeof(AVComplexFloat));298 RE_MALLOC_OR_FAIL(atempo->frag[1].xdat, (atempo->window + 1), sizeof(AVComplexFloat));
299 299
300 // initialize rDFT contexts:300 // initialize rDFT contexts:
301 av_tx_uninit(&atempo->real_to_complex);301 av_tx_uninit(&atempo->real_to_complex);
@@ -313,14 +313,14 @@ static int yae_reset(ATempoContext *atempo, · 11 unmodified lines
313 return AVERROR(ENOMEM);313 return AVERROR(ENOMEM);
314 }314 }
315 315
316 RE_MALLOC_OR_FAIL(atempo->correlation_in, (atempo->window + 1) * sizeof(AVComplexFloat));316 RE_MALLOC_OR_FAIL(atempo->correlation_in, (atempo->window + 1), sizeof(AVComplexFloat));
317 RE_MALLOC_OR_FAIL(atempo->correlation, atempo->window * sizeof(AVComplexFloat));317 RE_MALLOC_OR_FAIL(atempo->correlation, atempo->window, sizeof(AVComplexFloat));
318 318
319 atempo->ring = atempo->window * 3;319 atempo->ring = atempo->window * 3;
320 RE_MALLOC_OR_FAIL(atempo->buffer, atempo->ring * atempo->stride);320 RE_MALLOC_OR_FAIL(atempo->buffer, atempo->ring, atempo->stride);
321 321
322 // initialize the Hann window function:322 // initialize the Hann window function:
323 RE_MALLOC_OR_FAIL(atempo->hann, atempo->window * sizeof(float));323 RE_MALLOC_OR_FAIL(atempo->hann, atempo->window, sizeof(float));
324 324
325 for (i = 0; i < atempo->window; i++) {325 for (i = 0; i < atempo->window; i++) {
326 double t = (double)i / (double)(atempo->window - 1);326 double t = (double)i / (double)(atempo->window - 1);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t