changeset 1902:4225f8dc0098 libavformat

check if current block contains a B frame and gives this info to parse_block()
author aurel
date Sun, 11 Mar 2007 23:05:01 +0000
parents 3f05dc37b4ec
children 0f2186d1cc19
files matroska.c
diffstat 1 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/matroska.c	Sun Mar 11 22:54:15 2007 +0000
+++ b/matroska.c	Sun Mar 11 23:05:01 2007 +0000
@@ -2377,7 +2377,8 @@
 static int
 matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, int size,
                      int64_t pos, uint64_t cluster_time,
-                     int is_keyframe, int *ptrack, AVPacket **ppkt)
+                     int is_keyframe, int is_bframe,
+                     int *ptrack, AVPacket **ppkt)
 {
     int res = 0;
     int track;
@@ -2558,6 +2559,7 @@
     int res = 0;
     uint32_t id;
     AVPacket *pkt = NULL;
+    int is_bframe = 0;
     int is_keyframe = PKT_FLAG_KEY, last_num_packets = matroska->num_packets;
     uint64_t duration = AV_NOPTS_VALUE;
     int track = -1;
@@ -2592,14 +2594,19 @@
                 break;
             }
 
-            case MATROSKA_ID_BLOCKREFERENCE:
+            case MATROSKA_ID_BLOCKREFERENCE: {
+                int64_t num;
                 /* We've found a reference, so not even the first frame in
                  * the lace is a key frame. */
                 is_keyframe = 0;
                 if (last_num_packets != matroska->num_packets)
                     matroska->packets[last_num_packets]->flags = 0;
-                res = ebml_read_skip(matroska);
+                if ((res = ebml_read_sint(matroska, &id, &num)) < 0)
+                    break;
+                if (num > 0)
+                    is_bframe = 1;
                 break;
+            }
 
             default:
                 av_log(matroska->ctx, AV_LOG_INFO,
@@ -2622,7 +2629,7 @@
 
     if (size > 0)
         res = matroska_parse_block(matroska, data, size, pos, cluster_time,
-                                   is_keyframe, &track, &pkt);
+                                   is_keyframe, is_bframe, &track, &pkt);
 
     if (pkt)
     {
@@ -2679,7 +2686,7 @@
                 res = ebml_read_binary(matroska, &id, &data, &size);
                 if (res == 0)
                     res = matroska_parse_block(matroska, data, size, pos,
-                                               cluster_time, -1, NULL, NULL);
+                                               cluster_time, -1,0, NULL, NULL);
                 break;
 
             default: