From patchwork Thu Oct 12 23:27:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 44234 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4b15:b0:15d:8365:d4b8 with SMTP id fp21csp660467pzb; Thu, 12 Oct 2023 16:28:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEhm9h8njT/PtfrnN8T2SPTG2+wucSCBCPZperXHiPp8TCZ1vob1oQNzH0O5iImF8jNpKQG X-Received: by 2002:a05:6402:ea2:b0:53d:af60:219f with SMTP id h34-20020a0564020ea200b0053daf60219fmr7233924eda.10.1697153300332; Thu, 12 Oct 2023 16:28:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697153300; cv=none; d=google.com; s=arc-20160816; b=JwJ/e5BADsPbk51/LPaJzvvjNQdwalpQfN39ob7FTsA922WvLnxIHynZK06YkrLVoL 8rQFJO7T1gf5telpnTOARJjCGN/a9Ky49jYfHzyMDnNsz/KIMh2I5ednrZYYx4pOorGS edpyxH7IkYR9RG2LyAHDVvrpQqkP95FWB2mzgWI1B30tyKZAPtq+4zuYbWe3A+swXqKL /P1vLxctSdZ/NiCFCSEwZQQ2i2S7rL0p/V/WJv9kfT26m1yxEjaopKrWLwnnUoHRgee9 0aLPGTf+acZ5OrGfdNlECKyma4+Rqq0rWWcWxmSYrrYARpoWenYNcGKGDOihMm7PmHr5 jXuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=eCovw9iiS4hbOxRRHnsdsj2UoLnPEVUz21EWh6dRgGY=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=ZED0V4RHSe8JIQ9nhmYD3q0R4SmZ3boQ/a4ekmGoetN4gMhCZApnGXeKK/POPAhAS7 AunbtBPm5kjPJHtypDvmYtyvknHKrS2xF446TXm5N/RuMIaD6hrWKNcNrUdFzOUCCobA FVwnJ1QoHoLn4n2xnxKDT18ySzzGO5qTKbbm2qALeXV5BeRUc81yRvaBOZhwZnMPHhy+ hAopD1kGI++7pDgVZEDeJFmvzozPUMumKuZKeboskDzIutpiZGH+4eqq6PY11n8N3INl fv/XMVxmzv3QoiUvag3fs6hm+NilUh9j0tJb1yjSRh0y0lUygOU+FBbadDggpvXMYIC+ 76Jw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id c18-20020a056402121200b0053dff300911si1472097edw.376.2023.10.12.16.28.20; Thu, 12 Oct 2023 16:28:20 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 31B0568C9E5; Fri, 13 Oct 2023 02:28:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E423468C9BE for ; Fri, 13 Oct 2023 02:28:01 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 37A16FF806 for ; Thu, 12 Oct 2023 23:28:00 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 13 Oct 2023 01:27:58 +0200 Message-Id: <20231012232759.5352-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231012232759.5352-1-michael@niedermayer.cc> References: <20231012232759.5352-1-michael@niedermayer.cc> X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 2/3] 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: UmLjyqwfiI/v 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 bd3a4416f2..255706ce61 100644 --- a/libavcodec/evc_parse.c +++ b/libavcodec/evc_parse.c @@ -172,7 +172,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; @@ -187,15 +188,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; } }