[FFmpeg-cvslog] avformat/dsfdec: set packet pts/duration/pos correctly

Paul B Mahol git at videolan.org
Wed Aug 28 18:49:51 EEST 2019


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Tue Jul 30 13:16:33 2019 +0200| [98f5cbcb7db455dac8b4a6cbbe0dd72ec6a892fd] | committer: Paul B Mahol

avformat/dsfdec: set packet pts/duration/pos correctly

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=98f5cbcb7db455dac8b4a6cbbe0dd72ec6a892fd
---

 libavformat/dsfdec.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/libavformat/dsfdec.c b/libavformat/dsfdec.c
index afb24634b2..9be206af84 100644
--- a/libavformat/dsfdec.c
+++ b/libavformat/dsfdec.c
@@ -130,6 +130,7 @@ static int dsf_read_header(AVFormatContext *s)
     }
     st->codecpar->block_align *= st->codecpar->channels;
     st->codecpar->bit_rate = st->codecpar->channels * st->codecpar->sample_rate * 8LL;
+    avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
     avio_skip(pb, 4);
 
     /* data chunk */
@@ -150,11 +151,11 @@ static int dsf_read_packet(AVFormatContext *s, AVPacket *pkt)
     AVIOContext *pb = s->pb;
     AVStream *st = s->streams[0];
     int64_t pos = avio_tell(pb);
+    int ret;
 
     if (pos >= dsf->data_end)
         return AVERROR_EOF;
 
-    pkt->stream_index = 0;
     if (dsf->data_size > dsf->audio_size) {
         int last_packet = pos == (dsf->data_end - st->codecpar->block_align);
 
@@ -180,10 +181,22 @@ static int dsf_read_packet(AVFormatContext *s, AVPacket *pkt)
                 avio_skip(pb, skip_size / st->codecpar->channels);
             }
 
+            pkt->pos = pos;
+            pkt->stream_index = 0;
+            pkt->pts = (pos - s->internal->data_offset) / st->codecpar->channels;
+            pkt->duration = packet_size / st->codecpar->channels;
             return 0;
         }
     }
-    return av_get_packet(pb, pkt, FFMIN(dsf->data_end - pos, st->codecpar->block_align));
+    ret = av_get_packet(pb, pkt, FFMIN(dsf->data_end - pos, st->codecpar->block_align));
+    if (ret < 0)
+        return ret;
+
+    pkt->stream_index = 0;
+    pkt->pts = (pos - s->internal->data_offset) / st->codecpar->channels;
+    pkt->duration = st->codecpar->block_align / st->codecpar->channels;
+
+    return 0;
 }
 
 AVInputFormat ff_dsf_demuxer = {



More information about the ffmpeg-cvslog mailing list