]> granicus.if.org Git - libvpx/commitdiff
vp9_firstpass: Get rid of magic number in bits per MB calculation
authorGuillaume Martres <smarter3@gmail.com>
Sat, 5 Apr 2014 19:57:14 +0000 (21:57 +0200)
committerGuillaume Martres <smarter3@gmail.com>
Mon, 7 Apr 2014 16:21:40 +0000 (18:21 +0200)
Change-Id: Ib3886cb7cafc211581f4f9e7f76782d9d1984434

vp9/encoder/vp9_firstpass.c
vp9/encoder/vp9_ratectrl.c
vp9/encoder/vp9_ratectrl.h

index 26fc2800456e4a62306e02b5d36518607925fa6f..f4ec7cb65526a0a7623ddd14e5d4ef55c0a7a0e1 100644 (file)
@@ -916,9 +916,10 @@ int vp9_twopass_worst_quality(VP9_COMP *cpi, FIRSTPASS_STATS *fpstats,
   if (section_target_bandwitdh <= 0)
     return rc->worst_quality;          // Highest value allowed
 
-  target_norm_bits_per_mb = section_target_bandwitdh < (1 << 20)
-                              ? (512 * section_target_bandwitdh) / num_mbs
-                              : 512 * (section_target_bandwitdh / num_mbs);
+  target_norm_bits_per_mb =
+      section_target_bandwitdh < (1 << 20)
+      ? (section_target_bandwitdh << BPER_MB_NORMBITS) / num_mbs
+      : (section_target_bandwitdh / num_mbs) << BPER_MB_NORMBITS;
 
   // Try and pick a max Q that will be high enough to encode the
   // content at the given rate.
index eb4db1a33345a2a3463437bcdafd568d14f15b38..86de99ede92c079eaac0dbc5b451ceb798eaf147 100644 (file)
@@ -35,9 +35,6 @@
 #define MIN_BPB_FACTOR 0.005
 #define MAX_BPB_FACTOR 50
 
-// Bits Per MB at different Q (Multiplied by 512)
-#define BPER_MB_NORMBITS    9
-
 // Tables relating active max Q to active min Q
 static int kf_low_motion_minq[QINDEX_RANGE];
 static int kf_high_motion_minq[QINDEX_RANGE];
index f2d128c2d205620a7baa20538029c66325d86f2c..1d8ba66926049402a2a05bba9e38792be71a2dde 100644 (file)
@@ -22,6 +22,9 @@ extern "C" {
 
 #define FRAME_OVERHEAD_BITS 200
 
+// Bits Per MB at different Q (Multiplied by 512)
+#define BPER_MB_NORMBITS    9
+
 typedef struct {
   // Rate targetting variables
   int this_frame_target;