]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/matroska.c
Minor resync optimization
[ffmpeg] / libavformat / matroska.c
index 252c47ba5ed1918dd88951d313befba4569b6ad2..d22e85f2c2e93bdd9a4334ab46bf7dedbe8cb4fe 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "avformat.h"
 /* For codec_get_bmp_id and codec_get_wav_id. */
-#include "avi.h"
+#include "riff.h"
 #include "intfloat_readwrite.h"
 
 /* EBML version supported */
@@ -183,14 +183,14 @@ typedef enum {
  */
 
 typedef struct CodecTags{
-    char *str;
+    const char *str;
     enum CodecID id;
 }CodecTags;
 
 #define MATROSKA_CODEC_ID_VIDEO_VFW_FOURCC   "V_MS/VFW/FOURCC"
 #define MATROSKA_CODEC_ID_AUDIO_ACM          "A_MS/ACM"
 
-CodecTags codec_tags[]={
+static CodecTags codec_tags[]={
 //    {"V_MS/VFW/FOURCC"  , CODEC_ID_NONE},
     {"V_UNCOMPRESSED"   , CODEC_ID_RAWVIDEO},
     {"V_MPEG4/ISO/SP"   , CODEC_ID_MPEG4},
@@ -2417,7 +2417,7 @@ matroska_parse_blockgroup (MatroskaDemuxContext *matroska,
 
                 if (res == 0) {
                     for (n = 0; n < laces; n++) {
-                        uint64_t timecode = 0;
+                        uint64_t timecode = AV_NOPTS_VALUE;
 
                         pkt = av_mallocz(sizeof(AVPacket));
                         /* XXX: prevent data copy... */
@@ -2425,10 +2425,8 @@ matroska_parse_blockgroup (MatroskaDemuxContext *matroska,
                             res = AVERROR_NOMEM;
                             break;
                         }
-                        if (cluster_time != (uint64_t)-1) {
-                            if (block_time < 0 && (-block_time) > cluster_time)
-                                timecode = cluster_time;
-                            else
+                        if (cluster_time != (uint64_t)-1 && n == 0) {
+                            if (cluster_time + block_time >= 0)
                                 timecode = cluster_time + block_time;
                         }
                         /* FIXME: duration */
@@ -2632,16 +2630,12 @@ matroska_read_close (AVFormatContext *s)
         av_free(track);
     }
 
-    for (n = 0; n < s->nb_streams; n++) {
-        av_free(s->streams[n]->codec->extradata);
-    }
-
     memset(matroska, 0, sizeof(MatroskaDemuxContext));
 
     return 0;
 }
 
-static AVInputFormat matroska_iformat = {
+AVInputFormat matroska_demuxer = {
     "matroska",
     "Matroska file format",
     sizeof(MatroskaDemuxContext),
@@ -2650,10 +2644,3 @@ static AVInputFormat matroska_iformat = {
     matroska_read_packet,
     matroska_read_close,
 };
-
-int
-matroska_init(void)
-{
-    av_register_input_format(&matroska_iformat);
-    return 0;
-}