int channels;
unsigned int outputsamples;
int hassize;
- int readsamplesize;
+ unsigned int readsamplesize;
int wasted_bytes;
int isnotcompressed;
uint8_t interlacing_shift;
*outputsize = outputsamples * alac->bytespersample;
readsamplesize = alac->setinfo_sample_size - (wasted_bytes * 8) + channels - 1;
+ if (readsamplesize > MIN_CACHE_BITS) {
+ av_log(avctx, AV_LOG_ERROR, "readsamplesize too big (%d)\n", readsamplesize);
+ return -1;
+ }
if (!isnotcompressed) {
/* so it is compressed */
}
} else {
/* not compressed, easy case */
- int i, chan;
- for (chan = 0; chan < channels; chan++)
- for (i = 0; i < outputsamples; i++) {
- int32_t audiobits;
+ int i, chan;
+ for (i = 0; i < outputsamples; i++)
+ for (chan = 0; chan < channels; chan++) {
+ int32_t audiobits;
- audiobits = get_bits_long(&alac->gb, alac->setinfo_sample_size);
- audiobits = extend_sign32(audiobits, alac->setinfo_sample_size);
+ audiobits = get_bits_long(&alac->gb, alac->setinfo_sample_size);
+ audiobits = extend_sign32(audiobits, alac->setinfo_sample_size);
- alac->outputsamples_buffer[chan][i] = audiobits;
- }
+ alac->outputsamples_buffer[chan][i] = audiobits;
+ }
/* wasted_bytes = 0; */
interlacing_shift = 0;
interlacing_leftweight = 0;
alac->context_initialized = 0;
alac->numchannels = alac->avctx->channels;
- alac->bytespersample = (avctx->bits_per_sample / 8) * alac->numchannels;
+ alac->bytespersample = 2 * alac->numchannels;
+ avctx->sample_fmt = SAMPLE_FMT_S16;
return 0;
}
NULL,
alac_decode_close,
alac_decode_frame,
- .long_name = "ALAC (Apple Lossless Audio Codec)",
+ .long_name = NULL_IF_CONFIG_SMALL("ALAC (Apple Lossless Audio Codec)"),
};