diff mbox

[FFmpeg-devel] avformat/segafilm - fix keyframe detection and set packet, flags

Message ID 4ff1f397-e3f1-71ea-7396-dbc182217222@gmail.com
State Accepted
Headers show

Commit Message

Gyan March 22, 2018, 4:49 a.m. UTC
On 3/22/2018 2:02 AM, Carl Eugen Hoyos wrote:

> Can you comment on why this 15-year old code was wrong?

It inverts the correct assignment of keyframe status. On the sample file 
uploaded to trac, the existing code marks the first frame as non-KF and 
all remaining frames as KF.

Changed to AVINDEX_KEYFRAME.

Regards,
Gyan
From 443de6adc84c2cd5f11bb5e35f2e3bccb09d3b70 Mon Sep 17 00:00:00 2001
From: Gyan Doshi <gyandoshi@gmail.com>
Date: Wed, 21 Mar 2018 18:59:33 +0530
Subject: [PATCH] avformat/segafilm - fix keyframe detection and set packet
 flags

Streams from a Segafilm cpk file can't be streamcopied because
keyframe flag isn't correctly set in stream index and
said flag is never conveyed to the packet

Fixes #7091
---
 libavformat/segafilm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/libavformat/segafilm.c b/libavformat/segafilm.c
index 1fdef50cc7..383ec4d216 100644
--- a/libavformat/segafilm.c
+++ b/libavformat/segafilm.c
@@ -239,7 +239,7 @@  static int film_read_header(AVFormatContext *s)
         } else {
             film->sample_table[i].stream = film->video_stream_index;
             film->sample_table[i].pts = AV_RB32(&scratch[8]) & 0x7FFFFFFF;
-            film->sample_table[i].keyframe = (scratch[8] & 0x80) ? 0 : 1;
+            film->sample_table[i].keyframe = (scratch[8] & 0x80) ? AVINDEX_KEYFRAME : 0;
             video_frame_counter++;
             if (film->video_type)
                 av_add_index_entry(s->streams[film->video_stream_index],
@@ -286,6 +286,7 @@  static int film_read_packet(AVFormatContext *s,
 
     pkt->stream_index = sample->stream;
     pkt->pts = sample->pts;
+    pkt->flags |= sample->keyframe;
 
     film->current_sample++;