#include "libavutil/frame.h"
#include "libavutil/imgutils.h"
#include "libavutil/intreadwrite.h"
+#include "libavutil/mem_internal.h"
#include "avcodec.h"
#include "blockdsp.h"
#include "bswapdsp.h"
#define FIX_1_847759065 121095
#define FIX_2_613125930 171254
-#define MULTIPLY(var, const) (((var) * (const)) >> 16)
+#define MULTIPLY(var, const) ((int)((var) * (unsigned)(const)) >> 16)
static void idct(int16_t block[64])
{
index = size2index[log2h][log2w];
av_assert0(index >= 0);
+ if (get_bits_left(&f->gb) < 1)
+ return AVERROR_INVALIDDATA;
h = 1 << log2h;
code = get_vlc2(&f->gb, block_type_vlc[1 - (f->version > 1)][index].table,
BLOCK_TYPE_VLC_BITS, 1);
{
int code, i, j, level, val;
- if (get_bits_left(&f->gb) < 2){
- av_log(f->avctx, AV_LOG_ERROR, "%d bits left before decode_i_block()\n", get_bits_left(&f->gb));
- return -1;
+ if (get_bits_left(&f->pre_gb) < 2) {
+ av_log(f->avctx, AV_LOG_ERROR, "%d bits left before decode_i_block()\n", get_bits_left(&f->pre_gb));
+ return AVERROR_INVALIDDATA;
}
/* DC coef */
break;
if (code == 0xf0) {
i += 16;
+ if (i >= 64) {
+ av_log(f->avctx, AV_LOG_ERROR, "run %d overflow\n", i);
+ return 0;
+ }
} else {
if (code & 0xf) {
level = get_xbits(&f->gb, code & 0xf);
len_tab[j] = len;
}
+ ff_free_vlc(&f->pre_vlc);
if (init_vlc(&f->pre_vlc, ACDC_VLC_BITS, 257, len_tab, 1, 1,
bits_tab, 4, 4, 0))
return NULL;
for (x = 0; x < width; x += 16) {
unsigned int color[4] = { 0 }, bits;
if (buf_end - buf < 8)
- return -1;
+ return AVERROR_INVALIDDATA;
// warning following is purely guessed ...
color[0] = bytestream2_get_le16u(&g3);
color[1] = bytestream2_get_le16u(&g3);
return 0;
}
-AVCodec ff_fourxm_decoder = {
+const AVCodec ff_fourxm_decoder = {
.name = "4xm",
.long_name = NULL_IF_CONFIG_SMALL("4X Movie"),
.type = AVMEDIA_TYPE_VIDEO,