[FFmpeg-devel] [PATCH v2 6/7] avformat/argo_brp: remove usage of floats

Zane van Iperen zane at zanevaniperen.com
Fri Sep 18 15:05:05 EEST 2020


Signed-off-by: Zane van Iperen <zane at zanevaniperen.com>
---
 libavformat/argo_brp.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/libavformat/argo_brp.c b/libavformat/argo_brp.c
index a3e9846c74..3a5a0c0497 100644
--- a/libavformat/argo_brp.c
+++ b/libavformat/argo_brp.c
@@ -78,8 +78,8 @@ typedef struct ArgoBRPStreamHeader {
 typedef struct ArgoBRPDemuxContext {
     ArgoBRPFileHeader   fhdr;
     ArgoBRPStreamHeader *streams;
-    /* To know how much of a BASF to give. */
-    int64_t             lastpts;
+    /* Current PTS converted into BASF timebase (samples). */
+    int64_t             currpts;
     int                 hit_eof;
 
     /* BASF-specific fields. */
@@ -88,7 +88,6 @@ typedef struct ArgoBRPDemuxContext {
         ArgoASFChunkHeader  ckhdr;
         uint32_t            blocks_read;
         int64_t             offset;
-        /* ms, not samples. */
         int64_t             lastpts;
     } basf;
 } ArgoBRPDemuxContext;
@@ -352,7 +351,7 @@ static int argo_brp_read_basf(AVFormatContext *s, AVPacket *pkt,
     if (brp->basf.blocks_read >= ckhdr->num_blocks)
         return 0;
 
-    if (!ignorepts && brp->lastpts < brp->basf.lastpts)
+    if (!ignorepts && brp->currpts < brp->basf.lastpts)
         return 0;
 
     if ((ret = avio_tell(s->pb)) < 0)
@@ -377,8 +376,7 @@ static int argo_brp_read_basf(AVFormatContext *s, AVPacket *pkt,
 
     brp->basf.offset      += pkt->size;
     brp->basf.blocks_read += blocks_read;
-    /* Need the ceil() because ((1 * 32 * 1000) / 44100) < 1 */
-    brp->basf.lastpts     += ceilf((blocks_read * ckhdr->num_samples * 1000.0f) / ckhdr->sample_rate);
+    brp->basf.lastpts     += blocks_read * brp->basf.ckhdr.num_samples;
     return 1;
 }
 
@@ -434,7 +432,13 @@ static int argo_brp_read_packet(AVFormatContext *s, AVPacket *pkt)
 
     pkt->stream_index = blk.stream_id;
     pkt->pts          = blk.start_ms;
-    brp->lastpts      = FFMAX(brp->lastpts, blk.start_ms);
+
+    if (brp->basf.index >= 0) {
+        int64_t pts = av_rescale_rnd(blk.start_ms, brp->basf.ckhdr.sample_rate,
+                                     1000, AV_ROUND_UP);
+        brp->currpts = FFMAX(brp->currpts, pts);
+    }
+
     return 0;
 }
 
-- 
2.25.4




More information about the ffmpeg-devel mailing list