Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'libavcodec/idcinvideo.c')
-rw-r--r--libavcodec/idcinvideo.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/libavcodec/idcinvideo.c b/libavcodec/idcinvideo.c
index 476b628d82..a517d9da5e 100644
--- a/libavcodec/idcinvideo.c
+++ b/libavcodec/idcinvideo.c
@@ -2,20 +2,20 @@
* id Quake II CIN Video Decoder
* Copyright (C) 2003 the ffmpeg project
*
- * 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
*/
@@ -76,7 +76,7 @@ typedef struct IdcinContext {
uint32_t pal[256];
} IdcinContext;
-/*
+/**
* Find the lowest probability node in a Huffman table, and mark it as
* being assigned to a higher probability.
* @return the node index of the lowest unused node, or -1 if all nodes
@@ -167,12 +167,13 @@ static av_cold int idcin_decode_init(AVCodecContext *avctx)
huff_build_tree(s, i);
}
+ avcodec_get_frame_defaults(&s->frame);
s->frame.data[0] = NULL;
return 0;
}
-static void idcin_decode_vlcs(IdcinContext *s)
+static int idcin_decode_vlcs(IdcinContext *s)
{
hnode *hnodes;
long x, y;
@@ -191,7 +192,7 @@ static void idcin_decode_vlcs(IdcinContext *s)
if(!bit_pos) {
if(dat_pos >= s->size) {
av_log(s->avctx, AV_LOG_ERROR, "Huffman decode error.\n");
- return;
+ return -1;
}
bit_pos = 8;
v = s->buf[dat_pos++];
@@ -206,6 +207,8 @@ static void idcin_decode_vlcs(IdcinContext *s)
prev = node_num;
}
}
+
+ return 0;
}
static int idcin_decode_frame(AVCodecContext *avctx,
@@ -216,6 +219,7 @@ static int idcin_decode_frame(AVCodecContext *avctx,
int buf_size = avpkt->size;
IdcinContext *s = avctx->priv_data;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
+ int ret;
s->buf = buf;
s->size = buf_size;
@@ -223,12 +227,13 @@ static int idcin_decode_frame(AVCodecContext *avctx,
if (s->frame.data[0])
avctx->release_buffer(avctx, &s->frame);
- if (avctx->get_buffer(avctx, &s->frame)) {
- av_log(avctx, AV_LOG_ERROR, " id CIN Video: get_buffer() failed\n");
- return -1;
+ if ((ret = avctx->get_buffer(avctx, &s->frame))) {
+ av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ return ret;
}
- idcin_decode_vlcs(s);
+ if (idcin_decode_vlcs(s))
+ return AVERROR_INVALIDDATA;
if (pal) {
s->frame.palette_has_changed = 1;