]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/thp.c
mpegts: Always honor a registration descriptor if present and there is no other codec...
[ffmpeg] / libavformat / thp.c
index 29312b4f7850851aaf0afe171774ff45b9c690e7..5a1205eb9ae0ee8d5b833bf8f4256da12bbab0fa 100644 (file)
@@ -20,8 +20,9 @@
  */
 
 #include "libavutil/intreadwrite.h"
-#include "libavutil/intfloat_readwrite.h"
+#include "libavutil/intfloat.h"
 #include "avformat.h"
+#include "internal.h"
 
 typedef struct ThpDemuxContext {
     int              version;
@@ -53,8 +54,7 @@ static int thp_probe(AVProbeData *p)
         return 0;
 }
 
-static int thp_read_header(AVFormatContext *s,
-                           AVFormatParameters *ap)
+static int thp_read_header(AVFormatContext *s)
 {
     ThpDemuxContext *thp = s->priv_data;
     AVStream *st;
@@ -68,7 +68,7 @@ static int thp_read_header(AVFormatContext *s,
                            avio_rb32(pb); /* Max buf size.  */
                            avio_rb32(pb); /* Max samples.  */
 
-    thp->fps             = av_d2q(av_int2flt(avio_rb32(pb)), INT_MAX);
+    thp->fps             = av_d2q(av_int2float(avio_rb32(pb)), INT_MAX);
     thp->framecnt        = avio_rb32(pb);
     thp->first_framesz   = avio_rb32(pb);
                            avio_rb32(pb); /* Data size.  */
@@ -100,7 +100,7 @@ static int thp_read_header(AVFormatContext *s,
 
             /* The denominator and numerator are switched because 1/fps
                is required.  */
-            av_set_pts_info(st, 64, thp->fps.den, thp->fps.num);
+            avpriv_set_pts_info(st, 64, thp->fps.den, thp->fps.num);
             st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
             st->codec->codec_id = CODEC_ID_THP;
             st->codec->codec_tag = 0;  /* no fourcc */
@@ -127,7 +127,7 @@ static int thp_read_header(AVFormatContext *s,
             st->codec->channels    = avio_rb32(pb); /* numChannels.  */
             st->codec->sample_rate = avio_rb32(pb); /* Frequency.  */
 
-            av_set_pts_info(st, 64, 1, st->codec->sample_rate);
+            avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
 
             thp->audio_stream_index = st->index;
             thp->has_audio = 1;
@@ -181,6 +181,9 @@ static int thp_read_packet(AVFormatContext *s,
         }
 
         pkt->stream_index = thp->audio_stream_index;
+        if (thp->audiosize >= 8)
+            pkt->duration = AV_RB32(&pkt->data[4]);
+
         thp->audiosize = 0;
         thp->frame++;
     }