band->width = b_width;
band->height = b_height;
band->pitch = width_aligned;
- band->bufs[0] = av_malloc(buf_size);
- band->bufs[1] = av_malloc(buf_size);
+ band->aheight = height_aligned;
+ band->bufs[0] = av_mallocz(buf_size);
+ band->bufs[1] = av_mallocz(buf_size);
if (!band->bufs[0] || !band->bufs[1])
return AVERROR(ENOMEM);
/* allocate the 3rd band buffer for scalability mode */
if (cfg->luma_bands > 1) {
- band->bufs[2] = av_malloc(buf_size);
+ band->bufs[2] = av_mallocz(buf_size);
if (!band->bufs[2])
return AVERROR(ENOMEM);
}
for (x = 0; x < band->width; x += t_width) {
tile->xpos = x;
tile->ypos = y;
+ tile->mb_size = band->mb_size;
tile->width = FFMIN(band->width - x, t_width);
tile->height = FFMIN(band->height - y, t_height);
tile->is_empty = tile->data_size = 0;
mv_x >>= 1;
mv_y >>= 1; /* convert halfpel vectors into fullpel ones */
}
+ if (mb->type) {
+ int dmv_x, dmv_y, cx, cy;
+
+ dmv_x = mb->mv_x >> band->is_halfpel;
+ dmv_y = mb->mv_y >> band->is_halfpel;
+ cx = mb->mv_x & band->is_halfpel;
+ cy = mb->mv_y & band->is_halfpel;
+
+ if ( mb->xpos + dmv_x < 0
+ || mb->xpos + dmv_x + band->mb_size + cx > band->pitch
+ || mb->ypos + dmv_y < 0
+ || mb->ypos + dmv_y + band->mb_size + cy > band->aheight) {
+ return AVERROR_INVALIDDATA;
+ }
+ }
}
for (blk = 0; blk < num_blocks; blk++) {
#ifdef DEBUG
-uint16_t ivi_calc_band_checksum (IVIBandDesc *band)
+static uint16_t ivi_calc_band_checksum(IVIBandDesc *band)
{
int x, y;
int16_t *src, checksum;
return checksum;
}
-
-int ivi_check_band (IVIBandDesc *band, const uint8_t *ref, int pitch)
-{
- int x, y, result;
- uint8_t t1, t2;
- int16_t *src;
-
- src = band->buf;
- result = 0;
-
- for (y = 0; y < band->height; src += band->pitch, y++) {
- for (x = 0; x < band->width; x++) {
- t1 = av_clip(src[x] + 128, 0, 255);
- t2 = ref[x];
- if (t1 != t2) {
- av_log(NULL, AV_LOG_ERROR, "Data mismatch: row %d, column %d\n",
- y / band->blk_size, x / band->blk_size);
- result = -1;
- }
- }
- ref += pitch;
- }
-
- return result;
-}
#endif
void ff_ivi_output_plane(IVIPlaneDesc *plane, uint8_t *dst, int dst_pitch)
IVITile *tile;
band->buf = band->bufs[ctx->dst_buf];
+ if (!band->buf) {
+ av_log(avctx, AV_LOG_ERROR, "Band buffer points to no data!\n");
+ return AVERROR_INVALIDDATA;
+ }
band->ref_buf = band->bufs[ctx->ref_buf];
band->data_ptr = ctx->frame_data + (get_bits_count(&ctx->gb) >> 3);
for (t = 0; t < band->num_tiles; t++) {
tile = &band->tiles[t];
+ if (tile->mb_size != band->mb_size) {
+ av_log(avctx, AV_LOG_ERROR, "MB sizes mismatch: %d vs. %d\n",
+ band->mb_size, tile->mb_size);
+ return AVERROR_INVALIDDATA;
+ }
tile->is_empty = get_bits1(&ctx->gb);
if (tile->is_empty) {
ff_ivi_process_empty_tile(avctx, band, tile,