]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/gifdec.c
avfilter: Remove deprecated resample_lavr_opts
[ffmpeg] / libavcodec / gifdec.c
index 2eeed4c4c701b1e79af8dc4fdcbee107f86113ac..1906a4c738cbf2cd42ce3fdf830f7854e2d1380d 100644 (file)
@@ -179,12 +179,20 @@ static int gif_read_image(GifState *s, AVFrame *frame)
     }
 
     /* verify that all the image is inside the screen dimensions */
-    if (!width || width > s->screen_width || left >= s->screen_width) {
-        av_log(s->avctx, AV_LOG_ERROR, "Invalid image width.\n");
+    if (!width || width > s->screen_width) {
+        av_log(s->avctx, AV_LOG_WARNING, "Invalid image width: %d, truncating.\n", width);
+        width = s->screen_width;
+    }
+    if (left >= s->screen_width) {
+        av_log(s->avctx, AV_LOG_ERROR, "Invalid left position: %d.\n", left);
         return AVERROR_INVALIDDATA;
     }
-    if (!height || height > s->screen_height || top >= s->screen_height) {
-        av_log(s->avctx, AV_LOG_ERROR, "Invalid image height.\n");
+    if (!height || height > s->screen_height) {
+        av_log(s->avctx, AV_LOG_WARNING, "Invalid image height: %d, truncating.\n", height);
+        height = s->screen_height;
+    }
+    if (top >= s->screen_height) {
+        av_log(s->avctx, AV_LOG_ERROR, "Invalid top position: %d.\n", top);
         return AVERROR_INVALIDDATA;
     }
     if (left + width > s->screen_width) {
@@ -451,6 +459,8 @@ static av_cold int gif_decode_init(AVCodecContext *avctx)
     if (!s->frame)
         return AVERROR(ENOMEM);
     ff_lzw_decode_open(&s->lzw);
+    if (!s->lzw)
+        return AVERROR(ENOMEM);
     return 0;
 }
 
@@ -503,7 +513,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
             return AVERROR_INVALIDDATA;
         }
 
-        if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
+        if ((ret = ff_reget_buffer(avctx, s->frame, 0)) < 0)
             return ret;
 
         s->frame->pict_type = AV_PICTURE_TYPE_P;
@@ -559,5 +569,7 @@ AVCodec ff_gif_decoder = {
     .close          = gif_decode_close,
     .decode         = gif_decode_frame,
     .capabilities   = AV_CODEC_CAP_DR1,
+    .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE |
+                      FF_CODEC_CAP_INIT_CLEANUP,
     .priv_class     = &decoder_class,
 };