aom: Optimize av1_ceil_log2

From 732e09205efb2fd7e8e60418b8de5f9144cea520 Mon Sep 17 00:00:00 2001
From: Wan-Teh Chang <[EMAIL REDACTED]>
Date: Fri, 31 Mar 2023 20:17:20 -0700
Subject: [PATCH] Optimize av1_ceil_log2

Change-Id: Iac52774a520113eb3ba6f612123461a39ec6022c
---
 av1/common/entropymode.h | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/av1/common/entropymode.h b/av1/common/entropymode.h
index 09cd6bd1e9..028bd21ae3 100644
--- a/av1/common/entropymode.h
+++ b/av1/common/entropymode.h
@@ -12,6 +12,7 @@
 #ifndef AOM_AV1_COMMON_ENTROPYMODE_H_
 #define AOM_AV1_COMMON_ENTROPYMODE_H_
 
+#include "aom_ports/bitops.h"
 #include "av1/common/entropy.h"
 #include "av1/common/entropymv.h"
 #include "av1/common/filter.h"
@@ -192,13 +193,7 @@ void av1_setup_past_independence(struct AV1Common *cm);
 // Returns (int)ceil(log2(n)).
 static INLINE int av1_ceil_log2(int n) {
   if (n < 2) return 0;
-  int i = 1;
-  unsigned int p = 2;
-  while (p < (unsigned int)n) {
-    i++;
-    p = p << 1;
-  }
-  return i;
+  return get_msb(n - 1) + 1;
 }
 
 // Returns the context for palette color index at row 'r' and column 'c',