VLC vlc;
GetBitContext gb;
int prev;
+ const int cmask = ~(!plane_no && c->avctx->pix_fmt == PIX_FMT_YUV420P);
if (build_huff(src, &vlc)) {
av_log(c->avctx, AV_LOG_ERROR, "Cannot build Huffman codes\n");
int slice_data_start, slice_data_end, slice_size;
sstart = send;
- send = height * (slice + 1) / c->slices;
+ send = (height * (slice + 1) / c->slices) & cmask;
dest = dst + sstart * stride;
// slice offset and size validation was done earlier
}
static void restore_median(uint8_t *src, int step, int stride,
- int width, int height, int slices)
+ int width, int height, int slices, int rmode)
{
int i, j, slice;
int A, B, C;
uint8_t *bsrc;
int slice_start, slice_height;
+ const int cmask = ~rmode;
for (slice = 0; slice < slices; slice++) {
- slice_start = (slice * height) / slices;
- slice_height = ((slice + 1) * height) / slices - slice_start;
+ slice_start = ((slice * height) / slices) & cmask;
+ slice_height = ((((slice + 1) * height) / slices) & cmask) - slice_start;
bsrc = src + slice_start * stride;
if (c->frame_pred == PRED_MEDIAN)
restore_median(c->pic.data[0] + rgb_order[i], c->planes,
c->pic.linesize[0], avctx->width, avctx->height,
- c->slices);
+ c->slices, 0);
}
restore_rgb_planes(c->pic.data[0], c->planes, c->pic.linesize[0],
avctx->width, avctx->height);
if (c->frame_pred == PRED_MEDIAN)
restore_median(c->pic.data[i], 1, c->pic.linesize[i],
avctx->width >> !!i, avctx->height >> !!i,
- c->slices);
+ c->slices, !i);
}
break;
case PIX_FMT_YUV422P:
return ret;
if (c->frame_pred == PRED_MEDIAN)
restore_median(c->pic.data[i], 1, c->pic.linesize[i],
- avctx->width >> !!i, avctx->height, c->slices);
+ avctx->width >> !!i, avctx->height, c->slices, 0);
}
break;
}