fix predictor initialization for adpcm-ima encoder not to lose first sample

in block in adpcm-ima decoder
Patch by Timofei V. Bondarenko: tim £ ipi, ac, ru
Original thread: [FFmpeg-devel] [PATCH] adpcm-ima-wav header and codec
Date: 10/15/2007 05:55 PM

Originally committed as revision 10933 to svn://svn.ffmpeg.org/ffmpeg/trunk
pull/126/head
Timofei V. Bondarenko 17 years ago committed by Benoit Fouet
parent 3837d107b7
commit 62b3415258
  1. 6
      libavcodec/adpcm.c
  2. 6
      tests/ffmpeg.regression.ref
  3. 6
      tests/rotozoom.regression.ref

@ -451,7 +451,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx,
*dst++ = 0; /* unknown */
samples++;
if (avctx->channels == 2) {
c->status[1].prev_sample = (signed short)samples[1];
c->status[1].prev_sample = (signed short)samples[0];
/* c->status[1].step_index = 0; */
bytestream_put_le16(&dst, c->status[1].prev_sample);
*dst++ = (unsigned char)c->status[1].step_index;
@ -936,11 +936,9 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
for(i=0; i<avctx->channels; i++){
cs = &(c->status[i]);
cs->predictor = (int16_t)(src[0] + (src[1]<<8));
cs->predictor = *samples++ = (int16_t)(src[0] + (src[1]<<8));
src+=2;
// XXX: is this correct ??: *samples++ = cs->predictor;
cs->step_index = *src++;
if (cs->step_index > 88){
av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n", cs->step_index);

@ -176,10 +176,10 @@ aefe11ab5067621a1c674859d6413891 *./tests/data/a-ac3.rm
24279 ./tests/data/a-g726.wav
888f2f016e608d044a1bacbca5497ed2 *./tests/data/out.wav
stddev:8368.02 PSNR:17.87 bytes:96256
de3f0e1f50b19bd8572fdd3dee2e72c4 *./tests/data/a-adpcm_ima.wav
3b969c43e45582f713e3c35faee9e0cc *./tests/data/a-adpcm_ima.wav
266300 ./tests/data/a-adpcm_ima.wav
60178d48204f5662d91776e36eddc82e *./tests/data/out.wav
stddev:11441.89 PSNR:15.15 bytes:1054720
947196b1739a9d6fe0c29424cf61cd8c *./tests/data/out.wav
stddev:904.20 PSNR:37.19 bytes:1056768
628d4789cf9ee16a756ac54b7fd8650d *./tests/data/a-adpcm_ms.wav
267320 ./tests/data/a-adpcm_ms.wav
91a84bb4f319a3a0bf0c0441b3d3a529 *./tests/data/out.wav

@ -176,10 +176,10 @@ aefe11ab5067621a1c674859d6413891 *./tests/data/a-ac3.rm
24279 ./tests/data/a-g726.wav
888f2f016e608d044a1bacbca5497ed2 *./tests/data/out.wav
stddev:8368.02 PSNR:17.87 bytes:96256
de3f0e1f50b19bd8572fdd3dee2e72c4 *./tests/data/a-adpcm_ima.wav
3b969c43e45582f713e3c35faee9e0cc *./tests/data/a-adpcm_ima.wav
266300 ./tests/data/a-adpcm_ima.wav
60178d48204f5662d91776e36eddc82e *./tests/data/out.wav
stddev:11441.89 PSNR:15.15 bytes:1054720
947196b1739a9d6fe0c29424cf61cd8c *./tests/data/out.wav
stddev:904.20 PSNR:37.19 bytes:1056768
628d4789cf9ee16a756ac54b7fd8650d *./tests/data/a-adpcm_ms.wav
267320 ./tests/data/a-adpcm_ms.wav
91a84bb4f319a3a0bf0c0441b3d3a529 *./tests/data/out.wav

Loading…
Cancel
Save