diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c
index 79656e7757be23e1ef12716ce505938982c08139..0f491090fdcdde43146d560f4ffe637b9f5b9cfd 100644
--- a/libavcodec/shorten.c
+++ b/libavcodec/shorten.c
@@ -682,7 +682,7 @@ static int shorten_decode_frame(AVCodecContext *avctx, void *data,
             else {
                 int32_t sum = (s->version < 2) ? 0 : s->nmean / 2;
                 for (i = 0; i < s->nmean; i++)
-                    sum += s->offset[channel][i];
+                    sum += (unsigned)s->offset[channel][i];
                 coffset = sum / s->nmean;
                 if (s->version >= 2)
                     coffset = s->bitshift == 0 ? coffset : coffset >> s->bitshift - 1 >> 1;