#include <stddef.h>
#include <stdio.h>
-#define ALT_BITSTREAM_READER
#include "avcodec.h"
#include "get_bits.h"
#include "dsputil.h"
#define COEFFS 256
typedef struct {
+ AVFrame frame;
+
float old_floor[BANDS];
float flcoeffs1[BANDS];
float flcoeffs2[BANDS];
dsputil_init(&q->dsp, avctx);
avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
avctx->channel_layout = AV_CH_LAYOUT_MONO;
+
+ avcodec_get_frame_defaults(&q->frame);
+ avctx->coded_frame = &q->frame;
+
return 0;
}
return 0;
}
-static int imc_decode_frame(AVCodecContext * avctx,
- void *data, int *data_size,
- AVPacket *avpkt)
+static int imc_decode_frame(AVCodecContext * avctx, void *data,
+ int *got_frame_ptr, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
IMCContext *q = avctx->priv_data;
int stream_format_code;
- int imc_hdr, i, j, out_size, ret;
+ int imc_hdr, i, j, ret;
int flag;
int bits, summer;
int counter, bitscount;
return AVERROR_INVALIDDATA;
}
- out_size = COEFFS * av_get_bytes_per_sample(avctx->sample_fmt);
- if (*data_size < out_size) {
- av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
- return AVERROR(EINVAL);
+ /* get output buffer */
+ q->frame.nb_samples = COEFFS;
+ if ((ret = avctx->get_buffer(avctx, &q->frame)) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ return ret;
}
+ q->out_samples = (float *)q->frame.data[0];
q->dsp.bswap16_buf(buf16, (const uint16_t*)buf, IMC_BLOCK_SIZE / 2);
- q->out_samples = data;
init_get_bits(&q->gb, (const uint8_t*)buf16, IMC_BLOCK_SIZE * 8);
/* Check the frame header */
imc_imdct256(q);
- *data_size = out_size;
+ *got_frame_ptr = 1;
+ *(AVFrame *)data = q->frame;
return IMC_BLOCK_SIZE;
}
IMCContext *q = avctx->priv_data;
ff_fft_end(&q->fft);
+
return 0;
}
.init = imc_decode_init,
.close = imc_decode_close,
.decode = imc_decode_frame,
+ .capabilities = CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("IMC (Intel Music Coder)"),
};