]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/flashsv2enc.c
lavfi/hflip: copy palette data in start_frame()
[ffmpeg] / libavcodec / flashsv2enc.c
index 8efdb469213963cce2769d4fee5d36c82d340bea..8ab904616e3f780ebdb5edf674aecfb9de24d0a8 100644 (file)
@@ -48,6 +48,7 @@
 
 #include "libavutil/imgutils.h"
 #include "avcodec.h"
+#include "internal.h"
 #include "put_bits.h"
 #include "bytestream.h"
 
@@ -191,6 +192,11 @@ static av_cold int flashsv2_encode_init(AVCodecContext * avctx)
                "Input dimensions too large, input must be max 4096x4096 !\n");
         return -1;
     }
+    if ((avctx->width < 16) || (avctx->height < 16)) {
+        av_log(avctx, AV_LOG_ERROR,
+               "Input dimensions too small, input must be at least 16x16 !\n");
+        return -1;
+    }
 
     if (av_image_check_size(avctx->width, avctx->height, 0, avctx) < 0)
         return -1;
@@ -204,6 +210,11 @@ static av_cold int flashsv2_encode_init(AVCodecContext * avctx)
     s->block_width  = (s->image_width /  12) & ~15;
     s->block_height = (s->image_height / 12) & ~15;
 
+    if(!s->block_width)
+        s->block_width = 1;
+    if(!s->block_height)
+        s->block_height = 1;
+
     s->rows = (s->image_height + s->block_height - 1) / s->block_height;
     s->cols = (s->image_width +  s->block_width -  1) / s->block_width;
 
@@ -833,11 +844,8 @@ static int flashsv2_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 
     *p = *pict;
 
-    if (!pkt->data &&
-        (res = av_new_packet(pkt, s->frame_size + FF_MIN_BUFFER_SIZE)) < 0) {
-        av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
+    if ((res = ff_alloc_packet2(avctx, pkt, s->frame_size + FF_MIN_BUFFER_SIZE)) < 0)
         return res;
-    }
 
     /* First frame needs to be a keyframe */
     if (avctx->frame_number == 0)