]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/ansi.c
on2avc: check number of channels
[ffmpeg] / libavcodec / ansi.c
index c851d888915d09ce2e41b67b1cdcbc9beb9b319a..556bfe44616fc2e9d9795dc8cb9798f7fd1c1f65 100644 (file)
@@ -88,9 +88,11 @@ static av_cold int decode_init(AVCodecContext *avctx)
     s->fg          = DEFAULT_FG_COLOR;
     s->bg          = DEFAULT_BG_COLOR;
 
-    if (!avctx->width || !avctx->height)
-        avcodec_set_dimensions(avctx, 80<<3, 25<<4);
-
+    if (!avctx->width || !avctx->height) {
+        int ret = ff_set_dimensions(avctx, 80 << 3, 25 << 4);
+        if (ret < 0)
+            return ret;
+    }
     return 0;
 }
 
@@ -165,7 +167,10 @@ static void draw_char(AVCodecContext *avctx, int c)
 static int execute_code(AVCodecContext * avctx, int c)
 {
     AnsiContext *s = avctx->priv_data;
-    int ret, i, width, height;
+    int ret, i;
+    int width = 0;
+    int height = 0;
+
     switch(c) {
     case 'A': //Cursor Up
         s->y = FFMAX(s->y - (s->nb_args > 0 ? s->args[0]*s->font_height : s->font_height), 0);
@@ -224,9 +229,12 @@ static int execute_code(AVCodecContext * avctx, int c)
         default:
             avpriv_request_sample(avctx, "Unsupported screen mode");
         }
-        if (width != avctx->width || height != avctx->height) {
+        if (width != 0 && height != 0 &&
+            (width != avctx->width || height != avctx->height)) {
             av_frame_unref(s->frame);
-            avcodec_set_dimensions(avctx, width, height);
+            ret = ff_set_dimensions(avctx, width, height);
+            if (ret < 0)
+                return ret;
             ret = ff_get_buffer(avctx, s->frame, AV_GET_BUFFER_FLAG_REF);
             if (ret < 0) {
                 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
@@ -435,6 +443,7 @@ static av_cold int decode_close(AVCodecContext *avctx)
 
 AVCodec ff_ansi_decoder = {
     .name           = "ansi",
+    .long_name      = NULL_IF_CONFIG_SMALL("ASCII/ANSI art"),
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = AV_CODEC_ID_ANSI,
     .priv_data_size = sizeof(AnsiContext),
@@ -442,5 +451,4 @@ AVCodec ff_ansi_decoder = {
     .close          = decode_close,
     .decode         = decode_frame,
     .capabilities   = CODEC_CAP_DR1,
-    .long_name      = NULL_IF_CONFIG_SMALL("ASCII/ANSI art"),
 };