comparison h264.c @ 6309:af4b8e1f9b6c libavcodec

mbaff spatial direct
author lorenm
date Sat, 02 Feb 2008 10:51:56 +0000
parents 5a882b31308b
children f0457c910be3
comparison
equal deleted inserted replaced
6308:195356fc7230 6309:af4b8e1f9b6c
1015 mv[list][0] = mv[list][1] = 0; 1015 mv[list][0] = mv[list][1] = 0;
1016 } 1016 }
1017 } 1017 }
1018 1018
1019 if(ref[1] < 0){ 1019 if(ref[1] < 0){
1020 *mb_type &= ~MB_TYPE_P0L1; 1020 if(!is_b8x8)
1021 sub_mb_type &= ~MB_TYPE_P0L1; 1021 *mb_type &= ~MB_TYPE_L1;
1022 sub_mb_type &= ~MB_TYPE_L1;
1022 }else if(ref[0] < 0){ 1023 }else if(ref[0] < 0){
1023 *mb_type &= ~MB_TYPE_P0L0; 1024 if(!is_b8x8)
1024 sub_mb_type &= ~MB_TYPE_P0L0; 1025 *mb_type &= ~MB_TYPE_L0;
1025 } 1026 sub_mb_type &= ~MB_TYPE_L0;
1026 1027 }
1027 if(IS_16X16(*mb_type)){ 1028
1029 if(IS_INTERLACED(*mb_type) != IS_INTERLACED(mb_type_col)){
1030 int pair_xy = s->mb_x + (s->mb_y&~1)*s->mb_stride;
1031 int mb_types_col[2];
1032 int b8_stride = h->b8_stride;
1033 int b4_stride = h->b_stride;
1034
1035 *mb_type = (*mb_type & ~MB_TYPE_16x16) | MB_TYPE_8x8;
1036
1037 if(IS_INTERLACED(*mb_type)){
1038 mb_types_col[0] = h->ref_list[1][0].mb_type[pair_xy];
1039 mb_types_col[1] = h->ref_list[1][0].mb_type[pair_xy+s->mb_stride];
1040 if(s->mb_y&1){
1041 l1ref0 -= 2*b8_stride;
1042 l1ref1 -= 2*b8_stride;
1043 l1mv0 -= 4*b4_stride;
1044 l1mv1 -= 4*b4_stride;
1045 }
1046 b8_stride *= 3;
1047 b4_stride *= 6;
1048 }else{
1049 int cur_poc = s->current_picture_ptr->poc;
1050 int *col_poc = h->ref_list[1]->field_poc;
1051 int col_parity = FFABS(col_poc[0] - cur_poc) >= FFABS(col_poc[1] - cur_poc);
1052 int dy = 2*col_parity - (s->mb_y&1);
1053 mb_types_col[0] =
1054 mb_types_col[1] = h->ref_list[1][0].mb_type[pair_xy + col_parity*s->mb_stride];
1055 l1ref0 += dy*b8_stride;
1056 l1ref1 += dy*b8_stride;
1057 l1mv0 += 2*dy*b4_stride;
1058 l1mv1 += 2*dy*b4_stride;
1059 b8_stride = 0;
1060 }
1061
1062 for(i8=0; i8<4; i8++){
1063 int x8 = i8&1;
1064 int y8 = i8>>1;
1065 int xy8 = x8+y8*b8_stride;
1066 int xy4 = 3*x8+y8*b4_stride;
1067 int a=0, b=0;
1068
1069 if(is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8]))
1070 continue;
1071 h->sub_mb_type[i8] = sub_mb_type;
1072
1073 fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, (uint8_t)ref[0], 1);
1074 fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, (uint8_t)ref[1], 1);
1075 if(!IS_INTRA(mb_types_col[y8])
1076 && ( (l1ref0[xy8] == 0 && FFABS(l1mv0[xy4][0]) <= 1 && FFABS(l1mv0[xy4][1]) <= 1)
1077 || (l1ref0[xy8] < 0 && l1ref1[xy8] == 0 && FFABS(l1mv1[xy4][0]) <= 1 && FFABS(l1mv1[xy4][1]) <= 1))){
1078 if(ref[0] > 0)
1079 a= pack16to32(mv[0][0],mv[0][1]);
1080 if(ref[1] > 0)
1081 b= pack16to32(mv[1][0],mv[1][1]);
1082 }else{
1083 a= pack16to32(mv[0][0],mv[0][1]);
1084 b= pack16to32(mv[1][0],mv[1][1]);
1085 }
1086 fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, a, 4);
1087 fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, b, 4);
1088 }
1089 }else if(IS_16X16(*mb_type)){
1028 int a=0, b=0; 1090 int a=0, b=0;
1029 1091
1030 fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, (uint8_t)ref[0], 1); 1092 fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, (uint8_t)ref[0], 1);
1031 fill_rectangle(&h->ref_cache[1][scan8[0]], 4, 4, 8, (uint8_t)ref[1], 1); 1093 fill_rectangle(&h->ref_cache[1][scan8[0]], 4, 4, 8, (uint8_t)ref[1], 1);
1032 if(!IS_INTRA(mb_type_col) 1094 if(!IS_INTRA(mb_type_col)
4044 h->ref_count[1]= h->pps.ref_count[1]; 4106 h->ref_count[1]= h->pps.ref_count[1];
4045 4107
4046 if(h->slice_type == P_TYPE || h->slice_type == SP_TYPE || h->slice_type == B_TYPE){ 4108 if(h->slice_type == P_TYPE || h->slice_type == SP_TYPE || h->slice_type == B_TYPE){
4047 if(h->slice_type == B_TYPE){ 4109 if(h->slice_type == B_TYPE){
4048 h->direct_spatial_mv_pred= get_bits1(&s->gb); 4110 h->direct_spatial_mv_pred= get_bits1(&s->gb);
4049 if(FIELD_OR_MBAFF_PICTURE && h->direct_spatial_mv_pred)
4050 av_log(h->s.avctx, AV_LOG_ERROR, "Interlaced pictures + spatial direct mode is not implemented\n");
4051 } 4111 }
4052 num_ref_idx_active_override_flag= get_bits1(&s->gb); 4112 num_ref_idx_active_override_flag= get_bits1(&s->gb);
4053 4113
4054 if(num_ref_idx_active_override_flag){ 4114 if(num_ref_idx_active_override_flag){
4055 h->ref_count[0]= get_ue_golomb(&s->gb) + 1; 4115 h->ref_count[0]= get_ue_golomb(&s->gb) + 1;