27
27
#include "avcodec.h"
30
* Adapted to ffmpeg by Francois Revol <revol@free.fr>
30
* Adapted to libavcodec by Francois Revol <revol@free.fr>
31
31
* (removed 68k REG stuff, changed types, added some statics and consts,
32
32
* libavcodec api, context stuff, interlaced stereo out).
229
230
static av_cold int mace_decode_init(AVCodecContext * avctx)
232
MACEContext *ctx = avctx->priv_data;
231
234
if (avctx->channels > 2)
233
236
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
238
avcodec_get_frame_defaults(&ctx->frame);
239
avctx->coded_frame = &ctx->frame;
237
static int mace_decode_frame(AVCodecContext *avctx,
238
void *data, int *data_size,
244
static int mace_decode_frame(AVCodecContext *avctx, void *data,
245
int *got_frame_ptr, AVPacket *avpkt)
241
247
const uint8_t *buf = avpkt->data;
242
248
int buf_size = avpkt->size;
243
int16_t *samples = data;
244
250
MACEContext *ctx = avctx->priv_data;
246
252
int is_mace3 = (avctx->codec_id == CODEC_ID_MACE3);
248
if (*data_size < (3 * buf_size << (2-is_mace3))) {
249
av_log(avctx, AV_LOG_ERROR, "Output buffer too small!\n");
254
/* get output buffer */
255
ctx->frame.nb_samples = 3 * (buf_size << (1 - is_mace3)) / avctx->channels;
256
if ((ret = avctx->get_buffer(avctx, &ctx->frame)) < 0) {
257
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
260
samples = (int16_t *)ctx->frame.data[0];
253
262
for(i = 0; i < avctx->channels; i++) {
254
263
int16_t *output = samples + i;
277
*data_size = 3 * buf_size << (2-is_mace3);
287
*(AVFrame *)data = ctx->frame;
282
292
AVCodec ff_mace3_decoder = {
294
.type = AVMEDIA_TYPE_AUDIO,
295
.id = CODEC_ID_MACE3,
296
.priv_data_size = sizeof(MACEContext),
297
.init = mace_decode_init,
298
.decode = mace_decode_frame,
299
.capabilities = CODEC_CAP_DR1,
291
300
.long_name = NULL_IF_CONFIG_SMALL("MACE (Macintosh Audio Compression/Expansion) 3:1"),
294
303
AVCodec ff_mace6_decoder = {
305
.type = AVMEDIA_TYPE_AUDIO,
306
.id = CODEC_ID_MACE6,
307
.priv_data_size = sizeof(MACEContext),
308
.init = mace_decode_init,
309
.decode = mace_decode_frame,
310
.capabilities = CODEC_CAP_DR1,
303
311
.long_name = NULL_IF_CONFIG_SMALL("MACE (Macintosh Audio Compression/Expansion) 6:1"),