* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avcodec.h"
-#include "bitstream.h"
+#include "get_bits.h"
+#include "put_bits.h"
#include "bytestream.h"
/**
break;
default:
return -1;
- break;
}
avctx->coded_frame= avcodec_alloc_frame();
*dst++ = buf[0][i] | (buf[1][i] << 4);
}
} else
- for (; n>0; n--) {
- for(i = 0; i < avctx->channels; i++) {
+ for (n *= avctx->channels; n>0; n--) {
int nibble;
- nibble = adpcm_yamaha_compress_sample(&c->status[i], samples[i]);
- nibble |= adpcm_yamaha_compress_sample(&c->status[i], samples[i+avctx->channels]) << 4;
+ nibble = adpcm_yamaha_compress_sample(&c->status[ 0], *samples++);
+ nibble |= adpcm_yamaha_compress_sample(&c->status[st], *samples++) << 4;
*dst++ = nibble;
}
- samples += 2 * avctx->channels;
- }
break;
default:
return -1;
static int adpcm_decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
- const uint8_t *buf, int buf_size)
+ AVPacket *avpkt)
{
+ const uint8_t *buf = avpkt->data;
+ int buf_size = avpkt->size;
ADPCMContext *c = avctx->priv_data;
ADPCMChannelStatus *cs;
int n, m, channel, i;
}
break;
case CODEC_ID_ADPCM_EA:
- samples_in_chunk = AV_RL32(src);
- if (samples_in_chunk >= ((buf_size - 12) * 2)) {
+ if (buf_size < 4 || AV_RL32(src) >= ((buf_size - 12) * 2)) {
src += buf_size;
break;
}
+ samples_in_chunk = AV_RL32(src);
src += 4;
current_left_sample = (int16_t)bytestream_get_le16(&src);
previous_left_sample = (int16_t)bytestream_get_le16(&src);
*samples++ = (unsigned short)current_right_sample;
}
}
+
+ if (src - buf == buf_size - 2)
+ src += 2; // Skip terminating 0x0000
+
break;
case CODEC_ID_ADPCM_EA_MAXIS_XA:
for(channel = 0; channel < avctx->channels; channel++) {
adpcm_encode_frame, \
adpcm_encode_close, \
NULL, \
- .sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE}, \
+ .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE}, \
.long_name = NULL_IF_CONFIG_SMALL(long_name_), \
};
#else