---
updated patch. avoids calling ff_sqrt() twice in FFMIN macro.

 libavcodec/ac3enc_fixed.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c
index 26bba0f..adb7352 100644
--- a/libavcodec/ac3enc_fixed.c
+++ b/libavcodec/ac3enc_fixed.c
@@ -118,7 +118,14 @@ static void clip_coefficients(DSPContext *dsp, int32_t 
*coef, unsigned int len)
  */
 static CoefType calc_cpl_coord(CoefSumType energy_ch, CoefSumType energy_cpl)
 {
-    return 1048576;
+    if (energy_cpl <= COEF_MAX) {
+        return 1048576;
+    } else {
+        uint64_t coord   = energy_ch / (energy_cpl >> 24);
+        uint32_t coord32 = FFMIN(coord, 1073741824);
+        coord32          = ff_sqrt(coord32) << 9;
+        return FFMIN(coord32, COEF_MAX);
+    }
 }
 
 
-- 
1.7.1

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to