]> git.sesse.net Git - ffmpeg/commitdiff
ffv1enc: Keep coded_frame.key_frame a write-only variable
authorVittorio Giovara <vittorio.giovara@gmail.com>
Wed, 15 Jul 2015 17:41:17 +0000 (18:41 +0100)
committerVittorio Giovara <vittorio.giovara@gmail.com>
Mon, 20 Jul 2015 13:13:42 +0000 (14:13 +0100)
libavcodec/ffv1.h
libavcodec/ffv1enc.c

index bc433bceb5f95db60e444236790597ac79fa6d44..6e8c798b6a1478c9736b507cd77a937646cdcebc 100644 (file)
@@ -78,6 +78,7 @@ typedef struct FFV1Context {
     int transparency;
     int flags;
     int picture_number;
+    int key_frame;
     const AVFrame *frame;
     AVFrame *last_picture;
 
index f689bd98b49ac74771bb630e5f970478b0dcb559..ad52f155d11df48c853c1c872becdee13d4a6720 100644 (file)
@@ -884,7 +884,7 @@ static int encode_slice(AVCodecContext *c, void *arg)
                        ? (f->bits_per_raw_sample > 8) + 1
                        : 4;
 
-    if (c->coded_frame->key_frame)
+    if (f->key_frame)
         ffv1_clear_slice_state(f, fs);
     if (f->version > 2) {
         encode_slice_header(f, fs);
@@ -931,7 +931,6 @@ static int ffv1_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 {
     FFV1Context *f      = avctx->priv_data;
     RangeCoder *const c = &f->slice_context[0]->c;
-    AVFrame *const p    = avctx->coded_frame;
     int used_count      = 0;
     uint8_t keystate    = 128;
     uint8_t *buf_p;
@@ -951,12 +950,12 @@ static int ffv1_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 
     if (avctx->gop_size == 0 || f->picture_number % avctx->gop_size == 0) {
         put_rac(c, &keystate, 1);
-        p->key_frame = 1;
+        f->key_frame = 1;
         f->gob_count++;
         write_header(f);
     } else {
         put_rac(c, &keystate, 0);
-        p->key_frame = 0;
+        f->key_frame = 0;
     }
 
     if (f->ac > 1) {
@@ -1050,9 +1049,11 @@ static int ffv1_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     } else if (avctx->flags & CODEC_FLAG_PASS1)
         avctx->stats_out[0] = '\0';
 
+    avctx->coded_frame->key_frame = f->key_frame;
+
     f->picture_number++;
     pkt->size   = buf_p - pkt->data;
-    pkt->flags |= AV_PKT_FLAG_KEY * p->key_frame;
+    pkt->flags |= AV_PKT_FLAG_KEY * f->key_frame;
     *got_packet = 1;
 
     return 0;