comparison adpcm.c @ 5500:8b0dc2ce135c libavcodec

cosmetic, indentation
author bcoudurier
date Mon, 06 Aug 2007 08:42:05 +0000
parents c2512a13877e
children a0dcb5a51409
comparison
equal deleted inserted replaced
5499:838ba4dafaae 5500:8b0dc2ce135c
1285 table = swf_index_tables[nb_bits-2]; 1285 table = swf_index_tables[nb_bits-2];
1286 k0 = 1 << (nb_bits-2); 1286 k0 = 1 << (nb_bits-2);
1287 signmask = 1 << (nb_bits-1); 1287 signmask = 1 << (nb_bits-1);
1288 1288
1289 while (get_bits_count(&gb) <= size - 22*avctx->channels) { 1289 while (get_bits_count(&gb) <= size - 22*avctx->channels) {
1290 for (i = 0; i < avctx->channels; i++) {
1291 *samples++ = c->status[i].predictor = get_sbits(&gb, 16);
1292 c->status[i].step_index = get_bits(&gb, 6);
1293 }
1294
1295 for (count = 0; get_bits_count(&gb) <= size - nb_bits*avctx->channels && count < 4095; count++)
1296 {
1297 int i;
1298
1299 for (i = 0; i < avctx->channels; i++) { 1290 for (i = 0; i < avctx->channels; i++) {
1300 // similar to IMA adpcm 1291 *samples++ = c->status[i].predictor = get_sbits(&gb, 16);
1301 int delta = get_bits(&gb, nb_bits); 1292 c->status[i].step_index = get_bits(&gb, 6);
1302 int step = step_table[c->status[i].step_index]; 1293 }
1303 long vpdiff = 0; // vpdiff = (delta+0.5)*step/4 1294
1304 int k = k0; 1295 for (count = 0; get_bits_count(&gb) <= size - nb_bits*avctx->channels && count < 4095; count++) {
1305 1296 int i;
1306 do { 1297
1307 if (delta & k) 1298 for (i = 0; i < avctx->channels; i++) {
1308 vpdiff += step; 1299 // similar to IMA adpcm
1309 step >>= 1; 1300 int delta = get_bits(&gb, nb_bits);
1310 k >>= 1; 1301 int step = step_table[c->status[i].step_index];
1311 } while(k); 1302 long vpdiff = 0; // vpdiff = (delta+0.5)*step/4
1312 vpdiff += step; 1303 int k = k0;
1313 1304
1314 if (delta & signmask) 1305 do {
1315 c->status[i].predictor -= vpdiff; 1306 if (delta & k)
1316 else 1307 vpdiff += step;
1317 c->status[i].predictor += vpdiff; 1308 step >>= 1;
1318 1309 k >>= 1;
1319 c->status[i].step_index += table[delta & (~signmask)]; 1310 } while(k);
1320 1311 vpdiff += step;
1321 c->status[i].step_index = av_clip(c->status[i].step_index, 0, 88); 1312
1322 c->status[i].predictor = av_clip(c->status[i].predictor, -32768, 32767); 1313 if (delta & signmask)
1323 1314 c->status[i].predictor -= vpdiff;
1324 *samples++ = c->status[i].predictor; 1315 else
1325 if (samples >= samples_end) { 1316 c->status[i].predictor += vpdiff;
1326 av_log(avctx, AV_LOG_ERROR, "allocated output buffer is too small\n"); 1317
1327 return -1; 1318 c->status[i].step_index += table[delta & (~signmask)];
1319
1320 c->status[i].step_index = av_clip(c->status[i].step_index, 0, 88);
1321 c->status[i].predictor = av_clip(c->status[i].predictor, -32768, 32767);
1322
1323 *samples++ = c->status[i].predictor;
1324 if (samples >= samples_end) {
1325 av_log(avctx, AV_LOG_ERROR, "allocated output buffer is too small\n");
1326 return -1;
1327 }
1328 } 1328 }
1329 } 1329 }
1330 }
1331 } 1330 }
1332 src += buf_size; 1331 src += buf_size;
1333 break; 1332 break;
1334 } 1333 }
1335 case CODEC_ID_ADPCM_YAMAHA: 1334 case CODEC_ID_ADPCM_YAMAHA: