- for (i = 0; i < s->channels; i++) {
- s->decoded[i] = av_realloc(s->decoded[i],
- sizeof(int32_t)*s->max_blocksize);
- }
-}
-
-void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s,
- const uint8_t *buffer)
-{
- GetBitContext gb;
- init_get_bits(&gb, buffer, FLAC_STREAMINFO_SIZE*8);
-
- skip_bits(&gb, 16); /* skip min blocksize */
- s->max_blocksize = get_bits(&gb, 16);
- if (s->max_blocksize < FLAC_MIN_BLOCKSIZE) {
- av_log(avctx, AV_LOG_WARNING, "invalid max blocksize: %d\n",
- s->max_blocksize);
- s->max_blocksize = 16;
- }
-
- skip_bits(&gb, 24); /* skip min frame size */
- s->max_framesize = get_bits_long(&gb, 24);
-
- s->samplerate = get_bits_long(&gb, 20);
- s->channels = get_bits(&gb, 3) + 1;
- s->bps = get_bits(&gb, 5) + 1;
-
- avctx->channels = s->channels;
- avctx->sample_rate = s->samplerate;
- avctx->bits_per_raw_sample = s->bps;
-
- s->samples = get_bits_long(&gb, 32) << 4;
- s->samples |= get_bits(&gb, 4);
+ buf_size = av_samples_get_buffer_size(NULL, s->channels, s->max_blocksize,
+ AV_SAMPLE_FMT_S32P, 0);
+ if (buf_size < 0)
+ return buf_size;