g722: Fix the QMF scaling

This fixes clipping if the encoder input used the full 16 bit
input range (samples with a magnitude below 16383 worked fine).
The filtered subband samples should be 15 bit maximum, while
the code earlier produced them scaled to 16 bit.

This makes the decoder output have double the magnitude
compared to before.

The spec reference samples doesn't test the QMF at all, which
was why this part slipped past initially.

(cherry picked from commit b087ce2bee81db8cc5caffb8f0a4f6c7c92a30fe)

Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
Martin Storsjö 2012-03-02 17:03:06 +02:00
parent 4ae138cb12
commit ca7e97bdcf
5 changed files with 176 additions and 176 deletions

View File

@ -126,8 +126,8 @@ static int g722_decode_frame(AVCodecContext *avctx, void *data,
c->prev_samples[c->prev_samples_pos++] = rlow - rhigh;
ff_g722_apply_qmf(c->prev_samples + c->prev_samples_pos - 24,
&xout1, &xout2);
*out_buf++ = av_clip_int16(xout1 >> 12);
*out_buf++ = av_clip_int16(xout2 >> 12);
*out_buf++ = av_clip_int16(xout1 >> 11);
*out_buf++ = av_clip_int16(xout2 >> 11);
if (c->prev_samples_pos >= PREV_SAMPLES_BUF_SIZE) {
memmove(c->prev_samples, c->prev_samples + c->prev_samples_pos - 22,
22 * sizeof(c->prev_samples[0]));

View File

@ -128,8 +128,8 @@ static inline void filter_samples(G722Context *c, const int16_t *samples,
c->prev_samples[c->prev_samples_pos++] = samples[0];
c->prev_samples[c->prev_samples_pos++] = samples[1];
ff_g722_apply_qmf(c->prev_samples + c->prev_samples_pos - 24, &xout1, &xout2);
*xlow = xout1 + xout2 >> 13;
*xhigh = xout1 - xout2 >> 13;
*xlow = xout1 + xout2 >> 14;
*xhigh = xout1 - xout2 >> 14;
if (c->prev_samples_pos >= PREV_SAMPLES_BUF_SIZE) {
memmove(c->prev_samples,
c->prev_samples + c->prev_samples_pos - 22,

View File

@ -1,4 +1,4 @@
1975cc4a3521e374b33ae042e182f6b6 *./tests/data/acodec/g722.wav
48053 ./tests/data/acodec/g722.wav
ade04cdcf249e6946395f109b077dd62 *./tests/data/g722.acodec.out.wav
stddev: 8841.24 PSNR: 17.40 MAXDIFF:36225 bytes: 191980/ 1058400
7b0492eee76b04b710990235f97a0bf2 *./tests/data/acodec/g722.wav
48053 ./tests/data/acodec/g722.wav
b5568e0e3930ff563824156e8e1015f0 *./tests/data/g722.acodec.out.wav
stddev: 8939.44 PSNR: 17.30 MAXDIFF:40370 bytes: 191980/ 1058400

View File

@ -1,167 +1,167 @@
0, 0, 4096, 0xde68394d
0, 11520, 4096, 0xa5c28cb7
0, 23040, 4096, 0x2e3c2f23
0, 34560, 4096, 0xd7757825
0, 46080, 4096, 0xafd1fd61
0, 57600, 4096, 0x686afcbe
0, 69120, 4096, 0x2290e848
0, 80640, 4096, 0xddd484ad
0, 92160, 4096, 0x148811a6
0, 103680, 4096, 0x8b965613
0, 115200, 4096, 0x8b095d51
0, 126720, 4096, 0xf7625485
0, 138240, 4096, 0x982a688c
0, 149760, 4096, 0xc290dcfc
0, 161280, 4096, 0x8bdef225
0, 172800, 4096, 0xfca27fdc
0, 184320, 4096, 0x95eff313
0, 195840, 4096, 0x691ed4f7
0, 207360, 4096, 0xd7e7b492
0, 218880, 4096, 0xb0416bfe
0, 230400, 4096, 0xf94b3ebd
0, 241920, 4096, 0x7f73ca12
0, 253440, 4096, 0xe91da4a3
0, 264960, 4096, 0x1f74dc0e
0, 276480, 4096, 0xd95b35e8
0, 288000, 4096, 0x6dcdde1a
0, 299520, 4096, 0x614fd4e4
0, 311040, 4096, 0xe38d0fd5
0, 322560, 4096, 0xfeba2999
0, 334080, 4096, 0x1bf541e1
0, 345600, 4096, 0x689f50d8
0, 357120, 4096, 0x0aa60f5f
0, 368640, 4096, 0x60ac3116
0, 380160, 4096, 0xfa60e5e6
0, 391680, 4096, 0xc7207c5b
0, 403200, 4096, 0x01196277
0, 414720, 4096, 0x609ca46c
0, 426240, 4096, 0xfb799142
0, 437760, 4096, 0x720910df
0, 449280, 4096, 0xe21a8662
0, 460800, 4096, 0x07105120
0, 472320, 4096, 0x593f627e
0, 483840, 4096, 0x28ddc80c
0, 495360, 4096, 0xc69ef356
0, 506880, 4096, 0x2defc5bd
0, 518400, 4096, 0x82a4f418
0, 529920, 4096, 0x424cb997
0, 541440, 4096, 0x167a49b7
0, 552960, 4096, 0x32a3e0d4
0, 564480, 4096, 0x08a353ae
0, 576000, 4096, 0x9543577b
0, 587520, 4096, 0x2ed137cf
0, 599040, 4096, 0xd80b0538
0, 610560, 4096, 0x2ad31bef
0, 622080, 4096, 0x1060cff8
0, 633600, 4096, 0x76ab5ab8
0, 645120, 4096, 0x8eedb68d
0, 656640, 4096, 0xf4e2dc46
0, 668160, 4096, 0xc52d3326
0, 679680, 4096, 0x25201a26
0, 691200, 4096, 0x16419378
0, 702720, 4096, 0x97061f3c
0, 714240, 4096, 0xd54edecd
0, 725760, 4096, 0xc830b07b
0, 737280, 4096, 0x804bae00
0, 748800, 4096, 0xbb279150
0, 760320, 4096, 0x95c4d5aa
0, 771840, 4096, 0xc51d5259
0, 783360, 4096, 0x856e1ab0
0, 794880, 4096, 0x9e6ccb12
0, 806400, 4096, 0xa2e5c1bb
0, 817920, 4096, 0xe62fb62f
0, 829440, 4096, 0xf10e3df0
0, 840960, 4096, 0x76def18b
0, 852480, 4096, 0xc9c3a26d
0, 864000, 4096, 0x8ec0e061
0, 875520, 4096, 0x3d4e8512
0, 887040, 4096, 0xec45cd46
0, 898560, 4096, 0xa34f3ddf
0, 910080, 4096, 0x52b81c53
0, 921600, 4096, 0xd0f0397a
0, 933120, 4096, 0x7c0de231
0, 944640, 4096, 0xfe86c032
0, 956160, 4096, 0x67cdb848
0, 967680, 4096, 0x90532cc0
0, 979200, 4096, 0x03bca9e9
0, 990720, 4096, 0x73169fd1
0, 1002240, 4096, 0x0b93967d
0, 1013760, 4096, 0x6486d8be
0, 1025280, 4096, 0x555cc2ac
0, 1036800, 4096, 0x07c1912e
0, 1048320, 4096, 0xe0423c66
0, 1059840, 4096, 0xc12d0fa1
0, 1071360, 4096, 0xdf497c2f
0, 1082880, 4096, 0x9298d1ba
0, 1094400, 4096, 0x691a4e15
0, 1105920, 4096, 0x725adc6e
0, 1117440, 4096, 0xf68e88de
0, 1128960, 4096, 0x37a234aa
0, 1140480, 4096, 0x43fb0558
0, 1152000, 4096, 0x653e4320
0, 1163520, 4096, 0x651e2f13
0, 1175040, 4096, 0x179049f9
0, 1186560, 4096, 0xe02fbb9d
0, 1198080, 4096, 0xb7e9f2a0
0, 1209600, 4096, 0x94ee81df
0, 1221120, 4096, 0x398a98de
0, 1232640, 4096, 0x1267594a
0, 1244160, 4096, 0x715adbaf
0, 1255680, 4096, 0x28ce1a20
0, 1267200, 4096, 0x4f8073d0
0, 1278720, 4096, 0x536846d3
0, 1290240, 4096, 0x7dc7defe
0, 1301760, 4096, 0x08a28e2a
0, 1313280, 4096, 0xd717c5cd
0, 1324800, 4096, 0x5d6e1efd
0, 1336320, 4096, 0x4d0eea27
0, 1347840, 4096, 0x70fff90c
0, 1359360, 4096, 0xd5cc8207
0, 1370880, 4096, 0xf87cae0e
0, 1382400, 4096, 0x26814ab5
0, 1393920, 4096, 0x9569fb8d
0, 1405440, 4096, 0x7835122e
0, 1416960, 4096, 0xa38840dd
0, 1428480, 4096, 0xfc499ba3
0, 1440000, 4096, 0x0aa60cb0
0, 1451520, 4096, 0x530ef56e
0, 1463040, 4096, 0xead968db
0, 1474560, 4096, 0x64484214
0, 1486080, 4096, 0xfd0cc89e
0, 1497600, 4096, 0x0d452a5d
0, 1509120, 4096, 0x36ef8482
0, 1520640, 4096, 0x462b641b
0, 1532160, 4096, 0x2a5c1c0c
0, 1543680, 4096, 0x8837ff80
0, 1555200, 4096, 0x27a3de22
0, 1566720, 4096, 0xf88d28c1
0, 1578240, 4096, 0xed85ea97
0, 1589760, 4096, 0x50c3e7db
0, 1601280, 4096, 0x82bcb480
0, 1612800, 4096, 0xc50ee536
0, 1624320, 4096, 0x086280ee
0, 1635840, 4096, 0x6f18f2b2
0, 1647360, 4096, 0x1c7c0856
0, 1658880, 4096, 0xc576268a
0, 1670400, 4096, 0x7a9af56d
0, 1681920, 4096, 0x6d058fc5
0, 1693440, 4096, 0x8fb1107b
0, 1704960, 4096, 0x807588d1
0, 1716480, 4096, 0x56178443
0, 1728000, 4096, 0xf2460763
0, 1739520, 4096, 0x284255f2
0, 1751040, 4096, 0xb29d17fb
0, 1762560, 4096, 0x5e7e4633
0, 1774080, 4096, 0x57704db1
0, 1785600, 4096, 0xd87dcc1d
0, 1797120, 4096, 0x28d4bb93
0, 1808640, 4096, 0x3a2e5c6c
0, 1820160, 4096, 0xf3581656
0, 1831680, 4096, 0x42f1942f
0, 1843200, 4096, 0xe75c5092
0, 1854720, 4096, 0x3fae7f6d
0, 1866240, 4096, 0xf99ad73e
0, 1877760, 4096, 0x80564e3e
0, 1889280, 4096, 0x8ff6ebe5
0, 1900800, 4096, 0x436d5e69
0, 1912320, 1368, 0xe0ebeda3
0, 0, 4096, 0x4f9228b3
0, 11520, 4096, 0xfab58157
0, 23040, 4096, 0x0b641c78
0, 34560, 4096, 0x601c6803
0, 46080, 4096, 0xb3e2f166
0, 57600, 4096, 0x5681f206
0, 69120, 4096, 0x1e69e71f
0, 80640, 4096, 0x05628be3
0, 92160, 4096, 0x109b1aef
0, 103680, 4096, 0xd5435a9e
0, 115200, 4096, 0xb38b5d28
0, 126720, 4096, 0x64514c93
0, 138240, 4096, 0x453350e7
0, 149760, 4096, 0x6deccce6
0, 161280, 4096, 0xd427ede1
0, 172800, 4096, 0xdecb8c42
0, 184320, 4096, 0x3841e4d2
0, 195840, 4096, 0x858ac1b1
0, 207360, 4096, 0x8e9dbfa0
0, 218880, 4096, 0xcbc0766f
0, 230400, 4096, 0x78d52555
0, 241920, 4096, 0x600ac7d5
0, 253440, 4096, 0xafadb7ee
0, 264960, 4096, 0x8009d5a1
0, 276480, 4096, 0xb07d475e
0, 288000, 4096, 0xfcfecceb
0, 299520, 4096, 0x38b5d85f
0, 311040, 4096, 0xbd48072e
0, 322560, 4096, 0xd04724d8
0, 334080, 4096, 0x08425144
0, 345600, 4096, 0x7b14483e
0, 357120, 4096, 0x8858ef4c
0, 368640, 4096, 0x1e3024c2
0, 380160, 4096, 0xcd6bfe4f
0, 391680, 4096, 0x8cde8d18
0, 403200, 4096, 0xbbd856b8
0, 414720, 4096, 0x988c9b7a
0, 426240, 4096, 0x2a858e03
0, 437760, 4096, 0x6dee1e4a
0, 449280, 4096, 0x8cc38b41
0, 460800, 4096, 0x48bd5cec
0, 472320, 4096, 0xeb7f606b
0, 483840, 4096, 0x75f5d28c
0, 495360, 4096, 0x5bfeec4b
0, 506880, 4096, 0xfc35c22a
0, 518400, 4096, 0x3a95efba
0, 529920, 4096, 0xefdbce9c
0, 541440, 4096, 0x00594ada
0, 552960, 4096, 0x20ffebfa
0, 564480, 4096, 0x1b31370a
0, 576000, 4096, 0x50766a56
0, 587520, 4096, 0x0058315a
0, 599040, 4096, 0x98090cbf
0, 610560, 4096, 0x66ed2d40
0, 622080, 4096, 0xdfd7c0a7
0, 633600, 4096, 0x2adc57e1
0, 645120, 4096, 0x838bbc82
0, 656640, 4096, 0x2c55de1a
0, 668160, 4096, 0xeae027f4
0, 679680, 4096, 0x09fe00f6
0, 691200, 4096, 0xa25d9970
0, 702720, 4096, 0xedb11a20
0, 714240, 4096, 0x9ce2e63e
0, 725760, 4096, 0xeb699974
0, 737280, 4096, 0xcc04a296
0, 748800, 4096, 0xe90e9a12
0, 760320, 4096, 0xae85c0f7
0, 771840, 4096, 0x7ee877db
0, 783360, 4096, 0x9ecf14ee
0, 794880, 4096, 0xa821cecd
0, 806400, 4096, 0x2714bb11
0, 817920, 4096, 0x28f1c1e0
0, 829440, 4096, 0xf81c4f60
0, 840960, 4096, 0x1ae0e5a1
0, 852480, 4096, 0xbdae9d9a
0, 864000, 4096, 0x5202e560
0, 875520, 4096, 0x82408396
0, 887040, 4096, 0xc850ce0c
0, 898560, 4096, 0x1d732d88
0, 910080, 4096, 0xc5c01e33
0, 921600, 4096, 0x84942d6c
0, 933120, 4096, 0x7c27cd3a
0, 944640, 4096, 0x22adc503
0, 956160, 4096, 0xfbc3af31
0, 967680, 4096, 0xe9652b18
0, 979200, 4096, 0xae75987e
0, 990720, 4096, 0x0f7ea428
0, 1002240, 4096, 0x92b89582
0, 1013760, 4096, 0xf393d910
0, 1025280, 4096, 0x6349b600
0, 1036800, 4096, 0x16918dbd
0, 1048320, 4096, 0x14ee15ad
0, 1059840, 4096, 0x26b510d3
0, 1071360, 4096, 0x97007bf8
0, 1082880, 4096, 0x3718c509
0, 1094400, 4096, 0x24a54ccd
0, 1105920, 4096, 0xc960df4e
0, 1117440, 4096, 0xc7cb6e6f
0, 1128960, 4096, 0x4c563ae5
0, 1140480, 4096, 0x0dd51432
0, 1152000, 4096, 0xdb4243c8
0, 1163520, 4096, 0x9bb6417f
0, 1175040, 4096, 0xec6a40a1
0, 1186560, 4096, 0x82d6c3b4
0, 1198080, 4096, 0xd181e2ec
0, 1209600, 4096, 0xba5d7b55
0, 1221120, 4096, 0x78fcb938
0, 1232640, 4096, 0x6691671c
0, 1244160, 4096, 0x44fadee7
0, 1255680, 4096, 0xa42720d5
0, 1267200, 4096, 0xc1165a91
0, 1278720, 4096, 0x86aa3e3f
0, 1290240, 4096, 0xab5ae57d
0, 1301760, 4096, 0x291a91f3
0, 1313280, 4096, 0xfdf0dcfc
0, 1324800, 4096, 0x1ef91f67
0, 1336320, 4096, 0xc899efee
0, 1347840, 4096, 0x5ade15ac
0, 1359360, 4096, 0x04516beb
0, 1370880, 4096, 0xbf5ebbb9
0, 1382400, 4096, 0x4a235122
0, 1393920, 4096, 0xd7a3f4a6
0, 1405440, 4096, 0x5f900f20
0, 1416960, 4096, 0xa90b4365
0, 1428480, 4096, 0x63149dc4
0, 1440000, 4096, 0xf12c1ee8
0, 1451520, 4096, 0x6d0fec8c
0, 1463040, 4096, 0x65e07850
0, 1474560, 4096, 0x16d951cc
0, 1486080, 4096, 0xd296d0c4
0, 1497600, 4096, 0x619b2a53
0, 1509120, 4096, 0x316972d5
0, 1520640, 4096, 0xcfd64e21
0, 1532160, 4096, 0xcbcb10c6
0, 1543680, 4096, 0x20aeff7c
0, 1555200, 4096, 0xd205dabd
0, 1566720, 4096, 0xac9d3001
0, 1578240, 4096, 0x6d53dfdd
0, 1589760, 4096, 0xbb9fe15c
0, 1601280, 4096, 0x1852b88b
0, 1612800, 4096, 0xb0acec01
0, 1624320, 4096, 0xb52a9342
0, 1635840, 4096, 0x7529faee
0, 1647360, 4096, 0x150ff449
0, 1658880, 4096, 0xa81d31d9
0, 1670400, 4096, 0xbcb8084a
0, 1681920, 4096, 0x07229514
0, 1693440, 4096, 0xa85cfd88
0, 1704960, 4096, 0x0aef9c27
0, 1716480, 4096, 0x8ec47b39
0, 1728000, 4096, 0x910b0560
0, 1739520, 4096, 0x99a8578e
0, 1751040, 4096, 0xb3df1d84
0, 1762560, 4096, 0x48e52559
0, 1774080, 4096, 0xb25c4800
0, 1785600, 4096, 0x913bc8ce
0, 1797120, 4096, 0xb736cc8c
0, 1808640, 4096, 0x13c66646
0, 1820160, 4096, 0x70a71221
0, 1831680, 4096, 0x3a50a08e
0, 1843200, 4096, 0xc0a037b0
0, 1854720, 4096, 0x9a789475
0, 1866240, 4096, 0xc890ca16
0, 1877760, 4096, 0xa0d34bed
0, 1889280, 4096, 0x1689fa60
0, 1900800, 4096, 0x5bac4c83
0, 1912320, 1368, 0x904be5e5

View File

@ -1 +1 @@
750269cc236541df28e15da5c7b0df7a
94e2f200d6e05b47cec4aa3e94571cf3