comparison cavs.c @ 3472:0e0cffe06fb3 libavcodec

avoid double copying of left border in luma prediction
author stefang
date Fri, 14 Jul 2006 19:31:58 +0000
parents c2db6e76b269
children 419409926166
comparison
equal deleted inserted replaced
3471:c2db6e76b269 3472:0e0cffe06fb3
80 int cbp; 80 int cbp;
81 81
82 /** intra prediction is done with un-deblocked samples 82 /** intra prediction is done with un-deblocked samples
83 they are saved here before deblocking the MB */ 83 they are saved here before deblocking the MB */
84 uint8_t *top_border_y, *top_border_u, *top_border_v; 84 uint8_t *top_border_y, *top_border_u, *top_border_v;
85 uint8_t left_border_y[16], left_border_u[10], left_border_v[10]; 85 uint8_t left_border_y[26], left_border_u[10], left_border_v[10];
86 uint8_t intern_border_y[26];
86 uint8_t topleft_border_y, topleft_border_u, topleft_border_v; 87 uint8_t topleft_border_y, topleft_border_u, topleft_border_v;
87 88
88 void (*intra_pred_l[8])(uint8_t *d,uint8_t *top,uint8_t *left,int stride); 89 void (*intra_pred_l[8])(uint8_t *d,uint8_t *top,uint8_t *left,int stride);
89 void (*intra_pred_c[7])(uint8_t *d,uint8_t *top,uint8_t *left,int stride); 90 void (*intra_pred_c[7])(uint8_t *d,uint8_t *top,uint8_t *left,int stride);
90 uint8_t *col_type_base; 91 uint8_t *col_type_base;
149 h->topleft_border_v = h->top_border_v[h->mbx*10+8]; 150 h->topleft_border_v = h->top_border_v[h->mbx*10+8];
150 memcpy(&h->top_border_y[h->mbx*16], h->cy + 15* h->l_stride,16); 151 memcpy(&h->top_border_y[h->mbx*16], h->cy + 15* h->l_stride,16);
151 memcpy(&h->top_border_u[h->mbx*10+1], h->cu + 7* h->c_stride,8); 152 memcpy(&h->top_border_u[h->mbx*10+1], h->cu + 7* h->c_stride,8);
152 memcpy(&h->top_border_v[h->mbx*10+1], h->cv + 7* h->c_stride,8); 153 memcpy(&h->top_border_v[h->mbx*10+1], h->cv + 7* h->c_stride,8);
153 for(i=0;i<8;i++) { 154 for(i=0;i<8;i++) {
154 h->left_border_y[i*2+0] = *(h->cy + 15 + (i*2+0)*h->l_stride); 155 h->left_border_y[i*2+1] = *(h->cy + 15 + (i*2+0)*h->l_stride);
155 h->left_border_y[i*2+1] = *(h->cy + 15 + (i*2+1)*h->l_stride); 156 h->left_border_y[i*2+2] = *(h->cy + 15 + (i*2+1)*h->l_stride);
156 h->left_border_u[i+1] = *(h->cu + 7 + i*h->c_stride); 157 h->left_border_u[i+1] = *(h->cu + 7 + i*h->c_stride);
157 h->left_border_v[i+1] = *(h->cv + 7 + i*h->c_stride); 158 h->left_border_v[i+1] = *(h->cv + 7 + i*h->c_stride);
158 } 159 }
159 if(!h->loop_filter_disable) { 160 if(!h->loop_filter_disable) {
160 /* determine bs */ 161 /* determine bs */
209 * spatial intra prediction 210 * spatial intra prediction
210 * 211 *
211 ****************************************************************************/ 212 ****************************************************************************/
212 213
213 static inline void load_intra_pred_luma(AVSContext *h, uint8_t *top, 214 static inline void load_intra_pred_luma(AVSContext *h, uint8_t *top,
214 uint8_t *left, int block) { 215 uint8_t **left, int block) {
215 int i; 216 int i;
216 217
217 switch(block) { 218 switch(block) {
218 case 0: 219 case 0:
219 memcpy(&left[1],h->left_border_y,16); 220 *left = h->left_border_y;
220 left[0] = left[1]; 221 h->left_border_y[0] = h->left_border_y[1];
221 left[17] = left[16]; 222 memset(&h->left_border_y[17],h->left_border_y[16],9);
222 memcpy(&top[1],&h->top_border_y[h->mbx*16],16); 223 memcpy(&top[1],&h->top_border_y[h->mbx*16],16);
223 top[17] = top[16]; 224 top[17] = top[16];
224 top[0] = top[1]; 225 top[0] = top[1];
225 if((h->flags & A_AVAIL) && (h->flags & B_AVAIL)) 226 if((h->flags & A_AVAIL) && (h->flags & B_AVAIL))
226 left[0] = top[0] = h->topleft_border_y; 227 h->left_border_y[0] = top[0] = h->topleft_border_y;
227 break; 228 break;
228 case 1: 229 case 1:
230 *left = h->intern_border_y;
229 for(i=0;i<8;i++) 231 for(i=0;i<8;i++)
230 left[i+1] = *(h->cy + 7 + i*h->l_stride); 232 h->intern_border_y[i+1] = *(h->cy + 7 + i*h->l_stride);
231 memset(&left[9],left[8],9); 233 memset(&h->intern_border_y[9],h->intern_border_y[8],9);
232 left[0] = left[1]; 234 h->intern_border_y[0] = h->intern_border_y[1];
233 memcpy(&top[1],&h->top_border_y[h->mbx*16+8],8); 235 memcpy(&top[1],&h->top_border_y[h->mbx*16+8],8);
234 if(h->flags & C_AVAIL) 236 if(h->flags & C_AVAIL)
235 memcpy(&top[9],&h->top_border_y[(h->mbx + 1)*16],8); 237 memcpy(&top[9],&h->top_border_y[(h->mbx + 1)*16],8);
236 else 238 else
237 memset(&top[9],top[8],9); 239 memset(&top[9],top[8],9);
238 top[17] = top[16]; 240 top[17] = top[16];
239 top[0] = top[1]; 241 top[0] = top[1];
240 if(h->flags & B_AVAIL) 242 if(h->flags & B_AVAIL)
241 left[0] = top[0] = h->top_border_y[h->mbx*16+7]; 243 h->intern_border_y[0] = top[0] = h->top_border_y[h->mbx*16+7];
242 break; 244 break;
243 case 2: 245 case 2:
244 memcpy(&left[1],&h->left_border_y[8],8); 246 *left = &h->left_border_y[8];
245 memset(&left[9],left[8],9);
246 memcpy(&top[1],h->cy + 7*h->l_stride,16); 247 memcpy(&top[1],h->cy + 7*h->l_stride,16);
247 top[17] = top[16]; 248 top[17] = top[16];
248 left[0] = h->left_border_y[7];
249 top[0] = top[1]; 249 top[0] = top[1];
250 if(h->flags & A_AVAIL) 250 if(h->flags & A_AVAIL)
251 top[0] = left[0]; 251 top[0] = h->left_border_y[8];
252 break; 252 break;
253 case 3: 253 case 3:
254 for(i=0;i<9;i++) 254 *left = &h->intern_border_y[8];
255 left[i] = *(h->cy + 7 + (i+7)*h->l_stride); 255 for(i=0;i<8;i++)
256 memset(&left[9],left[8],9); 256 h->intern_border_y[i+9] = *(h->cy + 7 + (i+8)*h->l_stride);
257 memset(&h->intern_border_y[17],h->intern_border_y[16],9);
257 memcpy(&top[0],h->cy + 7 + 7*h->l_stride,9); 258 memcpy(&top[0],h->cy + 7 + 7*h->l_stride,9);
258 memset(&top[9],top[8],9); 259 memset(&top[9],top[8],9);
259 break; 260 break;
260 } 261 }
261 } 262 }
814 815
815 static int decode_mb_i(AVSContext *h, int cbp_code) { 816 static int decode_mb_i(AVSContext *h, int cbp_code) {
816 GetBitContext *gb = &h->s.gb; 817 GetBitContext *gb = &h->s.gb;
817 int block, pred_mode_uv; 818 int block, pred_mode_uv;
818 uint8_t top[18]; 819 uint8_t top[18];
819 uint8_t left[18]; 820 uint8_t *left = NULL;
820 uint8_t *d; 821 uint8_t *d;
821 822
822 init_mb(h); 823 init_mb(h);
823 824
824 /* get intra prediction modes from stream */ 825 /* get intra prediction modes from stream */
873 h->qp = (h->qp + get_se_golomb(gb)) & 63; //qp_delta 874 h->qp = (h->qp + get_se_golomb(gb)) & 63; //qp_delta
874 875
875 /* luma intra prediction interleaved with residual decode/transform/add */ 876 /* luma intra prediction interleaved with residual decode/transform/add */
876 for(block=0;block<4;block++) { 877 for(block=0;block<4;block++) {
877 d = h->cy + h->luma_scan[block]; 878 d = h->cy + h->luma_scan[block];
878 load_intra_pred_luma(h, top, left, block); 879 load_intra_pred_luma(h, top, &left, block);
879 h->intra_pred_l[h->pred_mode_Y[scan3x3[block]]] 880 h->intra_pred_l[h->pred_mode_Y[scan3x3[block]]]
880 (d, top, left, h->l_stride); 881 (d, top, left, h->l_stride);
881 if(h->cbp & (1<<block)) 882 if(h->cbp & (1<<block))
882 decode_residual_block(h,gb,intra_2dvlc,1,h->qp,d,h->l_stride); 883 decode_residual_block(h,gb,intra_2dvlc,1,h->qp,d,h->l_stride);
883 } 884 }