diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-06-22 22:34:32 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-06-23 01:26:18 +0200 |
commit | bcb42fb6dbef6da862f3445b2c5ebeb677581807 (patch) | |
tree | fb39925b0a67f5a963477fea9266b87bb4bc689b /libavcodec/sonic.c | |
parent | 81c5ceeda21186979a6f00d1611aa6a73f9b93a8 (diff) | |
download | ffmpeg-bcb42fb6dbef6da862f3445b2c5ebeb677581807.tar.gz |
sonic: use av_calloc()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/sonic.c')
-rw-r--r-- | libavcodec/sonic.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c index 6155516d0f..fc56f94a4f 100644 --- a/libavcodec/sonic.c +++ b/libavcodec/sonic.c @@ -172,7 +172,7 @@ static int intlist_write(PutBitContext *pb, int *buf, int entries, int base_2_pa int step = 256, pos = 0, dominant = 0, any = 0; int *copy, *bits; - copy = av_mallocz(sizeof(*copy) * entries); + copy = av_calloc(entries, sizeof(*copy)); if (!copy) return AVERROR(ENOMEM); @@ -198,7 +198,7 @@ static int intlist_write(PutBitContext *pb, int *buf, int entries, int base_2_pa max = abs(copy[i]); } - bits = av_mallocz(sizeof(*bits) * entries*max); + bits = av_calloc(entries*max, sizeof(*bits)); if (!bits) { // av_free(copy); @@ -268,7 +268,7 @@ static int intlist_read(GetBitContext *gb, int *buf, int entries, int base_2_par int i, low_bits = 0, x = 0; int n_zeros = 0, step = 256, dominant = 0; int pos = 0, level = 0; - int *bits = av_mallocz(sizeof(*bits) * entries); + int *bits = av_calloc(entries, sizeof(*bits)); if (!bits) return AVERROR(ENOMEM); @@ -418,7 +418,7 @@ static void modified_levinson_durbin(int *window, int window_entries, int *out, int out_entries, int channels, int *tap_quant) { int i; - int *state = av_mallocz(sizeof(*state) * window_entries); + int *state = av_calloc(window_entries, sizeof(*state)); memcpy(state, window, 4* window_entries); @@ -543,7 +543,7 @@ static av_cold int sonic_encode_init(AVCodecContext *avctx) } // generate taps - s->tap_quant = av_mallocz(sizeof(*s->tap_quant) * s->num_taps); + s->tap_quant = av_calloc(s->num_taps, sizeof(*s->tap_quant)); for (i = 0; i < s->num_taps; i++) s->tap_quant[i] = (int)(sqrt(i+1)); @@ -554,25 +554,25 @@ static av_cold int sonic_encode_init(AVCodecContext *avctx) s->frame_size = s->channels*s->block_align*s->downsampling; s->tail_size = s->num_taps*s->channels; - s->tail = av_mallocz(sizeof(*s->tail) * s->tail_size); + s->tail = av_calloc(s->tail_size, sizeof(*s->tail)); if (!s->tail) return AVERROR(ENOMEM); - s->predictor_k = av_mallocz(sizeof(*s->predictor_k) * s->num_taps); + s->predictor_k = av_calloc(s->num_taps, sizeof(*s->predictor_k) ); if (!s->predictor_k) return AVERROR(ENOMEM); for (i = 0; i < s->channels; i++) { - s->coded_samples[i] = av_mallocz(sizeof(**s->coded_samples) * s->block_align); + s->coded_samples[i] = av_calloc(s->block_align, sizeof(**s->coded_samples)); if (!s->coded_samples[i]) return AVERROR(ENOMEM); } - s->int_samples = av_mallocz(sizeof(*s->int_samples) * s->frame_size); + s->int_samples = av_calloc(s->frame_size, sizeof(*s->int_samples)); s->window_size = ((2*s->tail_size)+s->frame_size); - s->window = av_mallocz(sizeof(*s->window) * s->window_size); + s->window = av_calloc(s->window_size, sizeof(*s->window)); if (!s->window) return AVERROR(ENOMEM); @@ -821,26 +821,26 @@ static av_cold int sonic_decode_init(AVCodecContext *avctx) version, s->lossless, s->decorrelation, s->num_taps, s->block_align, s->frame_size, s->downsampling); // generate taps - s->tap_quant = av_mallocz(sizeof(*s->tap_quant) * s->num_taps); + s->tap_quant = av_calloc(s->num_taps, sizeof(*s->tap_quant)); for (i = 0; i < s->num_taps; i++) s->tap_quant[i] = (int)(sqrt(i+1)); - s->predictor_k = av_mallocz(sizeof(*s->predictor_k) * s->num_taps); + s->predictor_k = av_calloc(s->num_taps, sizeof(*s->predictor_k)); for (i = 0; i < s->channels; i++) { - s->predictor_state[i] = av_mallocz(sizeof(**s->predictor_state) * s->num_taps); + s->predictor_state[i] = av_calloc(s->num_taps, sizeof(**s->predictor_state)); if (!s->predictor_state[i]) return AVERROR(ENOMEM); } for (i = 0; i < s->channels; i++) { - s->coded_samples[i] = av_mallocz(sizeof(**s->coded_samples) * s->block_align); + s->coded_samples[i] = av_calloc(s->block_align, sizeof(**s->coded_samples)); if (!s->coded_samples[i]) return AVERROR(ENOMEM); } - s->int_samples = av_mallocz(sizeof(*s->int_samples) * s->frame_size); + s->int_samples = av_calloc(s->frame_size, sizeof(*s->int_samples)); avctx->sample_fmt = AV_SAMPLE_FMT_S16; return 0; |