diff mbox

[FFmpeg-devel,1/2] avformat/bink: properly mark packets that are key frames

Message ID 20190327202147.25502-1-onemda@gmail.com
State Accepted
Headers show

Commit Message

Paul B Mahol March 27, 2019, 8:21 p.m. UTC
Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavformat/bink.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Comments

Peter Ross March 28, 2019, 9:01 a.m. UTC | #1
On Wed, Mar 27, 2019 at 09:21:46PM +0100, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
>  libavformat/bink.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 

this patch lgtm

tested on some bink b samples too.

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
diff mbox

Patch

diff --git a/libavformat/bink.c b/libavformat/bink.c
index 631b8c4d7d..44eb04362e 100644
--- a/libavformat/bink.c
+++ b/libavformat/bink.c
@@ -56,6 +56,7 @@  typedef struct BinkDemuxContext {
     int64_t audio_pts[BINK_MAX_AUDIO_TRACKS];
 
     uint32_t remain_packet_size;
+    int flags;
     int smush_size;
 } BinkDemuxContext;
 
@@ -90,6 +91,7 @@  static int read_header(AVFormatContext *s)
     unsigned int i;
     uint32_t pos, next_pos;
     uint16_t flags;
+    int next_keyframe = 1;
     int keyframe;
     int ret;
     uint32_t signature;
@@ -203,12 +205,13 @@  static int read_header(AVFormatContext *s)
     next_pos = avio_rl32(pb);
     for (i = 0; i < vst->duration; i++) {
         pos = next_pos;
+        keyframe = next_keyframe;
         if (i == vst->duration - 1) {
             next_pos = bink->file_size;
-            keyframe = 0;
+            next_keyframe = 0;
         } else {
             next_pos = avio_rl32(pb);
-            keyframe = pos & 1;
+            next_keyframe = next_pos & 1;
         }
         pos &= ~1;
         next_pos &= ~1;
@@ -254,6 +257,7 @@  static int read_packet(AVFormatContext *s, AVPacket *pkt)
         }
 
         bink->remain_packet_size = st->index_entries[index_entry].size;
+        bink->flags = st->index_entries[index_entry].flags;
         bink->current_track = 0;
     }
 
@@ -290,7 +294,8 @@  static int read_packet(AVFormatContext *s, AVPacket *pkt)
         return ret;
     pkt->stream_index = 0;
     pkt->pts = bink->video_pts++;
-    pkt->flags |= AV_PKT_FLAG_KEY;
+    if (bink->flags & AVINDEX_KEYFRAME)
+        pkt->flags |= AV_PKT_FLAG_KEY;
 
     /* -1 instructs the next call to read_packet() to read the next frame */
     bink->current_track = -1;