* @param out pointer to 8 bit array of outdata
*/
-static int decode_bytes(uint8_t* inbuffer, uint8_t* out, int bytes){
+static int decode_bytes(const uint8_t* inbuffer, uint8_t* out, int bytes){
int i, off;
uint32_t c;
- uint32_t* buf;
+ const uint32_t* buf;
uint32_t* obuf = (uint32_t*) out;
off = (int)((long)inbuffer & 3);
- buf = (uint32_t*) (inbuffer - off);
+ buf = (const uint32_t*) (inbuffer - off);
c = be2me_32((0x537F6103 >> (off*8)) | (0x537F6103 << (32-(off*8))));
bytes += 3 + off;
for (i = 0; i < bytes/4; i++)
float SF;
numSubbands = get_bits(gb, 5); // number of coded subbands
- codingMode = get_bits(gb, 1); // coding Mode: 0 - VLC/ 1-CLC
+ codingMode = get_bits1(gb); // coding Mode: 0 - VLC/ 1-CLC
/* Get the VLC selector table for the subbands, 0 means not coded. */
for (cnt = 0; cnt <= numSubbands; cnt++)
/* Fill the Weighting coeffs delay buffer */
memmove(q->weighting_delay,&(q->weighting_delay[2]),4*sizeof(int));
- q->weighting_delay[4] = get_bits(&q->gb,1);
+ q->weighting_delay[4] = get_bits1(&q->gb);
q->weighting_delay[5] = get_bits(&q->gb,3);
for (i = 0; i < 4; i++) {
static int atrac3_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
- uint8_t *buf, int buf_size) {
+ const uint8_t *buf, int buf_size) {
ATRAC3Context *q = avctx->priv_data;
int result = 0, i;
uint8_t* databuf;
if (q->channels == 1) {
/* mono */
for (i = 0; i<1024; i++)
- samples[i] = av_clip(round(q->outSamples[i]), -32768, 32767);
+ samples[i] = av_clip_int16(round(q->outSamples[i]));
*data_size = 1024 * sizeof(int16_t);
} else {
/* stereo */
for (i = 0; i < 1024; i++) {
- samples[i*2] = av_clip(round(q->outSamples[i]), -32768, 32767);
- samples[i*2+1] = av_clip(round(q->outSamples[1024+i]), -32768, 32767);
+ samples[i*2] = av_clip_int16(round(q->outSamples[i]));
+ samples[i*2+1] = av_clip_int16(round(q->outSamples[1024+i]));
}
*data_size = 2048 * sizeof(int16_t);
}
static int atrac3_decode_init(AVCodecContext *avctx)
{
int i;
- uint8_t *edata_ptr = avctx->extradata;
+ const uint8_t *edata_ptr = avctx->extradata;
ATRAC3Context *q = avctx->priv_data;
/* Take data from the AVCodecContext (RM container). */
/* Pad the data buffer with FF_INPUT_BUFFER_PADDING_SIZE,
* this is for the bitstream reader. */
if ((q->decoded_bytes_buffer = av_mallocz((avctx->block_align+(4-avctx->block_align%4) + FF_INPUT_BUFFER_PADDING_SIZE))) == NULL)
- return -1;
+ return AVERROR(ENOMEM);
/* Initialize the VLC tables. */
dsputil_init(&dsp, avctx);
q->pUnits = av_mallocz(sizeof(channel_unit)*q->channels);
+ if (!q->pUnits) {
+ av_free(q->decoded_bytes_buffer);
+ return AVERROR(ENOMEM);
+ }
return 0;
}
AVCodec atrac3_decoder =
{
- .name = "atrac 3",
+ .name = "atrac3",
.type = CODEC_TYPE_AUDIO,
.id = CODEC_ID_ATRAC3,
.priv_data_size = sizeof(ATRAC3Context),
.init = atrac3_decode_init,
.close = atrac3_decode_close,
.decode = atrac3_decode_frame,
+ .long_name = "Atrac 3 (Adaptive TRansform Acoustic Coding 3)",
};