Commit 1a8f9f0e authored by Andreas Cadhalpun's avatar Andreas Cadhalpun Committed by Michael Niedermayer

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: 's avatarMichael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 87513d65)
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 91ced160
...@@ -78,9 +78,13 @@ static void to_meta_with_crop(AVCodecContext *avctx, AVFrame *p, int *dest) ...@@ -78,9 +78,13 @@ static void to_meta_with_crop(AVCodecContext *avctx, AVFrame *p, int *dest)
for (y = blocky; y < blocky + 8 && y < C64YRES; y++) { for (y = blocky; y < blocky + 8 && y < C64YRES; y++) {
for (x = blockx; x < blockx + 8 && x < C64XRES; x += 2) { for (x = blockx; x < blockx + 8 && x < C64XRES; x += 2) {
if(x < width && y < height) { if(x < width && y < height) {
/* build average over 2 pixels */ if (x + 1 < width) {
luma = (src[(x + 0 + y * p->linesize[0])] + /* build average over 2 pixels */
src[(x + 1 + y * p->linesize[0])]) / 2; 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 */ /* write blocks as linear data now so they are suitable for elbg */
dest[0] = luma; dest[0] = luma;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment