diff options
author | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2006-12-11 20:18:36 +0000 |
---|---|---|
committer | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2006-12-11 20:18:36 +0000 |
commit | c8aee695c50f879186ca5f9cbaefb076a0d0343f (patch) | |
tree | 543da2de5afbf8db345832b8d4d05941cb9e3812 | |
parent | 4d43cbcc74a6418a8c9a56ecee67116f1d8bca17 (diff) | |
download | ffmpeg-c8aee695c50f879186ca5f9cbaefb076a0d0343f.tar.gz |
Fix JPEG-LS encoder 0xff-escaping writing too much or uninitialized data.
Originally committed as revision 7284 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/jpeg_ls.c | 9 | ||||
-rw-r--r-- | tests/ffmpeg.regression.ref | 4 | ||||
-rw-r--r-- | tests/rotozoom.regression.ref | 4 |
3 files changed, 11 insertions, 6 deletions
diff --git a/libavcodec/jpeg_ls.c b/libavcodec/jpeg_ls.c index 1b4df2b1a0..4629176ada 100644 --- a/libavcodec/jpeg_ls.c +++ b/libavcodec/jpeg_ls.c @@ -804,11 +804,16 @@ static int encode_picture_ls(AVCodecContext *avctx, unsigned char *buf, int buf_ av_free(zero); av_free(state); + // the specification says that after doing 0xff escaping unused bits in the + // last byte must be set to 0, so just append 7 "optional" zero-bits to + // avoid special-casing. + put_bits(&pb2, 7, 0); + size = put_bits_count(&pb2); flush_put_bits(&pb2); /* do escape coding */ - size = put_bits_count(&pb2) >> 3; init_get_bits(&gb, buf2, size); - while(get_bits_count(&gb) < size * 8){ + size -= 7; + while(get_bits_count(&gb) < size){ int v; v = get_bits(&gb, 8); put_bits(&pb, 8, v); diff --git a/tests/ffmpeg.regression.ref b/tests/ffmpeg.regression.ref index 9db847a1fc..3c6f9f7a1e 100644 --- a/tests/ffmpeg.regression.ref +++ b/tests/ffmpeg.regression.ref @@ -105,8 +105,8 @@ stddev: 7.93 PSNR:30.13 bytes:7602176 6264498 ./data/a-ljpeg.avi 799d3db687f6cdd7a837ec156efc171f *./data/out.yuv stddev: 0.00 PSNR:99.99 bytes:7602176 -8b9359781a7e87d09af1b1c9a536cb75 *./data/a-jpegls.avi -9086694 ./data/a-jpegls.avi +dca9d700da7857217408c310c501b9bc *./data/a-jpegls.avi +9086676 ./data/a-jpegls.avi 0f8637e9b861230aff9894825af83720 *./data/out.yuv stddev: 2.84 PSNR:39.04 bytes:7602176 7eee6367442884321e27d15a26bc032a *./data/a-rv10.rm diff --git a/tests/rotozoom.regression.ref b/tests/rotozoom.regression.ref index 91dbe27d9b..8e7ec32f25 100644 --- a/tests/rotozoom.regression.ref +++ b/tests/rotozoom.regression.ref @@ -105,8 +105,8 @@ bc0d8c868c1a05db0ff03f41768f6c5e *./data/a-ljpeg.avi 4766558 ./data/a-ljpeg.avi dde5895817ad9d219f79a52d0bdfb001 *./data/out.yuv stddev: 0.00 PSNR:99.99 bytes:7602176 -8a2f3984a27a7513545cf98bc05fd066 *./data/a-jpegls.avi -8334508 ./data/a-jpegls.avi +f67cd488dfd06c03ad1d6d94d81b80c8 *./data/a-jpegls.avi +8334488 ./data/a-jpegls.avi a63d4e3ea1f0b0c0d44821da9e09b8f4 *./data/out.yuv stddev: 0.67 PSNR:51.57 bytes:7602176 989a42671603dc1a7e6b156dccf0e820 *./data/a-rv10.rm |