]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/omadec.c
Merge commit 'e352520e3ed7f08f19e63cd60e95da6bb6f037c1'
[ffmpeg] / libavformat / omadec.c
index 9f3d3aa860fd5472a4508ceef6c1f4ab7d070fe6..b08005538ccefbe9d987cdb14a7afd0b4d51c266 100644 (file)
@@ -47,6 +47,7 @@
 #include "internal.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/des.h"
+#include "libavutil/mathematics.h"
 #include "oma.h"
 #include "pcm.h"
 #include "id3v2.h"
@@ -174,7 +175,7 @@ static int nprobe(AVFormatContext *s, uint8_t *enc_header, unsigned size,
     taglen  = AV_RB32(&enc_header[pos + 32]);
     datalen = AV_RB32(&enc_header[pos + 36]) >> 4;
 
-    pos += 44L + taglen;
+    pos += 44LL + taglen;
 
     if (pos + (((uint64_t)datalen) << 4) > size)
         return -1;
@@ -412,9 +413,12 @@ static int oma_read_header(AVFormatContext *s)
 
 static int oma_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
-    OMAContext *oc = s->priv_data;
-    int packet_size = s->streams[0]->codec->block_align;
-    int ret = av_get_packet(s->pb, pkt, packet_size);
+    OMAContext *oc  = s->priv_data;
+    AVStream *st    = s->streams[0];
+    int packet_size = st->codec->block_align;
+    int byte_rate   = st->codec->bit_rate >> 3;
+    int64_t pos     = avio_tell(s->pb);
+    int ret         = av_get_packet(s->pb, pkt, packet_size);
 
     if (ret < packet_size)
         pkt->flags |= AV_PKT_FLAG_CORRUPT;
@@ -426,6 +430,12 @@ static int oma_read_packet(AVFormatContext *s, AVPacket *pkt)
 
     pkt->stream_index = 0;
 
+    if (pos > 0) {
+        pkt->pts =
+        pkt->dts = av_rescale(pos, st->time_base.den,
+                              byte_rate * (int64_t)st->time_base.num);
+    }
+
     if (oc->encrypted) {
         /* previous unencrypted block saved in IV for
          * the next packet (CBC mode) */