]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/gxf.c
Remove redundant fastmemcpy.h #include, it is indirectly #included by avutil.h.
[ffmpeg] / libavformat / gxf.c
index 58cd5e3427bf923ef508bb6f7adabee957cc45c2..e6ee74c493026e6d4269e69e306d1bc4019f12c3 100644 (file)
@@ -87,8 +87,6 @@ static int parse_packet_header(ByteIOContext *pb, pkt_type_t *type, int *length)
 static int gxf_probe(AVProbeData *p) {
     static const uint8_t startcode[] = {0, 0, 0, 0, 1, 0xbc}; // start with map packet
     static const uint8_t endcode[] = {0, 0, 0, 0, 0xe1, 0xe2};
-    if (p->buf_size < 16)
-        return 0;
     if (!memcmp(p->buf, startcode, sizeof(startcode)) &&
         !memcmp(&p->buf[16 - sizeof(endcode)], endcode, sizeof(endcode)))
         return AVPROBE_SCORE_MAX;
@@ -130,11 +128,13 @@ static int get_sindex(AVFormatContext *s, int id, int format) {
         case 20:
             st->codec->codec_type = CODEC_TYPE_VIDEO;
             st->codec->codec_id = CODEC_ID_MPEG2VIDEO;
+            st->need_parsing = AVSTREAM_PARSE_HEADERS; //get keyframe flag etc.
             break;
         case 22:
         case 23:
             st->codec->codec_type = CODEC_TYPE_VIDEO;
             st->codec->codec_id = CODEC_ID_MPEG1VIDEO;
+            st->need_parsing = AVSTREAM_PARSE_HEADERS; //get keyframe flag etc.
             break;
         case 9:
             st->codec->codec_type = CODEC_TYPE_AUDIO;
@@ -160,6 +160,13 @@ static int get_sindex(AVFormatContext *s, int id, int format) {
             st->codec->channels = 2;
             st->codec->sample_rate = 48000;
             break;
+        // timecode tracks:
+        case 7:
+        case 8:
+        case 24:
+            st->codec->codec_type = CODEC_TYPE_DATA;
+            st->codec->codec_id = CODEC_ID_NONE;
+            break;
         default:
             st->codec->codec_type = CODEC_TYPE_UNKNOWN;
             st->codec->codec_id = CODEC_ID_NONE;
@@ -351,10 +358,11 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
         }
     }
     if (pkt_type == PKT_UMF) {
-        if (len >= 9) {
+        if (len >= 0x39) {
             AVRational fps;
-            len -= 9;
-            url_fskip(pb, 5);
+            len -= 0x39;
+            url_fskip(pb, 5); // preamble
+            url_fskip(pb, 0x30); // payload description
             fps = fps_umf2avr(get_le32(pb));
             if (!main_timebase.num || !main_timebase.den) {
                 // this may not always be correct, but simply the best we can get
@@ -366,13 +374,11 @@ static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
     } else
         av_log(s, AV_LOG_INFO, "GXF: UMF packet missing\n");
     url_fskip(pb, len);
+    if (!main_timebase.num || !main_timebase.den)
+        main_timebase = (AVRational){1, 50}; // set some arbitrary fallback
     for (i = 0; i < s->nb_streams; i++) {
         AVStream *st = s->streams[i];
-        if (main_timebase.num && main_timebase.den)
-            st->time_base = main_timebase;
-        else {
-            st->start_time = st->duration = AV_NOPTS_VALUE;
-        }
+        av_set_pts_info(st, 32, main_timebase.num, main_timebase.den);
     }
     return 0;
 }
@@ -488,7 +494,7 @@ static int gxf_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int
     maxlen = FFMAX(maxlen, 200 * 1024);
     url_fseek(&s->pb, pos, SEEK_SET);
     found = gxf_resync_media(s, maxlen, -1, timestamp);
-    if (ABS(found - timestamp) > 4)
+    if (FFABS(found - timestamp) > 4)
         return -1;
     return 0;
 }