comparison vc1.c @ 3474:24f293c3f3ef libavcodec

Rounding control for motion compensation.
author kostya
date Sun, 16 Jul 2006 03:45:04 +0000
parents ad66c11aeab4
children 4e06affe9974
comparison
equal deleted inserted replaced
3473:fa545ed305c9 3474:24f293c3f3ef
318 uint8_t* mv_type_mb_plane; ///< bitplane for mv_type == (4MV) 318 uint8_t* mv_type_mb_plane; ///< bitplane for mv_type == (4MV)
319 // BitPlane direct_mb_plane; ///< bitplane for "direct" MBs 319 // BitPlane direct_mb_plane; ///< bitplane for "direct" MBs
320 int mv_type_is_raw; ///< mv type mb plane is not coded 320 int mv_type_is_raw; ///< mv type mb plane is not coded
321 int skip_is_raw; ///< skip mb plane is not coded 321 int skip_is_raw; ///< skip mb plane is not coded
322 uint8_t luty[256], lutuv[256]; // lookup tables used for intensity compensation 322 uint8_t luty[256], lutuv[256]; // lookup tables used for intensity compensation
323 int rnd; ///< rounding control
323 324
324 /** Frame decoding info for S/M profiles only */ 325 /** Frame decoding info for S/M profiles only */
325 //@{ 326 //@{
326 uint8_t rangeredfrm; ///< out_sample = CLIP((in_sample-128)*2+128) 327 uint8_t rangeredfrm; ///< out_sample = CLIP((in_sample-128)*2+128)
327 uint8_t interpfrm; 328 uint8_t interpfrm;
976 if(!s->quarter_sample) { // hpel mc 977 if(!s->quarter_sample) { // hpel mc
977 mx >>= 1; 978 mx >>= 1;
978 my >>= 1; 979 my >>= 1;
979 dxy = ((my & 1) << 1) | (mx & 1); 980 dxy = ((my & 1) << 1) | (mx & 1);
980 981
981 dsp->put_no_rnd_pixels_tab[0][dxy](s->dest[0], srcY, s->linesize, 16); 982 if(!v->rnd)
983 dsp->put_pixels_tab[0][dxy](s->dest[0], srcY, s->linesize, 16);
984 else
985 dsp->put_no_rnd_pixels_tab[0][dxy](s->dest[0], srcY, s->linesize, 16);
982 } else { 986 } else {
983 dxy = ((my & 3) << 2) | (mx & 3); 987 dxy = ((my & 3) << 2) | (mx & 3);
984 988
985 dsp->put_no_rnd_qpel_pixels_tab[0][dxy](s->dest[0], srcY, s->linesize); 989 if(!v->rnd)
986 } 990 dsp->put_qpel_pixels_tab[0][dxy](s->dest[0], srcY, s->linesize);
987 uvmx >>= 1; 991 else
988 uvmy >>= 1; 992 dsp->put_no_rnd_qpel_pixels_tab[0][dxy](s->dest[0], srcY, s->linesize);
989 uvdxy = ((uvmy & 1) << 1) | (uvmx & 1); 993 }
990 dsp->put_no_rnd_pixels_tab[1][uvdxy](s->dest[1], srcU, s->uvlinesize, 8); 994 /* Chroma MC always uses qpel blilinear */
991 dsp->put_no_rnd_pixels_tab[1][uvdxy](s->dest[2], srcV, s->uvlinesize, 8); 995 uvdxy = ((uvmy & 3) << 2) | (uvmx & 3);
992 // dsp->put_mspel_pixels_tab[uvdxy](s->dest[1], srcU, s->uvlinesize); 996 if(!v->rnd){
993 // dsp->put_mspel_pixels_tab[uvdxy](s->dest[2], srcV, s->uvlinesize); 997 dsp->put_qpel_pixels_tab[1][uvdxy](s->dest[1], srcU, s->uvlinesize);
998 dsp->put_qpel_pixels_tab[1][uvdxy](s->dest[2], srcV, s->uvlinesize);
999 }else{
1000 dsp->put_no_rnd_qpel_pixels_tab[1][uvdxy](s->dest[1], srcU, s->uvlinesize);
1001 dsp->put_no_rnd_qpel_pixels_tab[1][uvdxy](s->dest[2], srcV, s->uvlinesize);
1002 }
994 } 1003 }
995 1004
996 /** Do motion compensation for 4-MV macroblock - luminance block 1005 /** Do motion compensation for 4-MV macroblock - luminance block
997 */ 1006 */
998 static void vc1_mc_4mv_luma(VC1Context *v, int n) 1007 static void vc1_mc_4mv_luma(VC1Context *v, int n)
1028 if(!s->quarter_sample) { // hpel mc 1037 if(!s->quarter_sample) { // hpel mc
1029 mx >>= 1; 1038 mx >>= 1;
1030 my >>= 1; 1039 my >>= 1;
1031 dxy = ((my & 1) << 1) | (mx & 1); 1040 dxy = ((my & 1) << 1) | (mx & 1);
1032 1041
1033 dsp->put_no_rnd_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize, 8); 1042 if(!v->rnd)
1043 dsp->put_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize, 8);
1044 else
1045 dsp->put_no_rnd_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize, 8);
1034 } else { 1046 } else {
1035 dxy = ((my & 3) << 2) | (mx & 3); 1047 dxy = ((my & 3) << 2) | (mx & 3);
1036 1048
1037 dsp->put_no_rnd_qpel_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize); 1049 if(!v->rnd)
1050 dsp->put_qpel_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize);
1051 else
1052 dsp->put_no_rnd_qpel_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize);
1038 } 1053 }
1039 } 1054 }
1040 1055
1041 static inline int median4(int a, int b, int c, int d) 1056 static inline int median4(int a, int b, int c, int d)
1042 { 1057 {
1126 if(v->fastuvmc) { 1141 if(v->fastuvmc) {
1127 uvmx = uvmx + ((uvmx<0)?(uvmx&1):-(uvmx&1)); 1142 uvmx = uvmx + ((uvmx<0)?(uvmx&1):-(uvmx&1));
1128 uvmy = uvmy + ((uvmy<0)?(uvmy&1):-(uvmy&1)); 1143 uvmy = uvmy + ((uvmy<0)?(uvmy&1):-(uvmy&1));
1129 } 1144 }
1130 1145
1131 uvmx >>= 1; 1146 /* Chroma MC always uses qpel blilinear */
1132 uvmy >>= 1; 1147 uvdxy = ((uvmy & 3) << 2) | (uvmx & 3);
1133 uvdxy = ((uvmy & 1) << 1) | (uvmx & 1); 1148 if(!v->rnd){
1134 dsp->put_no_rnd_pixels_tab[1][uvdxy](s->dest[1], srcU, s->uvlinesize, 8); 1149 dsp->put_qpel_pixels_tab[1][uvdxy](s->dest[1], srcU, s->uvlinesize);
1135 dsp->put_no_rnd_pixels_tab[1][uvdxy](s->dest[2], srcV, s->uvlinesize, 8); 1150 dsp->put_qpel_pixels_tab[1][uvdxy](s->dest[2], srcV, s->uvlinesize);
1151 }else{
1152 dsp->put_no_rnd_qpel_pixels_tab[1][uvdxy](s->dest[1], srcU, s->uvlinesize);
1153 dsp->put_no_rnd_qpel_pixels_tab[1][uvdxy](s->dest[2], srcV, s->uvlinesize);
1154 }
1136 } 1155 }
1137 1156
1138 /** 1157 /**
1139 * Decode Simple/Main Profiles sequence header 1158 * Decode Simple/Main Profiles sequence header
1140 * @see Figure 7-8, p16-17 1159 * @see Figure 7-8, p16-17
1296 } else v->s.pict_type = P_TYPE; 1315 } else v->s.pict_type = P_TYPE;
1297 } else v->s.pict_type = v->s.pict_type ? P_TYPE : I_TYPE; 1316 } else v->s.pict_type = v->s.pict_type ? P_TYPE : I_TYPE;
1298 1317
1299 if(v->s.pict_type == I_TYPE) 1318 if(v->s.pict_type == I_TYPE)
1300 get_bits(gb, 7); // skip buffer fullness 1319 get_bits(gb, 7); // skip buffer fullness
1320
1321 /* calculate RND */
1322 if(v->s.pict_type == I_TYPE)
1323 v->rnd = 1;
1324 if(v->s.pict_type == P_TYPE)
1325 v->rnd ^= 1;
1301 1326
1302 /* Quantizer stuff */ 1327 /* Quantizer stuff */
1303 pqindex = get_bits(gb, 5); 1328 pqindex = get_bits(gb, 5);
1304 if (v->quantizer_mode == QUANT_FRAME_IMPLICIT) 1329 if (v->quantizer_mode == QUANT_FRAME_IMPLICIT)
1305 v->pq = pquant_table[0][pqindex]; 1330 v->pq = pquant_table[0][pqindex];