Mercurial > libavcodec.hg
comparison adpcm.c @ 5494:c2512a13877e libavcodec
fix decoding of adpcm swf big frames, fix RamboMJPEGAVP6_1Mbps.swf
author | bcoudurier |
---|---|
date | Sun, 05 Aug 2007 13:41:44 +0000 |
parents | 74680ec68fd1 |
children | 8b0dc2ce135c |
comparison
equal
deleted
inserted
replaced
5493:80b481ec72a6 | 5494:c2512a13877e |
---|---|
1272 break; | 1272 break; |
1273 case CODEC_ID_ADPCM_SWF: | 1273 case CODEC_ID_ADPCM_SWF: |
1274 { | 1274 { |
1275 GetBitContext gb; | 1275 GetBitContext gb; |
1276 const int *table; | 1276 const int *table; |
1277 int k0, signmask, nb_bits; | 1277 int k0, signmask, nb_bits, count; |
1278 int size = buf_size*8; | 1278 int size = buf_size*8; |
1279 | 1279 |
1280 init_get_bits(&gb, buf, size); | 1280 init_get_bits(&gb, buf, size); |
1281 | 1281 |
1282 //read bits & initial values | 1282 //read bits & initial values |
1284 //av_log(NULL,AV_LOG_INFO,"nb_bits: %d\n", nb_bits); | 1284 //av_log(NULL,AV_LOG_INFO,"nb_bits: %d\n", nb_bits); |
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 for (i = 0; i < avctx->channels; i++) { | 1290 for (i = 0; i < avctx->channels; i++) { |
1290 *samples++ = c->status[i].predictor = get_sbits(&gb, 16); | 1291 *samples++ = c->status[i].predictor = get_sbits(&gb, 16); |
1291 c->status[i].step_index = get_bits(&gb, 6); | 1292 c->status[i].step_index = get_bits(&gb, 6); |
1292 } | 1293 } |
1293 | 1294 |
1294 while (get_bits_count(&gb) < size) | 1295 for (count = 0; get_bits_count(&gb) <= size - nb_bits*avctx->channels && count < 4095; count++) |
1295 { | 1296 { |
1296 int i; | 1297 int i; |
1297 | 1298 |
1298 for (i = 0; i < avctx->channels; i++) { | 1299 for (i = 0; i < avctx->channels; i++) { |
1299 // similar to IMA adpcm | 1300 // similar to IMA adpcm |
1324 if (samples >= samples_end) { | 1325 if (samples >= samples_end) { |
1325 av_log(avctx, AV_LOG_ERROR, "allocated output buffer is too small\n"); | 1326 av_log(avctx, AV_LOG_ERROR, "allocated output buffer is too small\n"); |
1326 return -1; | 1327 return -1; |
1327 } | 1328 } |
1328 } | 1329 } |
1330 } | |
1329 } | 1331 } |
1330 src += buf_size; | 1332 src += buf_size; |
1331 break; | 1333 break; |
1332 } | 1334 } |
1333 case CODEC_ID_ADPCM_YAMAHA: | 1335 case CODEC_ID_ADPCM_YAMAHA: |