vpx_codec_enc_config_default: rm unnecessary loop
authorJames Zern <jzern@google.com>
Sat, 14 Mar 2020 03:29:09 +0000 (20:29 -0700)
committerJames Zern <jzern@google.com>
Sat, 14 Mar 2020 03:35:32 +0000 (20:35 -0700)
quiets -Wunreachable-code-loop-increment, present since:
e57f388bc vpx_codec_enc_config_default: disable 'usage'

as g_usage was never supported for vp8/9 this was always a single
iteration. if additional usages are added in the future similar to av1
this can be restored.

Bug: b/150166387
Change-Id: Ic6f0985829e87694de8b5e0340cffa6c451ed1c2

configure
vpx/src/vpx_encoder.c

index 181e27b..f470cbe 100755 (executable)
--- a/configure
+++ b/configure
@@ -627,6 +627,7 @@ process_toolchain() {
         check_add_cflags -Wmissing-declarations
         check_add_cflags -Wmissing-prototypes
         check_add_cflags -Wuninitialized
+        check_add_cflags -Wunreachable-code-loop-increment
         check_add_cflags -Wunused
         check_add_cflags -Wextra
         # check_add_cflags also adds to cxxflags. gtest does not do well with
index 6272502..f636b54 100644 (file)
@@ -152,22 +152,15 @@ vpx_codec_err_t vpx_codec_enc_config_default(vpx_codec_iface_t *iface,
                                              vpx_codec_enc_cfg_t *cfg,
                                              unsigned int usage) {
   vpx_codec_err_t res;
-  vpx_codec_enc_cfg_map_t *map;
-  int i;
 
   if (!iface || !cfg || usage != 0)
     res = VPX_CODEC_INVALID_PARAM;
   else if (!(iface->caps & VPX_CODEC_CAP_ENCODER))
     res = VPX_CODEC_INCAPABLE;
   else {
-    res = VPX_CODEC_INVALID_PARAM;
-
-    for (i = 0; i < iface->enc.cfg_map_count; ++i) {
-      map = iface->enc.cfg_maps + i;
-      *cfg = map->cfg;
-      res = VPX_CODEC_OK;
-      break;
-    }
+    assert(iface->enc.cfg_map_count == 1);
+    *cfg = iface->enc.cfg_maps->cfg;
+    res = VPX_CODEC_OK;
   }
 
   return res;