[cclm] Fix heap corruption for non 64 divisible frames

This commit is contained in:
Joose Sainio 2022-12-15 13:12:42 +02:00 committed by Marko Viitanen
parent d296cac7c3
commit c89ebf8bf1
2 changed files with 2 additions and 2 deletions

View file

@ -450,7 +450,7 @@ static void downsample_cclm_rec(encoder_state_t *state, int x, int y, int width,
if((y + height * 2) % 64 == 0) { if((y + height * 2) % 64 == 0) {
int line = y / 64 * stride2 / 2; int line = y / 64 * stride2 / 2;
y_rec -= LCU_WIDTH; y_rec -= LCU_WIDTH;
for (int i = 0; i < width; ++i) { for (int i = 0; i < width && i + x < stride2 / 2; ++i) {
int s = 2; int s = 2;
s += y_rec[i * 2] * 2; s += y_rec[i * 2] * 2;
s += y_rec[i * 2 + 1]; s += y_rec[i * 2 + 1];

View file

@ -61,7 +61,7 @@ videoframe_t * uvg_videoframe_alloc(int32_t width,
frame->sao_chroma = MALLOC(sao_info_t, frame->width_in_lcu * frame->height_in_lcu); frame->sao_chroma = MALLOC(sao_info_t, frame->width_in_lcu * frame->height_in_lcu);
if (cclm) { if (cclm) {
assert(chroma_format == UVG_CSP_420); assert(chroma_format == UVG_CSP_420);
frame->cclm_luma_rec = MALLOC(uvg_pixel, (((width + 7) & ~7) + FRAME_PADDING_LUMA) * (((height + 7) & ~7) + FRAME_PADDING_LUMA) / 4); frame->cclm_luma_rec = MALLOC(uvg_pixel, (((width + 7) & ~7) + FRAME_PADDING_LUMA) * (((height + 15) & ~7) + FRAME_PADDING_LUMA) / 4);
frame->cclm_luma_rec_top_line = MALLOC(uvg_pixel, (((width + 7) & ~7) + FRAME_PADDING_LUMA) / 2 * CEILDIV(height, 64)); frame->cclm_luma_rec_top_line = MALLOC(uvg_pixel, (((width + 7) & ~7) + FRAME_PADDING_LUMA) / 2 * CEILDIV(height, 64));
} }
} }