int swapuv)
{
GetBitContext gb;
- uint8_t *tmp;
int mb_w, mb_h, mb_x, mb_y, i, j;
int bx, by;
int unesc_size;
int ret;
- tmp = av_realloc(c->buf, src_size + FF_INPUT_BUFFER_PADDING_SIZE);
- if (!tmp)
- return AVERROR(ENOMEM);
- c->buf = tmp;
+ if ((ret = av_reallocp(&c->buf,
+ src_size + FF_INPUT_BUFFER_PADDING_SIZE)) < 0)
+ return ret;
jpg_unescape(src, src_size, c->buf, &unesc_size);
memset(c->buf + unesc_size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
init_get_bits(&gb, c->buf, unesc_size * 8);
uint32_t bits;
uint32_t cur_size, cursor_w, cursor_h, cursor_stride;
uint32_t cursor_hot_x, cursor_hot_y;
- int cursor_fmt;
- uint8_t *tmp;
+ int cursor_fmt, err;
cur_size = bytestream2_get_be32(gb);
cursor_w = bytestream2_get_byte(gb);
cursor_hot_y = bytestream2_get_byte(gb);
cursor_fmt = bytestream2_get_byte(gb);
- cursor_stride = cursor_w * 4;
+ cursor_stride = FFALIGN(cursor_w, 32) * 4;
if (cursor_w < 1 || cursor_w > 256 ||
cursor_h < 1 || cursor_h > 256) {
return AVERROR_PATCHWELCOME;
}
- tmp = av_realloc(c->cursor, cursor_stride * cursor_h);
- if (!tmp) {
+ if ((err = av_reallocp(&c->cursor, cursor_stride * cursor_h)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Cannot allocate cursor buffer\n");
- return AVERROR(ENOMEM);
+ return err;
}
- c->cursor = tmp;
c->cursor_w = cursor_w;
c->cursor_h = cursor_h;
c->cursor_hot_x = cursor_hot_x;
bits <<= 1;
}
}
+ dst += c->cursor_stride - c->cursor_w * 4;
}
dst = c->cursor;
bits <<= 1;
}
}
+ dst += c->cursor_stride - c->cursor_w * 4;
}
break;
case 32: // full colour
*dst++ = val >> 16;
*dst++ = val >> 24;
}
+ dst += c->cursor_stride - c->cursor_w * 4;
}
break;
default:
goto header_fail;
}
if (c->width != avctx->width || c->height != avctx->height)
- avcodec_set_dimensions(avctx, c->width, c->height);
+ ff_set_dimensions(avctx, c->width, c->height);
c->compression = bytestream2_get_be32(&bc);
if (c->compression != 2 && c->compression != 3) {
av_log(avctx, AV_LOG_ERROR,
}
c->tile_width = bytestream2_get_be32(&bc);
c->tile_height = bytestream2_get_be32(&bc);
- if (!c->tile_width || !c->tile_height) {
+ if (!c->tile_width || !c->tile_height ||
+ ((c->tile_width | c->tile_height) & 0xF)) {
av_log(avctx, AV_LOG_ERROR,
"Invalid tile dimensions %dx%d\n",
c->tile_width, c->tile_height);
return AVERROR(ENOMEM);
}
- avctx->pix_fmt = PIX_FMT_RGB24;
+ avctx->pix_fmt = AV_PIX_FMT_RGB24;
return 0;
}