]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/qtrleenc: Use keyframe when no previous frame is available
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Fri, 26 Mar 2021 11:42:21 +0000 (12:42 +0100)
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
Thu, 1 Apr 2021 12:15:52 +0000 (14:15 +0200)
If keeping a reference to an earlier frame failed, the next frame must
be an I frame for lack of reference frame. This commit implements this.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavcodec/qtrleenc.c

index 8b0edf7b3d8bb6189934916ce1be261d85ebfe0e..0f5bedcdcd046cdb761c4ab48fdfc11fe7689fd5 100644 (file)
@@ -369,7 +369,8 @@ static int qtrle_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     if ((ret = ff_alloc_packet2(avctx, pkt, s->max_buf_size, 0)) < 0)
         return ret;
 
-    if (avctx->gop_size == 0 || (s->avctx->frame_number % avctx->gop_size) == 0) {
+    if (avctx->gop_size == 0 || !s->previous_frame->data[0] ||
+        (s->avctx->frame_number % avctx->gop_size) == 0) {
         /* I-Frame */
         s->key_frame = 1;
     } else {