[FFmpeg-cvslog] cook: expand dither_tab[], and make sure indexes into it don't overflow.
Ronald S. Bultje
git at videolan.org
Sun Mar 11 01:27:49 CET 2012
ffmpeg | branch: master | Ronald S. Bultje <rsbultje at gmail.com> | Thu Mar 8 17:09:27 2012 -0800| [442c3a8cb1785d74f8e2d7ab35b1862b7088436b] | committer: Ronald S. Bultje
cook: expand dither_tab[], and make sure indexes into it don't overflow.
Fixes overflows in accessing dither_tab[].
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable at libav.org
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=442c3a8cb1785d74f8e2d7ab35b1862b7088436b
---
libavcodec/cook.c | 6 +++++-
libavcodec/cookdata.h | 4 ++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/libavcodec/cook.c b/libavcodec/cook.c
index 65e16e4..41ce0e5 100644
--- a/libavcodec/cook.c
+++ b/libavcodec/cook.c
@@ -507,7 +507,11 @@ static inline void expand_category(COOKContext *q, int *category,
{
int i;
for (i = 0; i < q->num_vectors; i++)
- ++category[category_index[i]];
+ {
+ int idx = category_index[i];
+ if (++category[idx] >= FF_ARRAY_ELEMS(dither_tab))
+ --category[idx];
+ }
}
/**
diff --git a/libavcodec/cookdata.h b/libavcodec/cookdata.h
index 126010a..c4c26fa 100644
--- a/libavcodec/cookdata.h
+++ b/libavcodec/cookdata.h
@@ -36,8 +36,8 @@ static const int expbits_tab[8] = {
52,47,43,37,29,22,16,0,
};
-static const float dither_tab[8] = {
- 0.0, 0.0, 0.0, 0.0, 0.0, 0.176777, 0.25, 0.707107,
+static const float dither_tab[9] = {
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.176777, 0.25, 0.707107, 1.0
};
static const float quant_centroid_tab[7][14] = {
More information about the ffmpeg-cvslog
mailing list