]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/xan.c
10l: vorbisdec: declare dy
[ffmpeg] / libavcodec / xan.c
index e0bd7800956f450e1592c83703069b8e0a95a5f5..e5792a1fce54754ecd2f8bce054fdf1a15df2b17 100644 (file)
@@ -20,7 +20,7 @@
  */
 
 /**
- * @file libavcodec/xan.c
+ * @file
  * Xan video decoder for Wing Commander III computer game
  * by Mario Brito (mbrito@student.dei.uc.pt)
  * and Mike Melanson (melanson@pcisys.net)
@@ -68,18 +68,22 @@ static av_cold int xan_decode_init(AVCodecContext *avctx)
 
     if ((avctx->codec->id == CODEC_ID_XAN_WC3) &&
         (s->avctx->palctrl == NULL)) {
-        av_log(avctx, AV_LOG_ERROR, " WC3 Xan video: palette expected.\n");
-        return -1;
+        av_log(avctx, AV_LOG_ERROR, "palette expected\n");
+        return AVERROR(EINVAL);
     }
 
     avctx->pix_fmt = PIX_FMT_PAL8;
 
     s->buffer1_size = avctx->width * avctx->height;
     s->buffer1 = av_malloc(s->buffer1_size);
+    if (!s->buffer1)
+        return AVERROR(ENOMEM);
     s->buffer2_size = avctx->width * avctx->height;
     s->buffer2 = av_malloc(s->buffer2_size + 130);
-    if (!s->buffer1 || !s->buffer2)
-        return -1;
+    if (!s->buffer2) {
+        av_freep(&s->buffer1);
+        return AVERROR(ENOMEM);
+    }
 
     return 0;
 }
@@ -355,13 +359,13 @@ static int xan_decode_frame(AVCodecContext *avctx,
                             AVPacket *avpkt)
 {
     const uint8_t *buf = avpkt->data;
-    int buf_size = avpkt->size;
+    int ret, buf_size = avpkt->size;
     XanContext *s = avctx->priv_data;
     AVPaletteControl *palette_control = avctx->palctrl;
 
-    if (avctx->get_buffer(avctx, &s->current_frame)) {
-        av_log(s->avctx, AV_LOG_ERROR, "  Xan Video: get_buffer() failed\n");
-        return -1;
+    if ((ret = avctx->get_buffer(avctx, &s->current_frame))) {
+        av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+        return ret;
     }
     s->current_frame.reference = 3;
 
@@ -405,15 +409,15 @@ static av_cold int xan_decode_end(AVCodecContext *avctx)
     if (s->current_frame.data[0])
         avctx->release_buffer(avctx, &s->current_frame);
 
-    av_free(s->buffer1);
-    av_free(s->buffer2);
+    av_freep(&s->buffer1);
+    av_freep(&s->buffer2);
 
     return 0;
 }
 
 AVCodec xan_wc3_decoder = {
     "xan_wc3",
-    CODEC_TYPE_VIDEO,
+    AVMEDIA_TYPE_VIDEO,
     CODEC_ID_XAN_WC3,
     sizeof(XanContext),
     xan_decode_init,
@@ -427,7 +431,7 @@ AVCodec xan_wc3_decoder = {
 /*
 AVCodec xan_wc4_decoder = {
     "xan_wc4",
-    CODEC_TYPE_VIDEO,
+    AVMEDIA_TYPE_VIDEO,
     CODEC_ID_XAN_WC4,
     sizeof(XanContext),
     xan_decode_init,
@@ -435,5 +439,6 @@ AVCodec xan_wc4_decoder = {
     xan_decode_end,
     xan_decode_frame,
     CODEC_CAP_DR1,
+    .long_name = NULL_IF_CONFIG_SMALL("Wing Commander IV / Xxan"),
 };
 */