int mv[256];
VLC pre_vlc;
int last_dc;
- DECLARE_ALIGNED(16, DCTELEM, block)[6][64];
+ DECLARE_ALIGNED(16, int16_t, block)[6][64];
void *bitstream_buffer;
unsigned int bitstream_buffer_size;
int version;
#define MULTIPLY(var, const) (((var) * (const)) >> 16)
-static void idct(DCTELEM block[64])
+static void idct(int16_t block[64])
{
int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
int tmp10, tmp11, tmp12, tmp13;
* decode block and dequantize.
* Note this is almost identical to MJPEG.
*/
-static int decode_i_block(FourXContext *f, DCTELEM *block)
+static int decode_i_block(FourXContext *f, int16_t *block)
{
int code, i, j, level, val;
static inline void idct_put(FourXContext *f, int x, int y)
{
- DCTELEM (*block)[64] = f->block;
+ int16_t (*block)[64] = f->block;
int stride = f->current_picture->linesize[0] >> 1;
int i;
uint16_t *dst = ((uint16_t*)f->current_picture->data[0]) + y * stride + x;
* cr = (-1b - 4g + 5r) / 14 */
for (y = 0; y < 8; y++) {
for (x = 0; x < 8; x++) {
- DCTELEM *temp = block[(x >> 2) + 2 * (y >> 2)] +
+ int16_t *temp = block[(x >> 2) + 2 * (y >> 2)] +
2 * (x & 3) + 2 * 8 * (y & 3); // FIXME optimize
int cb = block[4][x + 8 * y];
int cr = block[5][x + 8 * y];
for (;;) {
int i;
- if (start <= end && ptr_end - ptr < end - start + 1 + 1)
+ if (ptr_end - ptr < FFMAX(end - start + 1, 0) + 1) {
+ av_log(f->avctx, AV_LOG_ERROR, "invalid data in read_huffman_tables\n");
return NULL;
+ }
for (i = start; i <= end; i++)
frequency[i] = *ptr++;
start = *ptr++;
while ((ptr - buf) & 3)
ptr++; // 4byte align
+ if (ptr > ptr_end) {
+ av_log(f->avctx, AV_LOG_ERROR, "ptr overflow in read_huffman_tables\n");
+ return NULL;
+ }
+
for (j = 257; j < 512; j++) {
int min_freq[2] = { 256 * 256, 256 * 256 };
int smallest[2] = { 0, 0 };
if (!prestream)
return -1;
+ av_assert0(prestream <= buf + length);
+
init_get_bits(&f->gb, buf + 4, 8 * bitstream_size);
prestream_size = length + buf - prestream;
return AVERROR_INVALIDDATA;
}
- avcodec_get_frame_defaults(&f->current_picture);
- avcodec_get_frame_defaults(&f->last_picture);
f->version = AV_RL32(avctx->extradata) >> 16;
ff_dsputil_init(&f->dsp, avctx);
f->avctx = avctx;