]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/gxf.c
RFC 2 stage: First feedback from review comments
[ffmpeg] / libavformat / gxf.c
index 26c3fc1c0f42ed56b8dcfb5a6e4c05725a84fa54..897cdade0f1377e5133e93a25c4f772a3227acc5 100644 (file)
@@ -2,18 +2,20 @@
  * GXF demuxer.
  * Copyright (c) 2006 Reimar Doeffinger.
  *
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
  *
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #include "avformat.h"
@@ -128,16 +130,17 @@ 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 = 2; // 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 = 2; // get keyframe flag etc.
             break;
         case 9:
             st->codec->codec_type = CODEC_TYPE_AUDIO;
             st->codec->codec_id = CODEC_ID_PCM_S24LE;
-            st->codec->codec_tag = 0x1;
             st->codec->channels = 1;
             st->codec->sample_rate = 48000;
             st->codec->bit_rate = 3 * 1 * 48000 * 8;
@@ -147,7 +150,6 @@ static int get_sindex(AVFormatContext *s, int id, int format) {
         case 10:
             st->codec->codec_type = CODEC_TYPE_AUDIO;
             st->codec->codec_id = CODEC_ID_PCM_S16LE;
-            st->codec->codec_tag = 0x1;
             st->codec->channels = 1;
             st->codec->sample_rate = 48000;
             st->codec->bit_rate = 2 * 1 * 48000 * 8;
@@ -157,10 +159,16 @@ static int get_sindex(AVFormatContext *s, int id, int format) {
         case 17:
             st->codec->codec_type = CODEC_TYPE_AUDIO;
             st->codec->codec_id = CODEC_ID_AC3;
-            st->codec->codec_tag = 0x2000;
             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;
@@ -465,7 +473,7 @@ static int gxf_packet(AVFormatContext *s, AVPacket *pkt) {
         // as well.
         ret = av_get_packet(pb, pkt, pkt_len);
         pkt->stream_index = get_sindex(s, track_id, track_type);
-        pkt->pts = field_nr;
+        pkt->dts = field_nr;
         return ret;
     }
     return AVERROR_IO;
@@ -489,7 +497,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;
 }