28
28
* @author Ewald Snel, Benjamin Larsson, Alex Beregszaszi, Roberto Togni
29
30
* The decoder is not perfect yet, there are still some distortions
30
31
* especially on files encoded with 16 or 8 subbands.
1954
static int qdm2_decode_frame(AVCodecContext *avctx,
1955
void *data, int *data_size,
1960
static int qdm2_decode_frame(AVCodecContext *avctx, void *data,
1961
int *got_frame_ptr, AVPacket *avpkt)
1958
1963
const uint8_t *buf = avpkt->data;
1959
1964
int buf_size = avpkt->size;
1960
1965
QDM2Context *s = avctx->priv_data;
1961
int16_t *out = data;
1966
1971
if(buf_size < s->checksum_size)
1969
out_size = 16 * s->channels * s->frame_size *
1970
av_get_bytes_per_sample(avctx->sample_fmt);
1971
if (*data_size < out_size) {
1972
av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
1973
return AVERROR(EINVAL);
1974
/* get output buffer */
1975
s->frame.nb_samples = 16 * s->frame_size;
1976
if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
1977
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
1976
av_log(avctx, AV_LOG_DEBUG, "decode(%d): %p[%d] -> %p[%d]\n",
1977
buf_size, buf, s->checksum_size, data, *data_size);
1980
out = (int16_t *)s->frame.data[0];
1979
1982
for (i = 0; i < 16; i++) {
1980
1983
if (qdm2_decode(s, buf, out) < 0)
1996
2000
.init = qdm2_decode_init,
1997
2001
.close = qdm2_decode_close,
1998
2002
.decode = qdm2_decode_frame,
2003
.capabilities = CODEC_CAP_DR1,
1999
2004
.long_name = NULL_IF_CONFIG_SMALL("QDesign Music Codec 2"),