Tuning mediaformatshaper

-- allow per-resolution QPmax setting
-- additional tuning for Android 12 release

Bug: 183211971
Test: videoquality tests
Change-Id: I763c7f56016ab335b4f73fde1eda410991a8c7b5
diff --git a/media/libmediaformatshaper/CodecProperties.h b/media/libmediaformatshaper/CodecProperties.h
index 98ab99e..196a40f 100644
--- a/media/libmediaformatshaper/CodecProperties.h
+++ b/media/libmediaformatshaper/CodecProperties.h
@@ -69,7 +69,7 @@
     // qp max bound used to compensate when SupportedMinimumQuality == 0
     // 0 == let a system default handle it
     void setTargetQpMax(int qpmax);
-    int targetQpMax();
+    int targetQpMax(int32_t width, int32_t height);
 
     // target bits-per-pixel (per second) for encoding operations.
     // This is used to calculate a minimum bitrate for any particular resolution.
@@ -123,6 +123,19 @@
     struct bpp_point *mBppPoints = nullptr;
     bool bppPoint(std::string resolution, std::string value);
 
+    // same thing for qpmax -- allow different ones based on resolution
+    // allow different target bits-per-pixel based on resolution
+    // similar to codec 'performance points'
+    // uses 'next largest' (by pixel count) point as minimum bpp
+    struct qpmax_point {
+        struct qpmax_point *next;
+        int32_t pixels;
+        int32_t width, height;
+        int qpMax;
+    };
+    struct qpmax_point *mQpMaxPoints = nullptr;
+    bool qpMaxPoint(std::string resolution, std::string value);
+
     std::mutex mMappingLock;
     // XXX figure out why I'm having problems getting compiler to like GUARDED_BY
     std::map<std::string, std::string> mMappings /*GUARDED_BY(mMappingLock)*/ ;