X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fac3enc_template.c;h=b85fe51ef516d8c7ab6d5707e9fa535ff4a99dce;hb=7b9f0b80593d9b33e08106947bd432303848ce12;hp=be659872f73ee5db2558e16ab992e9a466351cab;hpb=c6892f59eb0e9f2a9ec1f55b21a5841a60540e1f;p=ffmpeg diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c index be659872f73..b85fe51ef51 100644 --- a/libavcodec/ac3enc_template.c +++ b/libavcodec/ac3enc_template.c @@ -41,19 +41,16 @@ int AC3_NAME(allocate_sample_buffers)(AC3EncodeContext *s) { int ch; - FF_ALLOC_OR_GOTO(s->avctx, s->windowed_samples, AC3_WINDOW_SIZE * - sizeof(*s->windowed_samples), alloc_fail); - FF_ALLOC_ARRAY_OR_GOTO(s->avctx, s->planar_samples, s->channels, sizeof(*s->planar_samples), - alloc_fail); + if (!FF_ALLOC_TYPED_ARRAY(s->windowed_samples, AC3_WINDOW_SIZE) || + !FF_ALLOCZ_TYPED_ARRAY(s->planar_samples, s->channels)) + return AVERROR(ENOMEM); + for (ch = 0; ch < s->channels; ch++) { - FF_ALLOCZ_OR_GOTO(s->avctx, s->planar_samples[ch], - (AC3_FRAME_SIZE+AC3_BLOCK_SIZE) * sizeof(**s->planar_samples), - alloc_fail); + if (!(s->planar_samples[ch] = av_mallocz((AC3_FRAME_SIZE + AC3_BLOCK_SIZE) * + sizeof(**s->planar_samples)))) + return AVERROR(ENOMEM); } - return 0; -alloc_fail: - return AVERROR(ENOMEM); }