static av_cold int xma_decode_init(AVCodecContext *avctx)
{
    XMADecodeCtx *s = avctx->priv_data;
    int i, ret;

    if (avctx->channels <= 0 || avctx->channels > 8)
        return AVERROR_INVALIDDATA;

    for (i = 0; i < (avctx->channels + 1) / 2; i++) {
        ret = decode_init(&s->xma[i], avctx);
        if (ret < 0)
            return ret;
        s->frames[i] = av_frame_alloc();
        if (!s->frames[i])
            return AVERROR(ENOMEM);
        s->frames[i]->nb_samples = 512;
        if ((ret = ff_get_buffer(avctx, s->frames[i], 0)) < 0) {
            return AVERROR(ENOMEM);
        }

    }

    return ret;
}