Mercurial > libavcodec.hg
comparison h264.c @ 6310:f0457c910be3 libavcodec
fix mbaff diagonal neighbor mv
author | lorenm |
---|---|
date | Sat, 02 Feb 2008 10:53:15 +0000 |
parents | af4b8e1f9b6c |
children | 985f4195bb69 |
comparison
equal
deleted
inserted
replaced
6309:af4b8e1f9b6c | 6310:f0457c910be3 |
---|---|
80 MpegEncContext * const s = &h->s; | 80 MpegEncContext * const s = &h->s; |
81 const int mb_xy= s->mb_x + s->mb_y*s->mb_stride; | 81 const int mb_xy= s->mb_x + s->mb_y*s->mb_stride; |
82 int topleft_xy, top_xy, topright_xy, left_xy[2]; | 82 int topleft_xy, top_xy, topright_xy, left_xy[2]; |
83 int topleft_type, top_type, topright_type, left_type[2]; | 83 int topleft_type, top_type, topright_type, left_type[2]; |
84 int left_block[8]; | 84 int left_block[8]; |
85 int topleft_partition= -1; | |
85 int i; | 86 int i; |
86 | 87 |
87 top_xy = mb_xy - (s->mb_stride << FIELD_PICTURE); | 88 top_xy = mb_xy - (s->mb_stride << FIELD_PICTURE); |
88 | 89 |
89 //FIXME deblocking could skip the intra and nnz parts. | 90 //FIXME deblocking could skip the intra and nnz parts. |
124 if (bottom | 125 if (bottom |
125 ? !curr_mb_frame_flag // bottom macroblock | 126 ? !curr_mb_frame_flag // bottom macroblock |
126 : (!curr_mb_frame_flag && !topleft_mb_frame_flag) // top macroblock | 127 : (!curr_mb_frame_flag && !topleft_mb_frame_flag) // top macroblock |
127 ) { | 128 ) { |
128 topleft_xy -= s->mb_stride; | 129 topleft_xy -= s->mb_stride; |
130 } else if(bottom && curr_mb_frame_flag && !left_mb_frame_flag) { | |
131 topleft_xy += s->mb_stride; | |
132 // take topleft mv from the middle of the mb, as opposed to all other modes which use the bottom-right partition | |
133 topleft_partition = 0; | |
129 } | 134 } |
130 if (bottom | 135 if (bottom |
131 ? !curr_mb_frame_flag // bottom macroblock | 136 ? !curr_mb_frame_flag // bottom macroblock |
132 : (!curr_mb_frame_flag && !topright_mb_frame_flag) // top macroblock | 137 : (!curr_mb_frame_flag && !topright_mb_frame_flag) // top macroblock |
133 ) { | 138 ) { |
401 | 406 |
402 if((for_deblock || (IS_DIRECT(mb_type) && !h->direct_spatial_mv_pred)) && !FRAME_MBAFF) | 407 if((for_deblock || (IS_DIRECT(mb_type) && !h->direct_spatial_mv_pred)) && !FRAME_MBAFF) |
403 continue; | 408 continue; |
404 | 409 |
405 if(USES_LIST(topleft_type, list)){ | 410 if(USES_LIST(topleft_type, list)){ |
406 const int b_xy = h->mb2b_xy[topleft_xy] + 3 + 3*h->b_stride; | 411 const int b_xy = h->mb2b_xy[topleft_xy] + 3 + h->b_stride + (topleft_partition & 2*h->b_stride); |
407 const int b8_xy= h->mb2b8_xy[topleft_xy] + 1 + h->b8_stride; | 412 const int b8_xy= h->mb2b8_xy[topleft_xy] + 1 + (topleft_partition & h->b8_stride); |
408 *(uint32_t*)h->mv_cache[list][scan8[0] - 1 - 1*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy]; | 413 *(uint32_t*)h->mv_cache[list][scan8[0] - 1 - 1*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy]; |
409 h->ref_cache[list][scan8[0] - 1 - 1*8]= s->current_picture.ref_index[list][b8_xy]; | 414 h->ref_cache[list][scan8[0] - 1 - 1*8]= s->current_picture.ref_index[list][b8_xy]; |
410 }else{ | 415 }else{ |
411 *(uint32_t*)h->mv_cache[list][scan8[0] - 1 - 1*8]= 0; | 416 *(uint32_t*)h->mv_cache[list][scan8[0] - 1 - 1*8]= 0; |
412 h->ref_cache[list][scan8[0] - 1 - 1*8]= topleft_type ? LIST_NOT_USED : PART_NOT_AVAILABLE; | 417 h->ref_cache[list][scan8[0] - 1 - 1*8]= topleft_type ? LIST_NOT_USED : PART_NOT_AVAILABLE; |
699 int topright_xy = s->mb_x + (s->mb_y-1)*s->mb_stride + (i == scan8[0]+3); | 704 int topright_xy = s->mb_x + (s->mb_y-1)*s->mb_stride + (i == scan8[0]+3); |
700 if(IS_INTERLACED(mb_types[topright_xy])){ | 705 if(IS_INTERLACED(mb_types[topright_xy])){ |
701 #define SET_DIAG_MV(MV_OP, REF_OP, X4, Y4)\ | 706 #define SET_DIAG_MV(MV_OP, REF_OP, X4, Y4)\ |
702 const int x4 = X4, y4 = Y4;\ | 707 const int x4 = X4, y4 = Y4;\ |
703 const int mb_type = mb_types[(x4>>2)+(y4>>2)*s->mb_stride];\ | 708 const int mb_type = mb_types[(x4>>2)+(y4>>2)*s->mb_stride];\ |
704 if(!USES_LIST(mb_type,list) && !IS_8X8(mb_type))\ | 709 if(!USES_LIST(mb_type,list))\ |
705 return LIST_NOT_USED;\ | 710 return LIST_NOT_USED;\ |
706 mv = s->current_picture_ptr->motion_val[list][x4 + y4*h->b_stride];\ | 711 mv = s->current_picture_ptr->motion_val[list][x4 + y4*h->b_stride];\ |
707 h->mv_cache[list][scan8[0]-2][0] = mv[0];\ | 712 h->mv_cache[list][scan8[0]-2][0] = mv[0];\ |
708 h->mv_cache[list][scan8[0]-2][1] = mv[1] MV_OP;\ | 713 h->mv_cache[list][scan8[0]-2][1] = mv[1] MV_OP;\ |
709 return s->current_picture_ptr->ref_index[list][(x4>>1) + (y4>>1)*h->b8_stride] REF_OP; | 714 return s->current_picture_ptr->ref_index[list][(x4>>1) + (y4>>1)*h->b8_stride] REF_OP; |
720 } | 725 } |
721 if(MB_FIELD | 726 if(MB_FIELD |
722 && !IS_INTERLACED(mb_types[h->left_mb_xy[0]]) | 727 && !IS_INTERLACED(mb_types[h->left_mb_xy[0]]) |
723 && i >= scan8[0]+8){ | 728 && i >= scan8[0]+8){ |
724 // leftshift will turn LIST_NOT_USED into PART_NOT_AVAILABLE, but that's ok. | 729 // leftshift will turn LIST_NOT_USED into PART_NOT_AVAILABLE, but that's ok. |
725 SET_DIAG_MV(>>1, <<1, s->mb_x*4-1, (s->mb_y&~1)*4 - 1 + ((i-scan8[0])>>3)*2); | 730 SET_DIAG_MV(/2, <<1, s->mb_x*4-1, (s->mb_y&~1)*4 - 1 + ((i-scan8[0])>>3)*2); |
726 } | 731 } |
727 } | 732 } |
728 #undef SET_DIAG_MV | 733 #undef SET_DIAG_MV |
729 } | 734 } |
730 | 735 |