diff mbox series

[FFmpeg-devel,07/10] avformat/argo_brp: set BVID packet duration

Message ID 20200920080528.26200-8-zane@zanevaniperen.com
State Accepted
Headers show
Series argo_brp cleanups and fixes
Related show

Commit Message

Zane van Iperen Sept. 20, 2020, 8:07 a.m. UTC
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
---
 libavformat/argo_brp.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/libavformat/argo_brp.c b/libavformat/argo_brp.c
index fb5c2b7245..ad54420283 100644
--- a/libavformat/argo_brp.c
+++ b/libavformat/argo_brp.c
@@ -306,6 +306,7 @@  static int argo_brp_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
     ArgoBRPDemuxContext *brp = s->priv_data;
     ArgoBRPBlockHeader blk;
+    const ArgoBRPStreamHeader *shdr;
     AVStream *st;
     uint8_t buf[BRP_MIN_BUFFER_SIZE];
     ArgoASFChunkHeader ckhdr;
@@ -327,6 +328,7 @@  static int argo_brp_read_packet(AVFormatContext *s, AVPacket *pkt)
         return AVERROR_INVALIDDATA;
 
     st = s->streams[blk.stream_id];
+    shdr = brp->streams + blk.stream_id;
 
     if (blk.stream_id == brp->basf.index) {
         if (blk.size < ASF_CHUNK_HEADER_SIZE)
@@ -358,6 +360,9 @@  static int argo_brp_read_packet(AVFormatContext *s, AVPacket *pkt)
     if (blk.stream_id == brp->basf.index) {
         pkt->duration = ckhdr.num_samples * ckhdr.num_blocks;
         pkt->pts      = av_rescale_rnd(blk.start_ms, ckhdr.sample_rate, 1000, AV_ROUND_UP);
+    } else if (brp->streams[blk.stream_id].codec_id == BRP_CODEC_ID_BVID) {
+        pkt->duration = av_rescale_rnd(1, st->duration, shdr->extradata.bvid.num_frames, AV_ROUND_UP);
+        pkt->pts      = blk.start_ms;
     } else {
         pkt->pts      = blk.start_ms;
     }