Changeset 221 for libmpc/branches/r2d/libmpcenc/encode_sv7.c
- Timestamp:
- 02/17/07 21:18:35 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libmpc/branches/r2d/libmpcenc/encode_sv7.c
r220 r221 129 129 int n; 130 130 const Huffman_t * Table, * Tables[2]; 131 mpc_int32_t * Res_L = e->Res_L; 132 mpc_int32_t * Res_R = e->Res_R; 133 mpc_bool_t * DSCF_Flag_L = e->DSCF_Flag_L; 134 mpc_bool_t * DSCF_Flag_R = e->DSCF_Flag_R; 135 mpc_int32_t * SCF_Last_L = e->SCF_Last_L; 136 mpc_int32_t * SCF_Last_R = e->SCF_Last_R; 131 137 132 138 for( n = MaxBand; n >= 0; n--) 133 if ( e->Res_L[n] != 0 || e->Res_R[n] != 0) break;139 if (Res_L[n] != 0 || Res_R[n] != 0) break; 134 140 135 141 n++; … … 147 153 148 154 if (MaxBand) { 149 writeBits(e, HuffRes[0][ e->Res_L[MaxBand - 1]].Code, HuffRes[0][e->Res_L[MaxBand - 1]].Length);150 writeBits(e, HuffRes[0][ e->Res_R[MaxBand - 1]].Code, HuffRes[0][e->Res_R[MaxBand - 1]].Length);155 writeBits(e, HuffRes[0][Res_L[MaxBand - 1]].Code, HuffRes[0][Res_L[MaxBand - 1]].Length); 156 writeBits(e, HuffRes[0][Res_R[MaxBand - 1]].Code, HuffRes[0][Res_R[MaxBand - 1]].Length); 151 157 for ( n = MaxBand - 2; n >= 0; n--) { 152 int tmp = e->Res_L[n] - e->Res_L[n + 1];158 int tmp = Res_L[n] - Res_L[n + 1]; 153 159 if (tmp < 0) tmp += 17; 154 writeBits(e, HuffRes[ e->Res_L[n + 1] > 2][tmp].Code, HuffRes[e->Res_L[n + 1] > 2][tmp].Length);155 156 tmp = e->Res_R[n] - e->Res_R[n + 1];160 writeBits(e, HuffRes[Res_L[n + 1] > 2][tmp].Code, HuffRes[Res_L[n + 1] > 2][tmp].Length); 161 162 tmp = Res_R[n] - Res_R[n + 1]; 157 163 if (tmp < 0) tmp += 17; 158 writeBits(e, HuffRes[ e->Res_R[n + 1] > 2][tmp].Code, HuffRes[e->Res_R[n + 1] > 2][tmp].Length);164 writeBits(e, HuffRes[Res_R[n + 1] > 2][tmp].Code, HuffRes[Res_R[n + 1] > 2][tmp].Length); 159 165 } 160 166 … … 162 168 mpc_uint32_t tmp = 0; 163 169 int cnt = 0, tot = 0; 170 mpc_bool_t * MS_Flag = e->MS_Flag; 164 171 for( n = 0; n < MaxBand; n++) { 165 if ( e->Res_L[n] != 0 || e->Res_R[n] != 0 ) {166 tmp = (tmp << 1) | e->MS_Flag[n];167 cnt += e->MS_Flag[n];172 if ( Res_L[n] != 0 || Res_R[n] != 0 ) { 173 tmp = (tmp << 1) | MS_Flag[n]; 174 cnt += MS_Flag[n]; 168 175 tot++; 169 176 } … … 179 186 if (e->framesInBlock == 0){ 180 187 for( n = 0; n < 32; n++) 181 e->DSCF_Flag_L[n] = e->DSCF_Flag_R[n] = 1; // new block -> force key frame188 DSCF_Flag_L[n] = DSCF_Flag_R[n] = 1; // new block -> force key frame 182 189 } 183 190 … … 186 193 for ( n = 0; n < MaxBand; n++ ) { 187 194 int tmp = 0, cnt = -1; 188 if ( e->Res_L[n]) {195 if (Res_L[n]) { 189 196 tmp = (e->SCF_Index_L[n][1] == e->SCF_Index_L[n][0]) * 2 + (e->SCF_Index_L[n][2] == e->SCF_Index_L[n][1]); 190 197 cnt++; 191 198 } 192 if ( e->Res_R[n]) {199 if (Res_R[n]) { 193 200 tmp = (tmp << 2) | ((e->SCF_Index_R[n][1] == e->SCF_Index_R[n][0]) * 2 + (e->SCF_Index_R[n][2] == e->SCF_Index_R[n][1])); 194 201 cnt++; … … 201 208 202 209 for ( n = 0; n < MaxBand; n++ ) { 203 if ( e->Res_L[n] ) {210 if ( Res_L[n] ) { 204 211 int m; 205 if (e->DSCF_Flag_L[n] == 1) { 206 writeBits(e, e->SCF_Index_L[n][0] + 6, 7); 207 e->DSCF_Flag_L[n] = 0; 212 mpc_int32_t * SCFI_L_n = e->SCF_Index_L[n]; 213 if (DSCF_Flag_L[n] == 1) { 214 writeBits(e, SCFI_L_n[0] + 6, 7); 215 DSCF_Flag_L[n] = 0; 208 216 } else { 209 unsigned int tmp = ( e->SCF_Index_L[n][0] - e->SCF_Last_L[n] + 31) & 127;217 unsigned int tmp = (SCFI_L_n[0] - SCF_Last_L[n] + 31) & 127; 210 218 if (tmp < 64) 211 219 writeBits(e, HuffDSCF_2[tmp].Code, HuffDSCF_2[tmp].Length); … … 216 224 } 217 225 for( m = 0; m < 2; m++){ 218 if ( e->SCF_Index_L[n][m+1] != e->SCF_Index_L[n][m]) {219 unsigned int tmp = ( e->SCF_Index_L[n][m+1] - e->SCF_Index_L[n][m] + 31) & 127;226 if (SCFI_L_n[m+1] != SCFI_L_n[m]) { 227 unsigned int tmp = (SCFI_L_n[m+1] - SCFI_L_n[m] + 31) & 127; 220 228 if (tmp < 64) 221 229 writeBits(e, HuffDSCF_1[tmp].Code, HuffDSCF_1[tmp].Length); … … 226 234 } 227 235 } 228 e->SCF_Last_L[n] = e->SCF_Index_L[n][2];229 } 230 if ( e->Res_R[n] ) {236 SCF_Last_L[n] = SCFI_L_n[2]; 237 } 238 if ( Res_R[n] ) { 231 239 int m; 232 if (e->DSCF_Flag_R[n] == 1) { 233 writeBits(e, e->SCF_Index_R[n][0] + 6, 7); 234 e->DSCF_Flag_R[n] = 0; 240 mpc_int32_t * SCFI_R_n = e->SCF_Index_R[n]; 241 if (DSCF_Flag_R[n] == 1) { 242 writeBits(e, SCFI_R_n[0] + 6, 7); 243 DSCF_Flag_R[n] = 0; 235 244 } else { 236 unsigned int tmp = ( e->SCF_Index_R[n][0] - e->SCF_Last_R[n] + 31) & 127;245 unsigned int tmp = (SCFI_R_n[0] - SCF_Last_R[n] + 31) & 127; 237 246 if (tmp < 64) 238 247 writeBits(e, HuffDSCF_2[tmp].Code, HuffDSCF_2[tmp].Length); … … 243 252 } 244 253 for( m = 0; m < 2; m++){ 245 if ( e->SCF_Index_R[n][m+1] != e->SCF_Index_R[n][m]) {246 unsigned int tmp = ( e->SCF_Index_R[n][m+1] - e->SCF_Index_R[n][m] + 31) & 127;254 if (SCFI_R_n[m+1] != SCFI_R_n[m]) { 255 unsigned int tmp = (SCFI_R_n[m+1] - SCFI_R_n[m] + 31) & 127; 247 256 if (tmp < 64) 248 257 writeBits(e, HuffDSCF_1[tmp].Code, HuffDSCF_1[tmp].Length); … … 253 262 } 254 263 } 255 e->SCF_Last_R[n] = e->SCF_Index_R[n][2];264 SCF_Last_R[n] = SCFI_R_n[2]; 256 265 } 257 266 } … … 259 268 /*********************************** Samples *********************************/ 260 269 for ( n = 0; n < MaxBand; n++ ) { 261 int Res = e->Res_L[n];270 int Res = Res_L[n]; 262 271 const int * q = e->Q[n].L; 263 272 static const unsigned int thres[] = {0, 0, 3, 7, 9, 1, 3, 4, 8}; … … 336 345 } 337 346 338 Res = e->Res_R[n];347 Res = Res_R[n]; 339 348 } while (q == e->Q[n].L && (q = e->Q[n].R)); 340 349 }
Note: See TracChangeset
for help on using the changeset viewer.