summaryrefslogtreecommitdiff
path: root/libavcodec/dnxhdenc.c
diff options
context:
space:
mode:
authorChristophe Gisquet <christophe.gisquet@gmail.com>2015-10-13 22:02:41 +0200
committerJames Almer <jamrial@gmail.com>2015-10-13 18:53:10 -0300
commit234369d0fd04f1ddfc10d6a73a1a0aa5cb7ea17c (patch)
tree9d38b3e0510fb7326b8c0a5f25d94ff326c18082 /libavcodec/dnxhdenc.c
parent74c414202f0eda01571dc362a4b4cb342dc1fb64 (diff)
dnxhdenc: fix access outside of image
This is the same test as for the 8bit case.
Diffstat (limited to 'libavcodec/dnxhdenc.c')
-rw-r--r--libavcodec/dnxhdenc.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c
index 1e14b8cb1f..f4a7b9891d 100644
--- a/libavcodec/dnxhdenc.c
+++ b/libavcodec/dnxhdenc.c
@@ -776,11 +776,13 @@ static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg,
unsigned mb = mb_y * ctx->m.mb_width + mb_x;
int sum = 0;
int sqsum = 0;
+ int bw = FFMIN(avctx->width - 16 * mb_x, 16);
+ int bh = FFMIN((avctx->height >> ctx->interlaced) - 16 * mb_y, 16);
int mean, sqmean;
int i, j;
// Macroblocks are 16x16 pixels, unlike DCT blocks which are 8x8.
- for (i = 0; i < 16; ++i) {
- for (j = 0; j < 16; ++j) {
+ for (i = 0; i < bh; ++i) {
+ for (j = 0; j < bw; ++j) {
// Turn 16-bit pixels into 10-bit ones.
int const sample = (unsigned) pix[j] >> 6;
sum += sample;