# HG changeset patch # User kostya # Date 1251612993 0 # Node ID d0f2f4e4436cd79085911b6ec55a8a2ab30661cf # Parent 6cade2cdd63b2ea6f24211ece058d6c3f64c96ca Adjust r->avail_cache[] indexes to avoid alignment issues when zeroing block inside it. diff -r 6cade2cdd63b -r d0f2f4e4436c rv34.c --- a/rv34.c Sat Aug 29 21:04:18 2009 +0000 +++ b/rv34.c Sun Aug 30 06:16:33 2009 +0000 @@ -440,7 +440,7 @@ static const uint8_t part_sizes_h[RV34_MB_TYPES] = { 2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2 }; /** availability index for subblocks */ -static const uint8_t avail_indexes[4] = { 5, 6, 9, 10 }; +static const uint8_t avail_indexes[4] = { 6, 7, 10, 11 }; /** * motion vector prediction @@ -553,21 +553,21 @@ memset(A, 0, sizeof(A)); memset(B, 0, sizeof(B)); memset(C, 0, sizeof(C)); - if((r->avail_cache[5-1] & type) & mask){ + if((r->avail_cache[6-1] & type) & mask){ A[0] = cur_pic->motion_val[dir][mv_pos - 1][0]; A[1] = cur_pic->motion_val[dir][mv_pos - 1][1]; has_A = 1; } - if((r->avail_cache[5-4] & type) & mask){ + if((r->avail_cache[6-4] & type) & mask){ B[0] = cur_pic->motion_val[dir][mv_pos - s->b8_stride][0]; B[1] = cur_pic->motion_val[dir][mv_pos - s->b8_stride][1]; has_B = 1; } - if(r->avail_cache[5-4] && (r->avail_cache[5-2] & type) & mask){ + if(r->avail_cache[6-4] && (r->avail_cache[6-2] & type) & mask){ C[0] = cur_pic->motion_val[dir][mv_pos - s->b8_stride + 2][0]; C[1] = cur_pic->motion_val[dir][mv_pos - s->b8_stride + 2][1]; has_C = 1; - }else if((s->mb_x+1) == s->mb_width && (r->avail_cache[5-5] & type) & mask){ + }else if((s->mb_x+1) == s->mb_width && (r->avail_cache[6-5] & type) & mask){ C[0] = cur_pic->motion_val[dir][mv_pos - s->b8_stride - 1][0]; C[1] = cur_pic->motion_val[dir][mv_pos - s->b8_stride - 1][1]; has_C = 1; @@ -958,17 +958,17 @@ int idx; // Set neighbour information. - if(r->avail_cache[0]) + if(r->avail_cache[1]) avail[0] = 1; - if(r->avail_cache[1]) + if(r->avail_cache[2]) avail[1] = avail[2] = 1; - if(r->avail_cache[2]) + if(r->avail_cache[3]) avail[3] = avail[4] = 1; - if(r->avail_cache[3]) + if(r->avail_cache[4]) avail[5] = 1; - if(r->avail_cache[4]) + if(r->avail_cache[5]) avail[8] = avail[16] = 1; - if(r->avail_cache[8]) + if(r->avail_cache[9]) avail[24] = avail[32] = 1; Y = s->dest[0]; @@ -987,9 +987,9 @@ intra_types += r->intra_types_stride; } intra_types -= r->intra_types_stride * 4; - fill_rectangle(r->avail_cache + 5, 2, 2, 4, 0, 4); + fill_rectangle(r->avail_cache + 6, 2, 2, 4, 0, 4); for(j = 0; j < 2; j++){ - idx = 5 + j*4; + idx = 6 + j*4; for(i = 0; i < 2; i++, cbp >>= 1, idx++){ rv34_pred_4x4_block(r, U + i*4 + j*4*s->uvlinesize, s->uvlinesize, ittrans[intra_types[i*2+j*2*r->intra_types_stride]], r->avail_cache[idx-4], r->avail_cache[idx-1], !i && !j, r->avail_cache[idx-3]); rv34_pred_4x4_block(r, V + i*4 + j*4*s->uvlinesize, s->uvlinesize, ittrans[intra_types[i*2+j*2*r->intra_types_stride]], r->avail_cache[idx-4], r->avail_cache[idx-1], !i && !j, r->avail_cache[idx-3]); @@ -1002,7 +1002,7 @@ } }else{ itype = ittrans16[intra_types[0]]; - itype = adjust_pred16(itype, r->avail_cache[5-4], r->avail_cache[5-1]); + itype = adjust_pred16(itype, r->avail_cache[6-4], r->avail_cache[6-1]); r->h.pred16x16[itype](Y, s->linesize); dsp->add_pixels_clamped(s->block[0], Y, s->linesize); dsp->add_pixels_clamped(s->block[1], Y + 8, s->linesize); @@ -1012,7 +1012,7 @@ itype = ittrans16[intra_types[0]]; if(itype == PLANE_PRED8x8) itype = DC_PRED8x8; - itype = adjust_pred16(itype, r->avail_cache[5-4], r->avail_cache[5-1]); + itype = adjust_pred16(itype, r->avail_cache[6-4], r->avail_cache[6-1]); r->h.pred8x8[itype](U, s->uvlinesize); dsp->add_pixels_clamped(s->block[4], U, s->uvlinesize); r->h.pred8x8[itype](V, s->uvlinesize); @@ -1173,18 +1173,18 @@ // Calculate which neighbours are available. Maybe it's worth optimizing too. memset(r->avail_cache, 0, sizeof(r->avail_cache)); - fill_rectangle(r->avail_cache + 5, 2, 2, 4, 1, 4); + fill_rectangle(r->avail_cache + 6, 2, 2, 4, 1, 4); dist = (s->mb_x - s->resync_mb_x) + (s->mb_y - s->resync_mb_y) * s->mb_width; if(s->mb_x && dist) - r->avail_cache[4] = - r->avail_cache[8] = s->current_picture_ptr->mb_type[mb_pos - 1]; + r->avail_cache[5] = + r->avail_cache[9] = s->current_picture_ptr->mb_type[mb_pos - 1]; if(dist >= s->mb_width) - r->avail_cache[1] = - r->avail_cache[2] = s->current_picture_ptr->mb_type[mb_pos - s->mb_stride]; + r->avail_cache[2] = + r->avail_cache[3] = s->current_picture_ptr->mb_type[mb_pos - s->mb_stride]; if(((s->mb_x+1) < s->mb_width) && dist >= s->mb_width - 1) - r->avail_cache[3] = s->current_picture_ptr->mb_type[mb_pos - s->mb_stride + 1]; + r->avail_cache[4] = s->current_picture_ptr->mb_type[mb_pos - s->mb_stride + 1]; if(s->mb_x && dist > s->mb_width) - r->avail_cache[0] = s->current_picture_ptr->mb_type[mb_pos - s->mb_stride - 1]; + r->avail_cache[1] = s->current_picture_ptr->mb_type[mb_pos - s->mb_stride - 1]; s->qscale = r->si.quant; cbp = cbp2 = rv34_decode_mb_header(r, intra_types); diff -r 6cade2cdd63b -r d0f2f4e4436c rv40.c --- a/rv40.c Sat Aug 29 21:04:18 2009 +0000 +++ b/rv40.c Sun Aug 30 06:16:33 2009 +0000 @@ -235,13 +235,13 @@ if(--r->s.mb_skip_run) return RV34_MB_SKIP; - if(r->avail_cache[5-1]) + if(r->avail_cache[6-1]) blocks[r->mb_type[mb_pos - 1]]++; - if(r->avail_cache[5-4]){ + if(r->avail_cache[6-4]){ blocks[r->mb_type[mb_pos - s->mb_stride]]++; - if(r->avail_cache[5-2]) + if(r->avail_cache[6-2]) blocks[r->mb_type[mb_pos - s->mb_stride + 1]]++; - if(r->avail_cache[5-5]) + if(r->avail_cache[6-5]) blocks[r->mb_type[mb_pos - s->mb_stride - 1]]++; }