[FFmpeg-cvslog] avcodec/qtrleenc: Use keyframe when no previous frame is available

Andreas Rheinhardt git at videolan.org
Sat Apr 3 01:18:34 EEST 2021


ffmpeg | branch: release/4.4 | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Fri Mar 26 12:42:21 2021 +0100| [6614f33a0b3862753f743253afdb8e1944e26167] | committer: Andreas Rheinhardt

avcodec/qtrleenc: Use keyframe when no previous frame is available

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 at gmail.com>
(cherry picked from commit d5fc16a6a87a24360312b812a560e7a3664e3791)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6614f33a0b3862753f743253afdb8e1944e26167
---

 libavcodec/qtrleenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/qtrleenc.c b/libavcodec/qtrleenc.c
index 8b0edf7b3d..0f5bedcdcd 100644
--- a/libavcodec/qtrleenc.c
+++ b/libavcodec/qtrleenc.c
@@ -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 {



More information about the ffmpeg-cvslog mailing list