#include <stddef.h>
#include <stdio.h>
+#include "libavutil/attributes.h"
#include "libavutil/float_dsp.h"
#include "avcodec.h"
#include "bytestream.h"
} ChannelUnit;
typedef struct ATRAC3Context {
- AVFrame frame;
GetBitContext gb;
//@{
/** stream data */
off = (intptr_t)input & 3;
buf = (const uint32_t *)(input - off);
- c = av_be2ne32((0x537F6103 >> (off * 8)) | (0x537F6103 << (32 - (off * 8))));
+ if (off)
+ c = av_be2ne32((0x537F6103U >> (off * 8)) | (0x537F6103U << (32 - (off * 8))));
+ else
+ c = av_be2ne32(0x537F6103U);
bytes += 3 + off;
for (i = 0; i < bytes / 4; i++)
output[i] = c ^ buf[i];
if (off)
- av_log_ask_for_sample(NULL, "Offset of %d not handled.\n", off);
+ avpriv_request_sample(NULL, "Offset of %d", off);
return off;
}
static int atrac3_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
+ AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
ATRAC3Context *q = avctx->priv_data;
}
/* get output buffer */
- q->frame.nb_samples = SAMPLES_PER_FRAME;
- if ((ret = ff_get_buffer(avctx, &q->frame)) < 0) {
+ frame->nb_samples = SAMPLES_PER_FRAME;
+ if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
databuf = buf;
}
- ret = decode_frame(avctx, databuf, (float **)q->frame.extended_data);
+ ret = decode_frame(avctx, databuf, (float **)frame->extended_data);
if (ret) {
av_log(NULL, AV_LOG_ERROR, "Frame decoding error!\n");
return ret;
}
- *got_frame_ptr = 1;
- *(AVFrame *)data = q->frame;
+ *got_frame_ptr = 1;
return avctx->block_align;
}
-static void atrac3_init_static_data(AVCodec *codec)
+static av_cold void atrac3_init_static_data(AVCodec *codec)
{
int i;
return AVERROR(ENOMEM);
}
- avcodec_get_frame_defaults(&q->frame);
- avctx->coded_frame = &q->frame;
-
return 0;
}