#define BITSTREAM_READER_LE
+#include "libavutil/mem_internal.h"
+
#include "avcodec.h"
#include "bytestream.h"
#include "copy_block.h"
int map = s->map[x];
if (orig_mv_x >= -32) {
- if (y * 8 + mv_y < 0 || y * 8 + mv_y + 8 >= h ||
- x * 8 + mv_x < 0 || x * 8 + mv_x + 8 >= w)
+ if (y * 8 + mv_y < 0 || y * 8 + mv_y + 8 > h ||
+ x * 8 + mv_x < 0 || x * 8 + mv_x + 8 > w)
return AVERROR_INVALIDDATA;
copy_block8(frame->data[plane] + (s->blocks_h - 1 - y) * 8 * frame->linesize[plane] + x * 8,
uint8_t *dst = frame->data[0] + (avctx->height - 1) * frame->linesize[0];
uint8_t r = 0, g = 0, b = 0;
+ if (bytestream2_get_bytes_left(gbyte) < 3 * avctx->width * avctx->height)
+ return AVERROR_INVALIDDATA;
+
for (int y = 0; y < avctx->height; y++) {
for (int x = 0; x < avctx->width; x++) {
- dst[x*3+0] = bytestream2_get_byte(gbyte) + r;
+ dst[x*3+0] = bytestream2_get_byteu(gbyte) + r;
r = dst[x*3+0];
- dst[x*3+1] = bytestream2_get_byte(gbyte) + g;
+ dst[x*3+1] = bytestream2_get_byteu(gbyte) + g;
g = dst[x*3+1];
- dst[x*3+2] = bytestream2_get_byte(gbyte) + b;
+ dst[x*3+2] = bytestream2_get_byteu(gbyte) + b;
b = dst[x*3+2];
}
dst -= frame->linesize[0];
return 0;
}
-static int fill_pixels(uint8_t **y0, uint8_t **y1,
+av_always_inline static int fill_pixels(uint8_t **y0, uint8_t **y1,
uint8_t **u, uint8_t **v,
int ylinesize, int ulinesize, int vlinesize,
uint8_t *fill,
s->dct = avctx->codec_tag != MKTAG('A', 'G', 'M', '4') &&
avctx->codec_tag != MKTAG('A', 'G', 'M', '5');
+ if (!s->rgb && !s->dct) {
+ if ((avctx->width & 1) || (avctx->height & 1))
+ return AVERROR_INVALIDDATA;
+ }
+
avctx->idct_algo = FF_IDCT_SIMPLE;
ff_idctdsp_init(&s->idsp, avctx);
ff_init_scantable(s->idsp.idct_permutation, &s->scantable, ff_zigzag_direct);
return 0;
}
-AVCodec ff_agm_decoder = {
+const AVCodec ff_agm_decoder = {
.name = "agm",
.long_name = NULL_IF_CONFIG_SMALL("Amuse Graphics Movie"),
.type = AVMEDIA_TYPE_VIDEO,