Fix invalid memory read.

This commit is contained in:
siivonek 2021-11-13 16:44:51 +02:00
parent 3e5301cce2
commit 0dc25b86e2
2 changed files with 5 additions and 3 deletions

View file

@ -1016,12 +1016,13 @@ static void intra_recon_tb_leaf(
// Extra reference lines for use with MRL. Extra lines needed only for left edge. // Extra reference lines for use with MRL. Extra lines needed only for left edge.
kvz_pixel extra_refs[2 * 128 * MAX_REF_LINE_IDX] = { 0 }; kvz_pixel extra_refs[2 * 128 * MAX_REF_LINE_IDX] = { 0 };
if (x > 0 && lcu_px.x == 0) { if (x > 0 && lcu_px.x == 0 && lcu_px.y > 0) {
videoframe_t* const frame = state->tile->frame; videoframe_t* const frame = state->tile->frame;
// Copy ref lines 2 & 3. Line 1 is stored in LCU ref buffers. // Copy ref lines 2 & 3. Line 1 is stored in LCU ref buffers.
for (int i = 0; i < MAX_REF_LINE_IDX; ++i) { for (int i = 0; i < MAX_REF_LINE_IDX; ++i) {
int height = (LCU_WIDTH >> depth) * 2 + MAX_REF_LINE_IDX; int height = (LCU_WIDTH >> depth) * 2 + MAX_REF_LINE_IDX;
height = MIN(height, pic_px.y - (y - MAX_REF_LINE_IDX));
kvz_pixels_blit(&frame->rec->y[(y - MAX_REF_LINE_IDX) * frame->rec->stride + x - (1 + i)], kvz_pixels_blit(&frame->rec->y[(y - MAX_REF_LINE_IDX) * frame->rec->stride + x - (1 + i)],
&extra_refs[i * 2 * 128], &extra_refs[i * 2 * 128],
1, height, 1, height,

View file

@ -1056,12 +1056,13 @@ void kvz_search_cu_intra(encoder_state_t * const state,
// Extra reference lines for use with MRL. Extra lines needed only for left edge. // Extra reference lines for use with MRL. Extra lines needed only for left edge.
kvz_pixel extra_refs[2 * 128 * MAX_REF_LINE_IDX] = {0}; kvz_pixel extra_refs[2 * 128 * MAX_REF_LINE_IDX] = {0};
if (x_px > 0 && lcu_px.x == 0) { if (x_px > 0 && lcu_px.x == 0 && lcu_px.y > 0) {
videoframe_t* const frame = state->tile->frame; videoframe_t* const frame = state->tile->frame;
// Copy extra ref lines, including ref line 1 and top left corner. // Copy extra ref lines, including ref line 1 and top left corner.
for (int i = 0; i < MAX_REF_LINE_IDX; ++i) { for (int i = 0; i < MAX_REF_LINE_IDX; ++i) {
int height = (LCU_WIDTH >> depth) * 2 + MAX_REF_LINE_IDX; int height = (LCU_WIDTH >> depth) * 2 + MAX_REF_LINE_IDX;
height = MIN(height, pic_px.y - (y_px - MAX_REF_LINE_IDX));
kvz_pixels_blit(&frame->rec->y[(y_px - MAX_REF_LINE_IDX) * frame->rec->stride + x_px - (1 + i)], kvz_pixels_blit(&frame->rec->y[(y_px - MAX_REF_LINE_IDX) * frame->rec->stride + x_px - (1 + i)],
&extra_refs[i * 2 * 128], &extra_refs[i * 2 * 128],
1, height, 1, height,