int got_quit_command;
} ShortenContext;
- static av_cold int shorten_decode_init(AVCodecContext * avctx)
+ static av_cold int shorten_decode_init(AVCodecContext *avctx)
{
ShortenContext *s = avctx->priv_data;
- s->avctx = avctx;
+ s->avctx = avctx;
- avctx->sample_fmt = AV_SAMPLE_FMT_S16P;
avcodec_get_frame_defaults(&s->frame);
avctx->coded_frame = &s->frame;
static int init_offset(ShortenContext *s)
{
int32_t mean = 0;
- int chan, i;
+ int chan, i;
int nblock = FFMAX(1, s->nmean);
/* initialise offset */
- switch (s->internal_ftype)
- {
- case TYPE_U8:
- s->avctx->sample_fmt = AV_SAMPLE_FMT_U8P;
- mean = 0x80;
- break;
- case TYPE_S16HL:
- case TYPE_S16LH:
- s->avctx->sample_fmt = AV_SAMPLE_FMT_S16P;
- break;
- default:
- av_log(s->avctx, AV_LOG_ERROR, "unknown audio type\n");
- return AVERROR_PATCHWELCOME;
+ switch (s->internal_ftype) {
++ case TYPE_U8:
++ s->avctx->sample_fmt = AV_SAMPLE_FMT_U8P;
++ mean = 0x80;
++ break;
+ case TYPE_S16HL:
+ case TYPE_S16LH:
- mean = 0;
++ s->avctx->sample_fmt = AV_SAMPLE_FMT_S16P;
+ break;
+ default:
- av_log(s->avctx, AV_LOG_ERROR, "unknown audio type");
- return AVERROR_INVALIDDATA;
++ av_log(s->avctx, AV_LOG_ERROR, "unknown audio type\n");
++ return AVERROR_PATCHWELCOME;
}
for (chan = 0; chan < s->channels; chan++)
static int decode_wave_header(AVCodecContext *avctx, const uint8_t *header,
int header_size)
{
- int len;
+ int len, bps;
short wave_format;
+ const uint8_t *end= header + header_size;
- if (bytestream_get_le32(&header) != MKTAG('R','I','F','F')) {
+ if (bytestream_get_le32(&header) != MKTAG('R', 'I', 'F', 'F')) {
av_log(avctx, AV_LOG_ERROR, "missing RIFF tag\n");
return AVERROR_INVALIDDATA;
}
return AVERROR_INVALIDDATA;
}
- while (bytestream_get_le32(&header) != MKTAG('f','m','t',' ')) {
- len = bytestream_get_le32(&header);
- if(len<0 || end - header - 8 < len)
+ while (bytestream_get_le32(&header) != MKTAG('f', 'm', 't', ' ')) {
+ len = bytestream_get_le32(&header);
++ if (len<0 || end - header - 8 < len)
+ return AVERROR_INVALIDDATA;
header += len;
}
len = bytestream_get_le32(&header);
avctx->sample_rate = bytestream_get_le32(&header);
header += 4; // skip bit rate (represents original uncompressed bit rate)
header += 2; // skip block align (not needed)
- avctx->bits_per_coded_sample = bytestream_get_le16(&header);
+ bps = bytestream_get_le16(&header);
+ avctx->bits_per_coded_sample = bps;
- if (avctx->bits_per_coded_sample != 16) {
- av_log(avctx, AV_LOG_ERROR, "unsupported number of bits per sample\n");
+ if (bps != 16 && bps != 8) {
+ av_log(avctx, AV_LOG_ERROR, "unsupported number of bits per sample: %d\n", bps);
- return AVERROR_INVALIDDATA;
+ return AVERROR(ENOSYS);
}
len -= 16;
int ret;
/* allocate internal bitstream buffer */
- if(s->max_framesize == 0){
+ if (s->max_framesize == 0) {
void *tmp_ptr;
- s->max_framesize= 8192; // should hopefully be enough for the first header
- s->max_framesize = 1024; // should hopefully be enough for the first header
++ s->max_framesize = 8192; // should hopefully be enough for the first header
tmp_ptr = av_fast_realloc(s->bitstream, &s->allocated_bitstream_size,
s->max_framesize);
if (!tmp_ptr) {
s->cur_chan = 0;
while (s->cur_chan < s->channels) {
- int cmd;
+ unsigned int cmd;
int len;
- if (get_bits_left(&s->gb) < 3+FNSIZE) {
+ if (get_bits_left(&s->gb) < 3 + FNSIZE) {
*got_frame_ptr = 0;
break;
}