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
247247
248248 /* av_realloc is not aligned enough; fortunately, the data does not need to
249249 * be preserved */
250−#define RE_MALLOC_OR_FAIL(field, field_size) \
250+#define RE_MALLOC_OR_FAIL(field, field_size, element_size) \
251251 do { \
252252 av_freep(&field); \
253− field = av_calloc(field_size, 1); \
253+ field = av_calloc(field_size, element_size); \
254254 if (!field) { \
255255 yae_release_buffers(atempo); \
256256 return AVERROR(ENOMEM); \
@@ -290,12 +290,12 @@ static int yae_reset(ATempoContext *atempo, · 33 unmodified lines
290290 }
291291
292292 // initialize audio fragment buffers:
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);
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));
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));
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);
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));
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));
299299
300300 // initialize rDFT contexts:
301301 av_tx_uninit(&atempo->real_to_complex);
@@ -313,14 +313,14 @@ static int yae_reset(ATempoContext *atempo, · 11 unmodified lines
313313 return AVERROR(ENOMEM);
314314 }
315315
316− RE_MALLOC_OR_FAIL(atempo->correlation_in, (atempo->window + 1) * sizeof(AVComplexFloat));
317− RE_MALLOC_OR_FAIL(atempo->correlation, atempo->window * 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));
318318
319319 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);
321321
322322 // 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));
324324
325325 for (i = 0; i < atempo->window; i++) {
326326 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