From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 788F1472C8 for ; Wed, 4 Oct 2023 22:59:51 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DC75F68CBC5; Thu, 5 Oct 2023 01:59:31 +0300 (EEST) Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 13FD668CAF4 for ; Thu, 5 Oct 2023 01:59:25 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 4B868C0004 for ; Wed, 4 Oct 2023 22:59:23 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 5 Oct 2023 00:59:20 +0200 Message-Id: <20231004225921.30287-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231004225921.30287-1-michael@niedermayer.cc> References: <20231004225921.30287-1-michael@niedermayer.cc> X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 3/4] avcodec/evc_parse: remove pow() and log2() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: The use of float based functions is both unneeded and wrong due to unpredictable rounding Signed-off-by: Michael Niedermayer --- libavcodec/evc_parse.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libavcodec/evc_parse.c b/libavcodec/evc_parse.c index 5ab33166cf3..20b6849041a 100644 --- a/libavcodec/evc_parse.c +++ b/libavcodec/evc_parse.c @@ -176,7 +176,8 @@ int ff_evc_derive_poc(const EVCParamSets *ps, const EVCParserSliceHeader *sh, poc->PicOrderCntVal = 0; poc->DocOffset = -1; } else { - int SubGopLength = (int)pow(2.0, sps->log2_sub_gop_length); + int SubGopLength = 1 << sps->log2_sub_gop_length; + if (tid == 0) { poc->PicOrderCntVal = poc->prevPicOrderCntVal + SubGopLength; poc->DocOffset = 0; @@ -191,15 +192,16 @@ int ff_evc_derive_poc(const EVCParamSets *ps, const EVCParserSliceHeader *sh, poc->prevPicOrderCntVal += SubGopLength; ExpectedTemporalId = 0; } else - ExpectedTemporalId = 1 + (int)log2(poc->DocOffset); + ExpectedTemporalId = 1 + av_log2(poc->DocOffset); + while (tid != ExpectedTemporalId) { poc->DocOffset = (poc->DocOffset + 1) % SubGopLength; if (poc->DocOffset == 0) ExpectedTemporalId = 0; else - ExpectedTemporalId = 1 + (int)log2(poc->DocOffset); + ExpectedTemporalId = 1 + av_log2(poc->DocOffset); } - PocOffset = (int)(SubGopLength * ((2.0 * poc->DocOffset + 1) / (int)pow(2.0, tid) - 2)); + PocOffset = (int)(SubGopLength * ((2.0 * poc->DocOffset + 1) / (1 << tid) - 2)); poc->PicOrderCntVal = poc->prevPicOrderCntVal + PocOffset; } } -- 2.17.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".