#include "libavutil/float_dsp.h"
#include "avcodec.h"
#include "bytestream.h"
-#include "dsputil.h"
#include "fft.h"
#include "get_bits.h"
-#include "golomb.h"
#include "internal.h"
-#include "unary.h"
#include "on2avcdata.h"
} else {
scale += get_vlc2(gb, c->scale_diff.table, 9, 3) - 60;
}
- if (scale < 0 || scale > 128) {
+ if (scale < 0 || scale > 127) {
av_log(c->avctx, AV_LOG_ERROR, "Invalid scale value %d\n",
scale);
return AVERROR_INVALIDDATA;
static inline float on2avc_scale(int v, float scale)
{
- return v * sqrtf(fabsf(v)) * scale;
+ return v * sqrtf(abs(v)) * scale;
}
// spectral data is coded completely differently - there are no unsigned codebooks
{
int v = 4;
- while (get_bits1(gb)) v++;
+ while (get_bits1(gb)) {
+ v++;
+ if (v > 30) {
+ av_log(NULL, AV_LOG_WARNING, "Too large golomb code in get_egolomb.\n");
+ v = 30;
+ break;
+ }
+ }
- return (1 << v) + get_bits(gb, v);
+ return (1 << v) + get_bits_long(gb, v);
}
static int on2avc_decode_pairs(On2AVCContext *c, GetBitContext *gb, float *dst,
av_log(avctx, AV_LOG_ERROR, "0x500 version should be mono\n");
return AVERROR_INVALIDDATA;
}
+ if (avctx->channels > 2) {
+ av_log(avctx, AV_LOG_ERROR, "Only 1 or 2 channels are supported.\n");
+ return AVERROR(EINVAL);
+ }
if (avctx->channels == 2)
av_log(avctx, AV_LOG_WARNING,
"Stereo mode support is not good, patch is welcome\n");
ff_fft_init(&c->fft256, 7, 0);
ff_fft_init(&c->fft512, 8, 1);
ff_fft_init(&c->fft1024, 9, 1);
- avpriv_float_dsp_init(&c->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
+ avpriv_float_dsp_init(&c->fdsp, avctx->flags & AV_CODEC_FLAG_BITEXACT);
if (init_vlc(&c->scale_diff, 9, ON2AVC_SCALE_DIFFS,
ff_on2avc_scale_diff_bits, 1, 1,
.init = on2avc_decode_init,
.decode = on2avc_decode_frame,
.close = on2avc_decode_close,
- .capabilities = CODEC_CAP_DR1,
+ .capabilities = AV_CODEC_CAP_DR1,
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
AV_SAMPLE_FMT_NONE },
};