Make use of third parameter of av_calloc() call.
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -247,10 +247,10 @@ static void yae_release_buffers(ATempoContext *atempo) · 246 unmodified lines | ||
| 247 | 247 | |
| 248 | 248 | /* av_realloc is not aligned enough; fortunately, the data does not need to |
| 249 | 249 | * be preserved */ |
| 250 | −#define RE_MALLOC_OR_FAIL(field, field_size) \ | |
| 250 | +#define RE_MALLOC_OR_FAIL(field, field_size, element_size) \ | |
| 251 | 251 | do { \ |
| 252 | 252 | av_freep(&field); \ |
| 253 | − field = av_calloc(field_size, 1); \ | |
| 253 | + field = av_calloc(field_size, element_size); \ | |
| 254 | 254 | if (!field) { \ |
| 255 | 255 | yae_release_buffers(atempo); \ |
| 256 | 256 | return AVERROR(ENOMEM); \ |
| @@ -290,12 +290,12 @@ static int yae_reset(ATempoContext *atempo, · 33 unmodified lines | ||
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | // 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)); | |
| 299 | 299 | |
| 300 | 300 | // initialize rDFT contexts: |
| 301 | 301 | av_tx_uninit(&atempo->real_to_complex); |
| @@ -313,14 +313,14 @@ static int yae_reset(ATempoContext *atempo, · 11 unmodified lines | ||
| 313 | 313 | return AVERROR(ENOMEM); |
| 314 | 314 | } |
| 315 | 315 | |
| 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)); | |
| 318 | 318 | |
| 319 | 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 | 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 | 325 | for (i = 0; i < atempo->window; i++) { |
| 326 | 326 | double t = (double)i / (double)(atempo->window - 1); |