Mercurial > libavcodec.hg
comparison adpcm.c @ 4807:30ac525752b9 libavcodec
prev1/2 -> prev[2]
author | michael |
---|---|
date | Sat, 07 Apr 2007 21:27:58 +0000 |
parents | 52cb2800e26c |
children | ec3c56e6185b |
comparison
equal
deleted
inserted
replaced
4806:52cb2800e26c | 4807:30ac525752b9 |
---|---|
1312 case CODEC_ID_ADPCM_THP: | 1312 case CODEC_ID_ADPCM_THP: |
1313 { | 1313 { |
1314 GetBitContext gb; | 1314 GetBitContext gb; |
1315 int table[2][16]; | 1315 int table[2][16]; |
1316 unsigned int samplecnt; | 1316 unsigned int samplecnt; |
1317 int prev1[2], prev2[2]; | 1317 int prev[2][2]; |
1318 int ch; | 1318 int ch; |
1319 | 1319 |
1320 if (buf_size < 80) { | 1320 if (buf_size < 80) { |
1321 av_log(avctx, AV_LOG_ERROR, "frame too small\n"); | 1321 av_log(avctx, AV_LOG_ERROR, "frame too small\n"); |
1322 return -1; | 1322 return -1; |
1331 for (i = 0; i < 32; i++) | 1331 for (i = 0; i < 32; i++) |
1332 table[0][i] = get_sbits(&gb, 16); | 1332 table[0][i] = get_sbits(&gb, 16); |
1333 | 1333 |
1334 /* Initialize the previous sample. */ | 1334 /* Initialize the previous sample. */ |
1335 for (ch = 0; ch < 2; ch++) { | 1335 for (ch = 0; ch < 2; ch++) { |
1336 prev1[ch] = get_sbits(&gb, 16); | 1336 prev[ch][0] = get_sbits(&gb, 16); |
1337 prev2[ch] = get_sbits(&gb, 16); | 1337 prev[ch][1] = get_sbits(&gb, 16); |
1338 } | 1338 } |
1339 | 1339 |
1340 if (samplecnt >= (samples_end - samples) / (st + 1)) { | 1340 if (samplecnt >= (samples_end - samples) / (st + 1)) { |
1341 av_log(avctx, AV_LOG_ERROR, "allocated output buffer is too small\n"); | 1341 av_log(avctx, AV_LOG_ERROR, "allocated output buffer is too small\n"); |
1342 return -1; | 1342 return -1; |
1354 | 1354 |
1355 /* Decode 14 samples. */ | 1355 /* Decode 14 samples. */ |
1356 for (n = 0; n < 14; n++) { | 1356 for (n = 0; n < 14; n++) { |
1357 int sampledat = get_sbits (&gb, 4); | 1357 int sampledat = get_sbits (&gb, 4); |
1358 | 1358 |
1359 *samples = ((prev1[ch]*factor1 | 1359 *samples = ((prev[ch][0]*factor1 |
1360 + prev2[ch]*factor2) >> 11) + (sampledat << exp); | 1360 + prev[ch][1]*factor2) >> 11) + (sampledat << exp); |
1361 prev2[ch] = prev1[ch]; | 1361 prev[ch][1] = prev[ch][0]; |
1362 prev1[ch] = *samples++; | 1362 prev[ch][0] = *samples++; |
1363 | 1363 |
1364 /* In case of stereo, skip one sample, this sample | 1364 /* In case of stereo, skip one sample, this sample |
1365 is for the other channel. */ | 1365 is for the other channel. */ |
1366 samples += st; | 1366 samples += st; |
1367 } | 1367 } |