/*
* Wing Commander/Xan Video Decoder
- * Copyright (C) 2003 the ffmpeg project
+ * Copyright (c) 2003 The FFmpeg Project
*
* This file is part of FFmpeg.
*
} XanContext;
-static av_cold int xan_decode_end(AVCodecContext *avctx);
+static av_cold int xan_decode_end(AVCodecContext *avctx)
+{
+ XanContext *s = avctx->priv_data;
+
+ av_frame_free(&s->last_frame);
+
+ av_freep(&s->buffer1);
+ av_freep(&s->buffer2);
+ av_freep(&s->palettes);
+
+ return 0;
+}
static av_cold int xan_decode_init(AVCodecContext *avctx)
{
av_freep(&s->buffer1);
return AVERROR(ENOMEM);
}
+
s->last_frame = av_frame_alloc();
if (!s->last_frame) {
xan_decode_end(avctx);
uint8_t val = ival;
uint8_t *dest_end = dest + dest_len;
uint8_t *dest_start = dest;
+ int ret;
GetBitContext gb;
- if (ptr_len < 0)
- return AVERROR_INVALIDDATA;
-
- init_get_bits(&gb, ptr, ptr_len * 8);
+ if ((ret = init_get_bits8(&gb, ptr, ptr_len)) < 0)
+ return ret;
while (val != 0x16) {
unsigned idx = val - 0x17 + get_bits1(&gb) * byte;
int i;
tag = bytestream2_get_le32(&ctx);
size = bytestream2_get_be32(&ctx);
- if(size < 0) {
+ if (size < 0) {
av_log(avctx, AV_LOG_ERROR, "Invalid tag size %d\n", size);
return AVERROR_INVALIDDATA;
}
return buf_size;
}
-static av_cold int xan_decode_end(AVCodecContext *avctx)
-{
- XanContext *s = avctx->priv_data;
-
- av_frame_free(&s->last_frame);
-
- av_freep(&s->buffer1);
- av_freep(&s->buffer2);
- av_freep(&s->palettes);
-
- return 0;
-}
-
AVCodec ff_xan_wc3_decoder = {
.name = "xan_wc3",
.long_name = NULL_IF_CONFIG_SMALL("Wing Commander III / Xan"),