From 09379bbfe797e54f91ef5702c802f75aad604067 Mon Sep 17 00:00:00 2001
From: Paul Zander <negril.nx+gentoo@gmail.com>
Date: Mon, 26 Aug 2024 14:26:55 +0200
Subject: [PATCH 4/4] use std::abs instead of abs to avoid truncating values

Signed-off-by: Paul Zander <negril.nx+gentoo@gmail.com>

diff --git a/encoder/ratecontrol.cpp b/encoder/ratecontrol.cpp
index 9f2b8d9..7732ccd 100644
--- a/encoder/ratecontrol.cpp
+++ b/encoder/ratecontrol.cpp
@@ -1891,7 +1891,7 @@ double RateControl::tuneQScaleForGrain(double rcOverflow)
     int newQp = rcOverflow > 1.1 ? curQp + 2 : rcOverflow > 1 ? curQp + 1 : curQp - 1 ;
     double projectedBitrate =  int(m_fps + 0.5) * m_qpToEncodedBits[newQp];
     if (curBitrate > 0 && projectedBitrate > 0)
-        q =  abs(projectedBitrate - m_bitrate) < abs (curBitrate - m_bitrate) ? x265_qp2qScale(newQp) : m_lastQScaleFor[P_SLICE];
+        q =  std::abs(projectedBitrate - m_bitrate) < std::abs (curBitrate - m_bitrate) ? x265_qp2qScale(newQp) : m_lastQScaleFor[P_SLICE];
     else
         q = rcOverflow > 1 ? qScaleAvg * qpstep : rcOverflow < 1 ?  qScaleAvg / qpstep : m_lastQScaleFor[P_SLICE];
     return q;
