]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/imm4.c
avcodec/put_bits: Parametrize bit buffer type
[ffmpeg] / libavcodec / imm4.c
index b66689acab29f1bbcb2bb960ebbc4008508bd020..d92bc30ddcbc10eb7942ff66addce81f02a75f22 100644 (file)
@@ -446,11 +446,13 @@ static int decode_frame(AVCodecContext *avctx, void *data,
         return AVERROR_PATCHWELCOME;
     }
 
-    if (!frame->key_frame &&
-        (avctx->width != width ||
-         avctx->height != height)) {
-        av_log(avctx, AV_LOG_ERROR, "Frame size change is unsupported.\n");
-        return AVERROR_INVALIDDATA;
+    if (avctx->width  != width ||
+        avctx->height != height) {
+        if (!frame->key_frame) {
+            av_log(avctx, AV_LOG_ERROR, "Frame size change is unsupported.\n");
+            return AVERROR_INVALIDDATA;
+        }
+        av_frame_unref(s->prev_frame);
     }
 
     ret = ff_set_dimensions(avctx, width, height);
@@ -521,6 +523,13 @@ static av_cold int decode_init(AVCodecContext *avctx)
     return 0;
 }
 
+static void decode_flush(AVCodecContext *avctx)
+{
+    IMM4Context *s = avctx->priv_data;
+
+    av_frame_unref(s->prev_frame);
+}
+
 static av_cold int decode_close(AVCodecContext *avctx)
 {
     IMM4Context *s = avctx->priv_data;
@@ -541,6 +550,7 @@ AVCodec ff_imm4_decoder = {
     .init             = decode_init,
     .close            = decode_close,
     .decode           = decode_frame,
+    .flush            = decode_flush,
     .capabilities     = AV_CODEC_CAP_DR1,
     .caps_internal    = FF_CODEC_CAP_INIT_THREADSAFE |
                         FF_CODEC_CAP_INIT_CLEANUP,