mirror of
https://git.videolan.org/git/ffmpeg.git
synced 2024-09-01 22:16:42 +02:00
avcodec/adxenc: match prediction used in the decoder
The prediction used in the encoder was not correct Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
93f959b672
commit
6b0ab561d0
@ -43,14 +43,12 @@ static void adx_encode(ADXContext *c, uint8_t *adx, const int16_t *wav,
|
||||
int s0, s1, s2, d;
|
||||
int max = 0;
|
||||
int min = 0;
|
||||
int data[BLOCK_SAMPLES];
|
||||
|
||||
s1 = prev->s1;
|
||||
s2 = prev->s2;
|
||||
for (i = 0, j = 0; j < 32; i += channels, j++) {
|
||||
s0 = wav[i];
|
||||
d = ((s0 << COEFF_BITS) - c->coeff[0] * s1 - c->coeff[1] * s2) >> COEFF_BITS;
|
||||
data[j] = d;
|
||||
if (max < d)
|
||||
max = d;
|
||||
if (min > d)
|
||||
@ -58,10 +56,10 @@ static void adx_encode(ADXContext *c, uint8_t *adx, const int16_t *wav,
|
||||
s2 = s1;
|
||||
s1 = s0;
|
||||
}
|
||||
prev->s1 = s1;
|
||||
prev->s2 = s2;
|
||||
|
||||
if (max == 0 && min == 0) {
|
||||
prev->s1 = s1;
|
||||
prev->s2 = s2;
|
||||
memset(adx, 0, BLOCK_SIZE);
|
||||
return;
|
||||
}
|
||||
@ -77,8 +75,23 @@ static void adx_encode(ADXContext *c, uint8_t *adx, const int16_t *wav,
|
||||
AV_WB16(adx, scale);
|
||||
|
||||
init_put_bits(&pb, adx + 2, 16);
|
||||
for (i = 0; i < BLOCK_SAMPLES; i++)
|
||||
put_sbits(&pb, 4, av_clip(data[i] / scale, -8, 7));
|
||||
|
||||
s1 = prev->s1;
|
||||
s2 = prev->s2;
|
||||
for (i = 0, j = 0; j < 32; i += channels, j++) {
|
||||
d = ((wav[i] << COEFF_BITS) - c->coeff[0] * s1 - c->coeff[1] * s2) >> COEFF_BITS;
|
||||
|
||||
d = av_clip(d / scale, -8, 7);
|
||||
|
||||
put_sbits(&pb, 4, d);
|
||||
|
||||
s0 = ((d << COEFF_BITS) * scale + c->coeff[0] * s1 + c->coeff[1] * s2) >> COEFF_BITS;
|
||||
s2 = s1;
|
||||
s1 = s0;
|
||||
}
|
||||
prev->s1 = s1;
|
||||
prev->s2 = s2;
|
||||
|
||||
flush_put_bits(&pb);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
0a30509d9296b857e134b762b76dbc31 *tests/data/fate/acodec-adpcm-adx.adx
|
||||
d82a87942d6500adb4d07d21cbcbdb78 *tests/data/fate/acodec-adpcm-adx.adx
|
||||
297720 tests/data/fate/acodec-adpcm-adx.adx
|
||||
7260139001fcac62384dad50a1023e75 *tests/data/fate/acodec-adpcm-adx.out.wav
|
||||
stddev: 6989.46 PSNR: 19.44 MAXDIFF:65398 bytes: 1058400/ 1058432
|
||||
4e78a1153eb8fc4dfc050836f46b62f8 *tests/data/fate/acodec-adpcm-adx.out.wav
|
||||
stddev: 3096.24 PSNR: 26.51 MAXDIFF:53110 bytes: 1058400/ 1058432
|
||||
|
@ -1,4 +1,4 @@
|
||||
0a30509d9296b857e134b762b76dbc31 *tests/data/fate/acodec-adpcm-adx-trellis.adx
|
||||
d82a87942d6500adb4d07d21cbcbdb78 *tests/data/fate/acodec-adpcm-adx-trellis.adx
|
||||
297720 tests/data/fate/acodec-adpcm-adx-trellis.adx
|
||||
7260139001fcac62384dad50a1023e75 *tests/data/fate/acodec-adpcm-adx-trellis.out.wav
|
||||
stddev: 6989.46 PSNR: 19.44 MAXDIFF:65398 bytes: 1058400/ 1058432
|
||||
4e78a1153eb8fc4dfc050836f46b62f8 *tests/data/fate/acodec-adpcm-adx-trellis.out.wav
|
||||
stddev: 3096.24 PSNR: 26.51 MAXDIFF:53110 bytes: 1058400/ 1058432
|
||||
|
Loading…
Reference in New Issue
Block a user