aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>2015-02-22 20:48:38 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-06-10 02:13:09 +0200
commit1cba89a135ba28bb80c2b7ea451331512827ac10 (patch)
treeefb22479c9813b664d49618d195c70a59b8a4e94
parentffdfa80147f3f534185e2b9dd9327b9bd48417ec (diff)
downloadffmpeg-1cba89a135ba28bb80c2b7ea451331512827ac10.tar.gz
avcodec/a64multienc: fix use of uninitialized values in to_meta_with_crop
Averaging over 2 pixels doesn't work correctly for the last pixel, because the rest of the buffer is not initialized. Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit 87513d654546a99f8ddb045ca4fa5d33778a617e) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/a64multienc.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/libavcodec/a64multienc.c b/libavcodec/a64multienc.c
index a2b4837990..ca9a6c14c1 100644
--- a/libavcodec/a64multienc.c
+++ b/libavcodec/a64multienc.c
@@ -81,9 +81,13 @@ static void to_meta_with_crop(AVCodecContext *avctx, AVFrame *p, int *dest)
for (y = blocky; y < blocky + 8 && y < C64YRES; y++) {
for (x = blockx; x < blockx + 8 && x < C64XRES; x += 2) {
if(x < width && y < height) {
- /* build average over 2 pixels */
- luma = (src[(x + 0 + y * p->linesize[0])] +
- src[(x + 1 + y * p->linesize[0])]) / 2;
+ if (x + 1 < width) {
+ /* build average over 2 pixels */
+ luma = (src[(x + 0 + y * p->linesize[0])] +
+ src[(x + 1 + y * p->linesize[0])]) / 2;
+ } else {
+ luma = src[(x + y * p->linesize[0])];
+ }
/* write blocks as linear data now so they are suitable for elbg */
dest[0] = luma;
}