comparison h264.c @ 5106:ddb5abe164f3 libavcodec

h264: use 'simple' in border backup / xchg patch by Andreas ªÓman: [andreas olebyn nu] original thread: subject: [FFmpeg-devel] [patch] h264: use 'simple' in border backup / xchg date: 06/07/2007 03:24 PM
author benoit
date Thu, 07 Jun 2007 13:51:06 +0000
parents f0ffa056b77c
children 4dbe6578f811
comparison
equal deleted inserted replaced
5105:bdd2625a8ac5 5106:ddb5abe164f3
2986 2986
2987 // s->decode= (s->flags&CODEC_FLAG_PSNR) || !s->encoding || s->current_picture.reference /*|| h->contains_intra*/ || 1; 2987 // s->decode= (s->flags&CODEC_FLAG_PSNR) || !s->encoding || s->current_picture.reference /*|| h->contains_intra*/ || 1;
2988 return 0; 2988 return 0;
2989 } 2989 }
2990 2990
2991 static inline void backup_mb_border(H264Context *h, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr, int linesize, int uvlinesize){ 2991 static inline void backup_mb_border(H264Context *h, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr, int linesize, int uvlinesize, int simple){
2992 MpegEncContext * const s = &h->s; 2992 MpegEncContext * const s = &h->s;
2993 int i; 2993 int i;
2994 2994
2995 src_y -= linesize; 2995 src_y -= linesize;
2996 src_cb -= uvlinesize; 2996 src_cb -= uvlinesize;
3004 } 3004 }
3005 3005
3006 *(uint64_t*)(h->top_borders[0][s->mb_x]+0)= *(uint64_t*)(src_y + 16*linesize); 3006 *(uint64_t*)(h->top_borders[0][s->mb_x]+0)= *(uint64_t*)(src_y + 16*linesize);
3007 *(uint64_t*)(h->top_borders[0][s->mb_x]+8)= *(uint64_t*)(src_y +8+16*linesize); 3007 *(uint64_t*)(h->top_borders[0][s->mb_x]+8)= *(uint64_t*)(src_y +8+16*linesize);
3008 3008
3009 if(!(s->flags&CODEC_FLAG_GRAY)){ 3009 if(simple || !(s->flags&CODEC_FLAG_GRAY)){
3010 h->left_border[17 ]= h->top_borders[0][s->mb_x][16+7]; 3010 h->left_border[17 ]= h->top_borders[0][s->mb_x][16+7];
3011 h->left_border[17+9]= h->top_borders[0][s->mb_x][24+7]; 3011 h->left_border[17+9]= h->top_borders[0][s->mb_x][24+7];
3012 for(i=1; i<9; i++){ 3012 for(i=1; i<9; i++){
3013 h->left_border[i+17 ]= src_cb[7+i*uvlinesize]; 3013 h->left_border[i+17 ]= src_cb[7+i*uvlinesize];
3014 h->left_border[i+17+9]= src_cr[7+i*uvlinesize]; 3014 h->left_border[i+17+9]= src_cr[7+i*uvlinesize];
3016 *(uint64_t*)(h->top_borders[0][s->mb_x]+16)= *(uint64_t*)(src_cb+8*uvlinesize); 3016 *(uint64_t*)(h->top_borders[0][s->mb_x]+16)= *(uint64_t*)(src_cb+8*uvlinesize);
3017 *(uint64_t*)(h->top_borders[0][s->mb_x]+24)= *(uint64_t*)(src_cr+8*uvlinesize); 3017 *(uint64_t*)(h->top_borders[0][s->mb_x]+24)= *(uint64_t*)(src_cr+8*uvlinesize);
3018 } 3018 }
3019 } 3019 }
3020 3020
3021 static inline void xchg_mb_border(H264Context *h, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr, int linesize, int uvlinesize, int xchg){ 3021 static inline void xchg_mb_border(H264Context *h, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr, int linesize, int uvlinesize, int xchg, int simple){
3022 MpegEncContext * const s = &h->s; 3022 MpegEncContext * const s = &h->s;
3023 int temp8, i; 3023 int temp8, i;
3024 uint64_t temp64; 3024 uint64_t temp64;
3025 int deblock_left = (s->mb_x > 0); 3025 int deblock_left = (s->mb_x > 0);
3026 int deblock_top = (s->mb_y > 0); 3026 int deblock_top = (s->mb_y > 0);
3047 if(s->mb_x+1 < s->mb_width){ 3047 if(s->mb_x+1 < s->mb_width){
3048 XCHG(*(uint64_t*)(h->top_borders[0][s->mb_x+1]), *(uint64_t*)(src_y +17), temp64, 1); 3048 XCHG(*(uint64_t*)(h->top_borders[0][s->mb_x+1]), *(uint64_t*)(src_y +17), temp64, 1);
3049 } 3049 }
3050 } 3050 }
3051 3051
3052 if(!(s->flags&CODEC_FLAG_GRAY)){ 3052 if(simple || !(s->flags&CODEC_FLAG_GRAY)){
3053 if(deblock_left){ 3053 if(deblock_left){
3054 for(i = !deblock_top; i<9; i++){ 3054 for(i = !deblock_top; i<9; i++){
3055 XCHG(h->left_border[i+17 ], src_cb[i*uvlinesize], temp8, xchg); 3055 XCHG(h->left_border[i+17 ], src_cb[i*uvlinesize], temp8, xchg);
3056 XCHG(h->left_border[i+17+9], src_cr[i*uvlinesize], temp8, xchg); 3056 XCHG(h->left_border[i+17+9], src_cr[i*uvlinesize], temp8, xchg);
3057 } 3057 }
3254 } 3254 }
3255 } 3255 }
3256 } else { 3256 } else {
3257 if(IS_INTRA(mb_type)){ 3257 if(IS_INTRA(mb_type)){
3258 if(h->deblocking_filter && (simple || !FRAME_MBAFF)) 3258 if(h->deblocking_filter && (simple || !FRAME_MBAFF))
3259 xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 1); 3259 xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 1, simple);
3260 3260
3261 if(simple || !(s->flags&CODEC_FLAG_GRAY)){ 3261 if(simple || !(s->flags&CODEC_FLAG_GRAY)){
3262 h->pred8x8[ h->chroma_pred_mode ](dest_cb, uvlinesize); 3262 h->pred8x8[ h->chroma_pred_mode ](dest_cb, uvlinesize);
3263 h->pred8x8[ h->chroma_pred_mode ](dest_cr, uvlinesize); 3263 h->pred8x8[ h->chroma_pred_mode ](dest_cr, uvlinesize);
3264 } 3264 }
3317 h264_luma_dc_dequant_idct_c(h->mb, s->qscale, h->dequant4_coeff[IS_INTRA(mb_type) ? 0:3][s->qscale][0]); 3317 h264_luma_dc_dequant_idct_c(h->mb, s->qscale, h->dequant4_coeff[IS_INTRA(mb_type) ? 0:3][s->qscale][0]);
3318 }else 3318 }else
3319 svq3_luma_dc_dequant_idct_c(h->mb, s->qscale); 3319 svq3_luma_dc_dequant_idct_c(h->mb, s->qscale);
3320 } 3320 }
3321 if(h->deblocking_filter && (simple || !FRAME_MBAFF)) 3321 if(h->deblocking_filter && (simple || !FRAME_MBAFF))
3322 xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 0); 3322 xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 0, simple);
3323 }else if(is_h264){ 3323 }else if(is_h264){
3324 hl_motion(h, dest_y, dest_cb, dest_cr, 3324 hl_motion(h, dest_y, dest_cb, dest_cr,
3325 s->me.qpel_put, s->dsp.put_h264_chroma_pixels_tab, 3325 s->me.qpel_put, s->dsp.put_h264_chroma_pixels_tab,
3326 s->me.qpel_avg, s->dsp.avg_h264_chroma_pixels_tab, 3326 s->me.qpel_avg, s->dsp.avg_h264_chroma_pixels_tab,
3327 s->dsp.weight_h264_pixels_tab, s->dsp.biweight_h264_pixels_tab); 3327 s->dsp.weight_h264_pixels_tab, s->dsp.biweight_h264_pixels_tab);
3417 fill_caches(h, mb_type_bottom, 1); //FIXME don't fill stuff which isn't used by filter_mb 3417 fill_caches(h, mb_type_bottom, 1); //FIXME don't fill stuff which isn't used by filter_mb
3418 h->chroma_qp = get_chroma_qp(h->pps.chroma_qp_index_offset, s->current_picture.qscale_table[mb_xy+s->mb_stride]); 3418 h->chroma_qp = get_chroma_qp(h->pps.chroma_qp_index_offset, s->current_picture.qscale_table[mb_xy+s->mb_stride]);
3419 filter_mb(h, mb_x, mb_y+1, dest_y, dest_cb, dest_cr, linesize, uvlinesize); 3419 filter_mb(h, mb_x, mb_y+1, dest_y, dest_cb, dest_cr, linesize, uvlinesize);
3420 } else { 3420 } else {
3421 tprintf(h->s.avctx, "call filter_mb\n"); 3421 tprintf(h->s.avctx, "call filter_mb\n");
3422 backup_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize); 3422 backup_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, simple);
3423 fill_caches(h, mb_type, 1); //FIXME don't fill stuff which isn't used by filter_mb 3423 fill_caches(h, mb_type, 1); //FIXME don't fill stuff which isn't used by filter_mb
3424 filter_mb_fast(h, mb_x, mb_y, dest_y, dest_cb, dest_cr, linesize, uvlinesize); 3424 filter_mb_fast(h, mb_x, mb_y, dest_y, dest_cb, dest_cr, linesize, uvlinesize);
3425 } 3425 }
3426 } 3426 }
3427 } 3427 }