From patchwork Fri Sep 18 12:05:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zane van Iperen X-Patchwork-Id: 22474 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 37F8544A787 for ; Fri, 18 Sep 2020 15:05:22 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1D0D968B9C7; Fri, 18 Sep 2020 15:05:22 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail2.protonmail.ch (mail2.protonmail.ch [185.70.40.22]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A53BC68B94F for ; Fri, 18 Sep 2020 15:05:15 +0300 (EEST) Date: Fri, 18 Sep 2020 12:05:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zanevaniperen.com; s=protonmail2; t=1600430714; bh=86ozy6Bigk2Ha1D8YCpLitzNDicQJZxQne9rj7zUiP0=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=jPBwSaI1LOldVv6PUQ5AK7p0ArhuqGmj0XXqBKBb7LjrfXG1Ryr4pf6OUBUt74lh/ D2yzW2vx4wMVvFoinJHwnaKHB4CATiY6nnoFoQ05otTu2vp2Q0WNW3UR1ZpdyzVBRI YTmS2gAIURJjxX/Fl74p08ADJo2I+r88fuS4P/vZprjdcsa3g58uCDlSsIsv/5OYun XkugbSn3vI6ZMnAdF0Xm4HCVeZ1Jy6ifQXO6SFJ151wpwq48Ui8Vo0GClaxVyP4r3P duQKOZAUPT1H6tYNe2Vecce5EWZdNVNO00B1Unq/s/ElzdQ8klsa1KfC2Z6E7rS8Dg 71GA9RzoOgZSg== To: ffmpeg-devel@ffmpeg.org From: Zane van Iperen Message-ID: <20200918120416.7319-7-zane@zanevaniperen.com> In-Reply-To: <20200918120416.7319-1-zane@zanevaniperen.com> References: <20200918120416.7319-1-zane@zanevaniperen.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch Subject: [FFmpeg-devel] [PATCH v2 6/7] avformat/argo_brp: remove usage of floats X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Zane van Iperen Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Zane van Iperen --- 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; }