video_VDA: disable ForceBitrate for 320x180 video on elm/hana

BUG=chromium:728906
TEST=manual test

Change-Id: I7c23980dae6ce529b906a7877c23c011108abccd
Reviewed-on: https://chromium-review.googlesource.com/522307
Commit-Ready: Pin-chih Lin <johnylin@chromium.org>
Tested-by: Pin-chih Lin <johnylin@chromium.org>
Reviewed-by: Kuang-che Wu <kcwu@chromium.org>
(cherry picked from commit ffd002943b1d7632b9931a27bffc4cab753d6762)
Reviewed-on: https://chromium-review.googlesource.com/527856
Commit-Queue: Pin-chih Lin <johnylin@chromium.org>
Trybot-Ready: Pin-chih Lin <johnylin@chromium.org>
diff --git a/client/site_tests/video_VideoEncodeAccelerator/video_VideoEncodeAccelerator.py b/client/site_tests/video_VideoEncodeAccelerator/video_VideoEncodeAccelerator.py
index 9a6a164..e981f5c 100644
--- a/client/site_tests/video_VideoEncodeAccelerator/video_VideoEncodeAccelerator.py
+++ b/client/site_tests/video_VideoEncodeAccelerator/video_VideoEncodeAccelerator.py
@@ -45,49 +45,60 @@
 
     version = 1
 
-    def get_filter_option(self, profile):
-        """Get option of filtering test
+    def get_filter_option(self, profile, size):
+        """Get option of filtering test.
+
+        @param profile: The profile to encode into.
+        @param size: The size of test stream in pair format (width, height).
         """
 
         # Profiles used in blacklist to filter test for specific profiles.
-        # Use FILTER_ALL for filtering all profiles.
-        FILTER_ALL = 0
-        FILTER_H264 = 1
-        FILTER_VP8 = 11
-        FILTER_VP9 = 12
+        H264 = 1
+        VP8 = 11
+        VP9 = 12
 
         blacklist = {
-                # (board, profile): [tests to skip...]
+                # (board, profile, size): [tests to skip...]
 
                 # "board" supports Unix shell-type wildcards.
 
-                # It is possible to match multiple keys for board/profile in the
-                # blacklist, e.g. veyron_minnie could match both "veyron_*" and
-                # "veyron_minnie".
+                # Use None for "profile" or "size" to indicate no filter on it.
+
+                # It is possible to match multiple keys for board/profile/size
+                # in the blacklist, e.g. veyron_minnie could match both
+                # "veyron_*" and "veyron_minnie".
 
                 # rk3399 doesn't support HW encode for plane sizes not multiple
                 # of cache line.
-                ('kevin', FILTER_ALL): ['CacheLineUnalignedInputTest/*'],
-                ('bob', FILTER_ALL): ['CacheLineUnalignedInputTest/*'],
+                ('kevin', None, None): ['CacheLineUnalignedInputTest/*'],
+                ('bob', None, None): ['CacheLineUnalignedInputTest/*'],
 
                 # Still high failure rate of VP8 EncoderPerf for veyrons,
                 # disable it for now. crbug/720386
-                ('veyron_*', FILTER_VP8): ['EncoderPerf/*'],
+                ('veyron_*', VP8, None): ['EncoderPerf/*'],
 
                 # Disable mid_stream_bitrate_switch test cases for elm/hana.
                 # crbug/725087
-                ('elm', FILTER_ALL): ['MidStreamParamSwitchBitrate/*',
+                ('elm', None, None): ['MidStreamParamSwitchBitrate/*',
                                       'MultipleEncoders/*'],
-                ('hana', FILTER_ALL): ['MidStreamParamSwitchBitrate/*',
+                ('hana', None, None): ['MidStreamParamSwitchBitrate/*',
                                        'MultipleEncoders/*'],
+
+                # Around 40% failure on elm and hana 320x180 test stream.
+                # crbug/728906
+                ('elm', H264, (320, 180)): ['ForceBitrate/*'],
+                ('elm', VP8, (320, 180)): ['ForceBitrate/*'],
+                ('hana', H264, (320, 180)): ['ForceBitrate/*'],
+                ('hana', VP8, (320, 180)): ['ForceBitrate/*'],
                 }
 
         board = utils.get_current_board()
 
         filter_list = []
-        for (board_key, profile_key), value in blacklist.items():
+        for (board_key, profile_key, size_key), value in blacklist.items():
             if (fnmatch.fnmatch(board, board_key) and
-                (profile_key == FILTER_ALL or profile == profile_key)):
+                (profile_key is None or profile == profile_key) and
+                (size_key is None or size == size_key)):
                 filter_list += value
 
         if filter_list:
@@ -126,7 +137,7 @@
             cmd_line_list.append('--ozone-platform=gbm')
 
             # Command line |gtest_filter| can override get_filter_option().
-            predefined_filter = self.get_filter_option(profile)
+            predefined_filter = self.get_filter_option(profile, (width, height))
             if gtest_filter and predefined_filter:
                 logging.warning('predefined gtest filter is suppressed: %s',
                     predefined_filter)