summaryrefslogtreecommitdiff
path: root/libavcodec/indeo2.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/indeo2.c')
-rw-r--r--libavcodec/indeo2.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/libavcodec/indeo2.c b/libavcodec/indeo2.c
index 3154e2314c..c89845233e 100644
--- a/libavcodec/indeo2.c
+++ b/libavcodec/indeo2.c
@@ -2,20 +2,20 @@
* Intel Indeo 2 codec
* Copyright (c) 2005 Konstantin Shishkov
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@@ -55,15 +55,13 @@ static int ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst
int i;
int j;
int out = 0;
- int c;
- int t;
if (width & 1)
return AVERROR_INVALIDDATA;
/* first line contain absolute values, other lines contain deltas */
while (out < width) {
- c = ir2_get_code(&ctx->gb);
+ int c = ir2_get_code(&ctx->gb);
if (c >= 0x80) { /* we have a run */
c -= 0x7F;
if (out + c*2 > width)
@@ -80,7 +78,7 @@ static int ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst
for (j = 1; j < height; j++) {
out = 0;
while (out < width) {
- c = ir2_get_code(&ctx->gb);
+ int c = ir2_get_code(&ctx->gb);
if (c >= 0x80) { /* we have a skip */
c -= 0x7F;
if (out + c*2 > width)
@@ -90,7 +88,7 @@ static int ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst
out++;
}
} else { /* add two deltas from table */
- t = dst[out - pitch] + (table[c * 2] - 128);
+ int t = dst[out - pitch] + (table[c * 2] - 128);
t = av_clip_uint8(t);
dst[out] = t;
out++;
@@ -151,10 +149,8 @@ static int ir2_decode_frame(AVCodecContext *avctx,
int start, ret;
int ltab, ctab;
- if ((ret = ff_reget_buffer(avctx, p)) < 0) {
- av_log(s->avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
+ if ((ret = ff_reget_buffer(avctx, p)) < 0)
return ret;
- }
start = 48; /* hardcoded for now */
@@ -171,10 +167,17 @@ static int ir2_decode_frame(AVCodecContext *avctx,
buf[i] = ff_reverse[buf[i]];
#endif
- init_get_bits(&s->gb, buf + start, (buf_size - start) * 8);
+ if ((ret = init_get_bits8(&s->gb, buf + start, buf_size - start)) < 0)
+ return ret;
ltab = buf[0x22] & 3;
ctab = buf[0x22] >> 2;
+
+ if (ctab > 3) {
+ av_log(avctx, AV_LOG_ERROR, "ctab %d is invalid\n", ctab);
+ return AVERROR_INVALIDDATA;
+ }
+
if (s->decode_delta) { /* intraframe */
if ((ret = ir2_decode_plane(s, avctx->width, avctx->height,
p->data[0], p->linesize[0],