[FFmpeg-devel] [PATCH] mpeg2: remove idct randomisation
Mans Rullgard
mans
Mon Jun 21 00:21:28 CEST 2010
Since the beginning of time, the MPEG2 decoder has XORed the LSB of
all block coeffs into the last one, probably to produce a random
dithering for masking DCT mismatch errors. This patch removes this
randomisation. As a side-effect, the value of block_last_index is
now correct.
---
libavcodec/mpeg12.c | 10 ---------
tests/ref/lavf/gxf | 2 +-
tests/ref/lavf/mxf | 4 +-
tests/ref/lavf/ts | 2 +-
tests/ref/seek/mpeg2reuse.mpg.ref | 40 ++++++++++++++++++------------------
tests/ref/vsynth1/mpeg2 | 14 ++++++------
tests/ref/vsynth1/mpeg2thread | 12 +++++-----
tests/ref/vsynth2/mpeg2 | 12 +++++-----
tests/ref/vsynth2/mpeg2thread | 14 ++++++------
9 files changed, 50 insertions(+), 60 deletions(-)
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index bc9ddcc..aa313ef 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -863,9 +863,6 @@ static inline int mpeg2_decode_block_non_intra(MpegEncContext *s,
uint8_t * const scantable= s->intra_scantable.permutated;
const uint16_t *quant_matrix;
const int qscale= s->qscale;
- int mismatch;
-
- mismatch = 1;
{
OPEN_READER(re, &s->gb);
@@ -882,7 +879,6 @@ static inline int mpeg2_decode_block_non_intra(MpegEncContext *s,
if(GET_CACHE(re, &s->gb)&0x40000000)
level= -level;
block[0] = level;
- mismatch ^= level;
i++;
SKIP_BITS(re, &s->gb, 2);
if(((int32_t)GET_CACHE(re, &s->gb)) <= (int32_t)0xBFFFFFFF)
@@ -922,7 +918,6 @@ static inline int mpeg2_decode_block_non_intra(MpegEncContext *s,
return -1;
}
- mismatch ^= level;
block[j] = level;
#if MIN_CACHE_BITS < 19
UPDATE_CACHE(re, &s->gb);
@@ -937,7 +932,6 @@ end:
LAST_SKIP_BITS(re, &s->gb, 2);
CLOSE_READER(re, &s->gb);
}
- block[63] ^= (mismatch & 1);
s->block_last_index[n] = i;
return 0;
@@ -1024,7 +1018,6 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s,
uint8_t * const scantable= s->intra_scantable.permutated;
const uint16_t *quant_matrix;
const int qscale= s->qscale;
- int mismatch;
/* DC coefficient */
if (n < 4){
@@ -1042,7 +1035,6 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s,
s->last_dc[component] = dc;
block[0] = dc << (3 - s->intra_dc_precision);
dprintf(s->avctx, "dc=%d\n", block[0]);
- mismatch = block[0] ^ 1;
i = 0;
if (s->intra_vlc_format)
rl = &ff_rl_mpeg2;
@@ -1083,12 +1075,10 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s,
return -1;
}
- mismatch^= level;
block[j] = level;
}
CLOSE_READER(re, &s->gb);
}
- block[63]^= mismatch&1;
s->block_last_index[n] = i;
return 0;
diff --git a/tests/ref/lavf/gxf b/tests/ref/lavf/gxf
index d147bc4..4ef0564 100644
--- a/tests/ref/lavf/gxf
+++ b/tests/ref/lavf/gxf
@@ -1,3 +1,3 @@
b52bf18b403ac9a0d12048b2f66cb24c *./tests/data/lavf/lavf.gxf
796392 ./tests/data/lavf/lavf.gxf
-./tests/data/lavf/lavf.gxf CRC=0xad9e86eb
+./tests/data/lavf/lavf.gxf CRC=0x6b2487ab
diff --git a/tests/ref/lavf/mxf b/tests/ref/lavf/mxf
index 84d7a09..fb76e6c 100644
--- a/tests/ref/lavf/mxf
+++ b/tests/ref/lavf/mxf
@@ -1,6 +1,6 @@
8e120da0ccd70c4475fdee13fc5f3d0b *./tests/data/lavf/lavf.mxf
525881 ./tests/data/lavf/lavf.mxf
-./tests/data/lavf/lavf.mxf CRC=0xb6aa0849
+./tests/data/lavf/lavf.mxf CRC=0xf9924ae6
b3174e2db508564c1cce0b5e3c1bc1bd *./tests/data/lavf/lavf.mxf_d10
5330989 ./tests/data/lavf/lavf.mxf_d10
-./tests/data/lavf/lavf.mxf_d10 CRC=0xc3f4f92e
+./tests/data/lavf/lavf.mxf_d10 CRC=0x573076ae
diff --git a/tests/ref/lavf/ts b/tests/ref/lavf/ts
index 5b046fb..5cfb6c0 100644
--- a/tests/ref/lavf/ts
+++ b/tests/ref/lavf/ts
@@ -1,3 +1,3 @@
e0c183639709d6e75bc553a3ed1333dd *./tests/data/lavf/lavf.ts
406644 ./tests/data/lavf/lavf.ts
-./tests/data/lavf/lavf.ts CRC=0x133216c1
+./tests/data/lavf/lavf.ts CRC=0x53173ec7
diff --git a/tests/ref/seek/mpeg2reuse.mpg.ref b/tests/ref/seek/mpeg2reuse.mpg.ref
index c4ae3ea..2268bf0 100644
--- a/tests/ref/seek/mpeg2reuse.mpg.ref
+++ b/tests/ref/seek/mpeg2reuse.mpg.ref
@@ -1,46 +1,46 @@
-ret: 0 st: 0 flags:1 dts: 0.000000 pts: NOPTS pos: 0 size: 20829
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: NOPTS pos: 0 size: 20833
ret: 0 st:-1 flags:0 ts:-1.000000
-ret: 0 st: 0 flags:1 dts: 0.000000 pts: NOPTS pos: 0 size: 20829
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: NOPTS pos: 0 size: 20833
ret: 0 st:-1 flags:1 ts: 1.894167
-ret: 0 st: 0 flags:1 dts: 1.840000 pts: NOPTS pos: 337078 size: 26840
+ret: 0 st: 0 flags:1 dts: 1.840000 pts: NOPTS pos: 336721 size: 26840
ret: 0 st: 0 flags:0 ts: 0.788334
-ret: 0 st: 0 flags:1 dts: 0.880000 pts: NOPTS pos: 141401 size: 23537
+ret: 0 st: 0 flags:1 dts: 0.880000 pts: NOPTS pos: 141341 size: 23536
ret:-1 st: 0 flags:1 ts:-0.317499
ret:-1 st:-1 flags:0 ts: 2.576668
ret: 0 st:-1 flags:1 ts: 1.470835
-ret: 0 st: 0 flags:1 dts: 1.360000 pts: NOPTS pos: 232037 size: 26192
+ret: 0 st: 0 flags:1 dts: 1.360000 pts: NOPTS pos: 231918 size: 26198
ret: 0 st: 0 flags:0 ts: 0.365002
-ret: 0 st: 0 flags:1 dts: 0.400000 pts: NOPTS pos: 63793 size: 21295
+ret: 0 st: 0 flags:1 dts: 0.400000 pts: NOPTS pos: 63746 size: 21296
ret:-1 st: 0 flags:1 ts:-0.740831
ret:-1 st:-1 flags:0 ts: 2.153336
ret: 0 st:-1 flags:1 ts: 1.047503
-ret: 0 st: 0 flags:1 dts: 0.880000 pts: NOPTS pos: 141401 size: 23537
+ret: 0 st: 0 flags:1 dts: 0.880000 pts: NOPTS pos: 141341 size: 23536
ret: 0 st: 0 flags:0 ts:-0.058330
-ret: 0 st: 0 flags:1 dts: 0.000000 pts: NOPTS pos: 0 size: 20829
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: NOPTS pos: 0 size: 20833
ret: 0 st: 0 flags:1 ts: 2.835837
-ret: 0 st: 0 flags:1 dts: 1.840000 pts: NOPTS pos: 337078 size: 26840
+ret: 0 st: 0 flags:1 dts: 1.840000 pts: NOPTS pos: 336721 size: 26840
ret: 0 st:-1 flags:0 ts: 1.730004
-ret: 0 st: 0 flags:1 dts: 1.840000 pts: NOPTS pos: 337078 size: 26840
+ret: 0 st: 0 flags:1 dts: 1.840000 pts: NOPTS pos: 336721 size: 26840
ret: 0 st:-1 flags:1 ts: 0.624171
-ret: 0 st: 0 flags:1 dts: 0.400000 pts: NOPTS pos: 63793 size: 21295
+ret: 0 st: 0 flags:1 dts: 0.400000 pts: NOPTS pos: 63746 size: 21296
ret: 0 st: 0 flags:0 ts:-0.481662
-ret: 0 st: 0 flags:1 dts: 0.000000 pts: NOPTS pos: 0 size: 20829
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: NOPTS pos: 0 size: 20833
ret: 0 st: 0 flags:1 ts: 2.412505
-ret: 0 st: 0 flags:1 dts: 1.840000 pts: NOPTS pos: 337078 size: 26840
+ret: 0 st: 0 flags:1 dts: 1.840000 pts: NOPTS pos: 336721 size: 26840
ret: 0 st:-1 flags:0 ts: 1.306672
-ret: 0 st: 0 flags:1 dts: 1.360000 pts: NOPTS pos: 232037 size: 26192
+ret: 0 st: 0 flags:1 dts: 1.360000 pts: NOPTS pos: 231918 size: 26198
ret: 0 st:-1 flags:1 ts: 0.200839
-ret: 0 st: 0 flags:1 dts: 0.000000 pts: NOPTS pos: 0 size: 20829
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: NOPTS pos: 0 size: 20833
ret: 0 st: 0 flags:0 ts:-0.904994
-ret: 0 st: 0 flags:1 dts: 0.000000 pts: NOPTS pos: 0 size: 20829
+ret: 0 st: 0 flags:1 dts: 0.000000 pts: NOPTS pos: 0 size: 20833
ret: 0 st: 0 flags:1 ts: 1.989173
-ret: 0 st: 0 flags:1 dts: 1.840000 pts: NOPTS pos: 337078 size: 26840
+ret: 0 st: 0 flags:1 dts: 1.840000 pts: NOPTS pos: 336721 size: 26840
ret: 0 st:-1 flags:0 ts: 0.883340
-ret: 0 st: 0 flags:1 dts: 1.360000 pts: NOPTS pos: 232037 size: 26192
+ret: 0 st: 0 flags:1 dts: 1.360000 pts: NOPTS pos: 231918 size: 26198
ret:-1 st:-1 flags:1 ts:-0.222493
ret:-1 st: 0 flags:0 ts: 2.671674
ret: 0 st: 0 flags:1 ts: 1.565841
-ret: 0 st: 0 flags:1 dts: 1.360000 pts: NOPTS pos: 232037 size: 26192
+ret: 0 st: 0 flags:1 dts: 1.360000 pts: NOPTS pos: 231918 size: 26198
ret: 0 st:-1 flags:0 ts: 0.460008
-ret: 0 st: 0 flags:1 dts: 0.880000 pts: NOPTS pos: 141401 size: 23537
+ret: 0 st: 0 flags:1 dts: 0.880000 pts: NOPTS pos: 141341 size: 23536
ret:-1 st:-1 flags:1 ts:-0.645825
diff --git a/tests/ref/vsynth1/mpeg2 b/tests/ref/vsynth1/mpeg2
index 7269080..a06f550 100644
--- a/tests/ref/vsynth1/mpeg2
+++ b/tests/ref/vsynth1/mpeg2
@@ -1,20 +1,20 @@
fbddea2368cd2028fc8db4dfd4682e94 *./tests/data/vsynth1/mpeg2.mpg
728044 ./tests/data/vsynth1/mpeg2.mpg
-b41ca49c1a02e66ce64d262e2cdaec15 *./tests/data/mpeg2.vsynth1.out.yuv
+fcdc3f7c713c05790409f3420f11be23 *./tests/data/mpeg2.vsynth1.out.yuv
stddev: 7.65 PSNR: 30.45 bytes: 7603200/ 7603200
8f6b20714918e6443e0c03716ed06f0d *./tests/data/vsynth1/mpeg2ivlc-qprd.mpg
783552 ./tests/data/vsynth1/mpeg2ivlc-qprd.mpg
-98eb9da15f880978e7f2ee1e7ce476ef *./tests/data/mpeg2.vsynth1.out.yuv
+4320470745bd32065be74f4e70cc164d *./tests/data/mpeg2.vsynth1.out.yuv
stddev: 10.07 PSNR: 28.06 bytes: 7603200/ 7603200
af0cb75451aaa807beb5102707a98823 *./tests/data/vsynth1/mpeg2_422.mpg
728200 ./tests/data/vsynth1/mpeg2_422.mpg
-29b518282493203e83b27a939795dc3a *./tests/data/mpeg2.vsynth1.out.yuv
+a2dc49b3a7d83f412e630f194f64e7cc *./tests/data/mpeg2.vsynth1.out.yuv
stddev: 63.33 PSNR: 12.10 bytes: 10137600/ 7603200
4c067397b504d65532d7779cd36f3f88 *./tests/data/vsynth1/mpeg2.mpg
725668 ./tests/data/vsynth1/mpeg2.mpg
-9f7b065f98d57cdecf90e6f7a2524eb5 *./tests/data/mpeg2.vsynth1.out.yuv
-stddev: 7.65 PSNR: 30.45 bytes: 7603200/ 7603200
+c2e4292876fc12e89824d05262a142d1 *./tests/data/mpeg2.vsynth1.out.yuv
+stddev: 7.66 PSNR: 30.45 bytes: 7603200/ 7603200
ec3f6713c88a2b41f6c369fd64341077 *./tests/data/vsynth1/mpeg2i.mpg
737473 ./tests/data/vsynth1/mpeg2i.mpg
-97615390fdd69abfcbc7e02df863a7d2 *./tests/data/mpeg2.vsynth1.out.yuv
-stddev: 7.67 PSNR: 30.43 bytes: 7603200/ 7603200
+769b636abe26473e66385a899317c1b0 *./tests/data/mpeg2.vsynth1.out.yuv
+stddev: 7.68 PSNR: 30.42 bytes: 7603200/ 7603200
diff --git a/tests/ref/vsynth1/mpeg2thread b/tests/ref/vsynth1/mpeg2thread
index c2e2c4f..c0f7a26 100644
--- a/tests/ref/vsynth1/mpeg2thread
+++ b/tests/ref/vsynth1/mpeg2thread
@@ -1,12 +1,12 @@
ecd183706688bd977c9994c3d1b23d61 *./tests/data/vsynth1/mpeg2thread.mpg
801313 ./tests/data/vsynth1/mpeg2thread.mpg
-d1658911ca83f5616c1d32abc40750de *./tests/data/mpeg2thread.vsynth1.out.yuv
+c9d33e8f71ba026a906b2176c83895ec *./tests/data/mpeg2thread.vsynth1.out.yuv
stddev: 7.63 PSNR: 30.48 bytes: 7603200/ 7603200
23d600b026222253c2340e23300a4c02 *./tests/data/vsynth1/mpeg2threadivlc.mpg
791773 ./tests/data/vsynth1/mpeg2threadivlc.mpg
-d1658911ca83f5616c1d32abc40750de *./tests/data/mpeg2thread.vsynth1.out.yuv
+c9d33e8f71ba026a906b2176c83895ec *./tests/data/mpeg2thread.vsynth1.out.yuv
stddev: 7.63 PSNR: 30.48 bytes: 7603200/ 7603200
-d119fe917dd81d1ff758b4ce684a8d9d *./tests/data/vsynth1/mpeg2reuse.mpg
-2074636 ./tests/data/vsynth1/mpeg2reuse.mpg
-92ced6afe8c02304943c400cce51a5f4 *./tests/data/mpeg2thread.vsynth1.out.yuv
-stddev: 7.66 PSNR: 30.44 bytes: 7603200/ 7603200
+f2a0f85d5e59d34d3cf49053fe533eed *./tests/data/vsynth1/mpeg2reuse.mpg
+2075375 ./tests/data/vsynth1/mpeg2reuse.mpg
+3f86f91251113bc0694df11f5083b6a4 *./tests/data/mpeg2thread.vsynth1.out.yuv
+stddev: 7.67 PSNR: 30.43 bytes: 7603200/ 7603200
diff --git a/tests/ref/vsynth2/mpeg2 b/tests/ref/vsynth2/mpeg2
index f4a1c96..228dc33 100644
--- a/tests/ref/vsynth2/mpeg2
+++ b/tests/ref/vsynth2/mpeg2
@@ -1,20 +1,20 @@
2d55ce623a7be4e8136f80266e487678 *./tests/data/vsynth2/mpeg2.mpg
198667 ./tests/data/vsynth2/mpeg2.mpg
-b7cae8a1f751b821cddcbe4d5dbc518c *./tests/data/mpeg2.vsynth2.out.yuv
-stddev: 4.96 PSNR: 34.20 bytes: 7603200/ 7603200
+b408fcfff4192c74a464c00056fc689b *./tests/data/mpeg2.vsynth2.out.yuv
+stddev: 4.97 PSNR: 34.20 bytes: 7603200/ 7603200
1ba5efeb53fab7b4b71edc96d86f6c91 *./tests/data/vsynth2/mpeg2ivlc-qprd.mpg
244694 ./tests/data/vsynth2/mpeg2ivlc-qprd.mpg
-b26e21599dee48a174bdbc40b2817e55 *./tests/data/mpeg2.vsynth2.out.yuv
+642da3c9e4b05b7645033342d922fa40 *./tests/data/mpeg2.vsynth2.out.yuv
stddev: 4.15 PSNR: 35.76 bytes: 7603200/ 7603200
2c8e33c2d2efab86fc16a195f6877682 *./tests/data/vsynth2/mpeg2_422.mpg
356124 ./tests/data/vsynth2/mpeg2_422.mpg
-de44597c6c470f3e7019b31245a3ff69 *./tests/data/mpeg2.vsynth2.out.yuv
+e0491e08873b71a4977a20da96c1d82c *./tests/data/mpeg2.vsynth2.out.yuv
stddev: 54.55 PSNR: 13.39 bytes: 10137600/ 7603200
f979bcca866e6e4cad5dc6cb06e56cfb *./tests/data/vsynth2/mpeg2.mpg
198041 ./tests/data/vsynth2/mpeg2.mpg
-f6d9bf24ff8676a7f6076c05cd2c81a3 *./tests/data/mpeg2.vsynth2.out.yuv
+74be9ceb2cd709cdc476511dc0830b10 *./tests/data/mpeg2.vsynth2.out.yuv
stddev: 4.97 PSNR: 34.19 bytes: 7603200/ 7603200
f90197a8b6e62ae25f82625337f27240 *./tests/data/vsynth2/mpeg2i.mpg
204579 ./tests/data/vsynth2/mpeg2i.mpg
-ea5057b60146c06d40449cdfc686bf13 *./tests/data/mpeg2.vsynth2.out.yuv
+8163a20aac64dc3013bcba713a1af090 *./tests/data/mpeg2.vsynth2.out.yuv
stddev: 4.98 PSNR: 34.18 bytes: 7603200/ 7603200
diff --git a/tests/ref/vsynth2/mpeg2thread b/tests/ref/vsynth2/mpeg2thread
index 9253d7f..de32305 100644
--- a/tests/ref/vsynth2/mpeg2thread
+++ b/tests/ref/vsynth2/mpeg2thread
@@ -1,12 +1,12 @@
889c754a42d7689b228853e1ece6d345 *./tests/data/vsynth2/mpeg2thread.mpg
179650 ./tests/data/vsynth2/mpeg2thread.mpg
-8c6a7ed2eb73bd18fd2bb9829464100d *./tests/data/mpeg2thread.vsynth2.out.yuv
-stddev: 4.72 PSNR: 34.65 bytes: 7603200/ 7603200
+754ac00c5134be8955b0c3ea41a969c6 *./tests/data/mpeg2thread.vsynth2.out.yuv
+stddev: 4.72 PSNR: 34.64 bytes: 7603200/ 7603200
10b900e32809758857c596d56746e00e *./tests/data/vsynth2/mpeg2threadivlc.mpg
178801 ./tests/data/vsynth2/mpeg2threadivlc.mpg
-8c6a7ed2eb73bd18fd2bb9829464100d *./tests/data/mpeg2thread.vsynth2.out.yuv
-stddev: 4.72 PSNR: 34.65 bytes: 7603200/ 7603200
-864d6bf2982a61e510003a518be65a2d *./tests/data/vsynth2/mpeg2reuse.mpg
-383419 ./tests/data/vsynth2/mpeg2reuse.mpg
-bb20fa080cfd2b0a687ea7376ff4f902 *./tests/data/mpeg2thread.vsynth2.out.yuv
+754ac00c5134be8955b0c3ea41a969c6 *./tests/data/mpeg2thread.vsynth2.out.yuv
+stddev: 4.72 PSNR: 34.64 bytes: 7603200/ 7603200
+d0f58c54fca40ba78e37ffa2a8bc1adb *./tests/data/vsynth2/mpeg2reuse.mpg
+382932 ./tests/data/vsynth2/mpeg2reuse.mpg
+75faa81962f651a5d7bc201a911264b7 *./tests/data/mpeg2thread.vsynth2.out.yuv
stddev: 4.73 PSNR: 34.63 bytes: 7603200/ 7603200
--
1.7.1
More information about the ffmpeg-devel
mailing list