]> granicus.if.org Git - libvpx/commitdiff
Resolves some static analysis / undefined warnings
authorDeb Mukherjee <debargha@google.com>
Mon, 6 Oct 2014 21:30:01 +0000 (14:30 -0700)
committerDeb Mukherjee <debargha@google.com>
Tue, 7 Oct 2014 18:20:56 +0000 (11:20 -0700)
Also fixes a case of distortion becoming negative and messing
up the RDCOST computation.

Change-Id: Id345af9e8dfff31ade622be5756e51f2cdface53

vp9/common/vp9_debugmodes.c
vp9/decoder/vp9_dthread.c
vp9/encoder/vp9_encoder.c
vp9/encoder/vp9_rdopt.c
vp9/encoder/vp9_temporal_filter.c

index 3f16841045e5858a84cc7d582631cfc14ca56cf1..d9dace6ac8af49510db89b15a0b80415d1acff3e 100644 (file)
@@ -27,7 +27,7 @@ static void print_mi_data(VP9_COMMON *cm, FILE *file, const char *descriptor,
   int mi_row, mi_col;
   int mi_index = 0;
   // TODO(hkuang): Fix this debug function.
-  MODE_INFO **mi = NULL;
+  MODE_INFO **mi = &cm->mi;
   int rows = cm->mi_rows;
   int cols = cm->mi_cols;
   char prefix = descriptor[0];
@@ -53,7 +53,7 @@ void vp9_print_modes_and_motion_vectors(VP9_COMMON *cm, const char *file) {
   int mi_index = 0;
   FILE *mvs = fopen(file, "a");
   // TODO(hkuang): Fix this debug function.
-  MODE_INFO **mi = NULL;
+  MODE_INFO **mi = &cm->mi;
   int rows = cm->mi_rows;
   int cols = cm->mi_cols;
 
index 62ea6c14d250c9ab38245d62b13159fdff91fa21..69e4fde85860a604b6bc2044f542d7bf58440098 100644 (file)
@@ -223,14 +223,18 @@ void vp9_loop_filter_alloc(VP9LfSync *lf_sync, VP9_COMMON *cm, int rows,
 
     CHECK_MEM_ERROR(cm, lf_sync->mutex_,
                     vpx_malloc(sizeof(*lf_sync->mutex_) * rows));
-    for (i = 0; i < rows; ++i) {
-      pthread_mutex_init(&lf_sync->mutex_[i], NULL);
+    if (lf_sync->mutex_) {
+      for (i = 0; i < rows; ++i) {
+        pthread_mutex_init(&lf_sync->mutex_[i], NULL);
+      }
     }
 
     CHECK_MEM_ERROR(cm, lf_sync->cond_,
                     vpx_malloc(sizeof(*lf_sync->cond_) * rows));
-    for (i = 0; i < rows; ++i) {
-      pthread_cond_init(&lf_sync->cond_[i], NULL);
+    if (lf_sync->cond_) {
+      for (i = 0; i < rows; ++i) {
+        pthread_cond_init(&lf_sync->cond_[i], NULL);
+      }
     }
   }
 #endif  // CONFIG_MULTITHREAD
index 822a45e5ea9eab0ede9fd7c591d4ccd34c201f89..dbc206ec4efb5c0230921cfd10bfd228a9742365 100644 (file)
@@ -1224,9 +1224,7 @@ void vp9_change_config(struct VP9_COMP *cpi, const VP9EncoderConfig *oxcf) {
 
   cpi->oxcf = *oxcf;
 #if CONFIG_VP9_HIGHBITDEPTH
-  if (cpi->oxcf.use_highbitdepth) {
-    cpi->mb.e_mbd.bd = (int)cm->bit_depth;
-  }
+  cpi->mb.e_mbd.bd = (int)cm->bit_depth;
 #endif  // CONFIG_VP9_HIGHBITDEPTH
 
   rc->baseline_gf_interval = DEFAULT_GF_INTERVAL;
index 20a4b70821f146e7bb1ec64e5e3a46ced6234a03..eacbbf7da6db35699a416a68ff8bce61defd0e61 100644 (file)
@@ -232,7 +232,7 @@ static void model_rd_for_sb(VP9_COMP *cpi, BLOCK_SIZE bsize,
     // Fast approximate the modelling function.
     if (cpi->oxcf.speed > 4) {
       int64_t rate;
-      int64_t square_error = sse;
+      const int64_t square_error = sum_sse;
       int quantizer = (pd->dequant[1] >> 3);
 #if CONFIG_VP9_HIGHBITDEPTH
       if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
@@ -497,7 +497,7 @@ static void block_rd_txfm(int plane, int block, BLOCK_SIZE plane_bsize,
         if (tx_size != TX_32X32)
           dc_correct >>= 2;
 
-        args->dist = args->sse - dc_correct;
+        args->dist = MAX(0, args->sse - dc_correct);
       }
     } else {
       // skip forward transform
@@ -2448,7 +2448,7 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
 #if CONFIG_VP9_HIGHBITDEPTH
   DECLARE_ALIGNED_ARRAY(16, uint16_t, tmp_buf16, MAX_MB_PLANE * 64 * 64);
   DECLARE_ALIGNED_ARRAY(16, uint8_t, tmp_buf8, MAX_MB_PLANE * 64 * 64);
-  uint8_t *tmp_buf = tmp_buf8;
+  uint8_t *tmp_buf;
 #else
   DECLARE_ALIGNED_ARRAY(16, uint8_t, tmp_buf, MAX_MB_PLANE * 64 * 64);
 #endif  // CONFIG_VP9_HIGHBITDEPTH
index eeb1ce9294e5e8db7cbb1e26107462f545924d76..2d594dd09b8c0b698f706707bbfd030cd95667e3 100644 (file)
@@ -676,61 +676,66 @@ void vp9_temporal_filter(VP9_COMP *cpi, int distance) {
     frames[frames_to_blur - 1 - frame] = &buf->img;
   }
 
-  // Setup scaling factors. Scaling on each of the arnr frames is not supported
-  if (is_two_pass_svc(cpi)) {
-    // In spatial svc the scaling factors might be less then 1/2. So we will use
-    // non-normative scaling.
-    int frame_used = 0;
+  if (frames_to_blur > 0) {
+    // Setup scaling factors. Scaling on each of the arnr frames is not
+    // supported.
+    if (is_two_pass_svc(cpi)) {
+      // In spatial svc the scaling factors might be less then 1/2.
+      // So we will use non-normative scaling.
+      int frame_used = 0;
 #if CONFIG_VP9_HIGHBITDEPTH
-    vp9_setup_scale_factors_for_frame(&sf,
-                                      get_frame_new_buffer(cm)->y_crop_width,
-                                      get_frame_new_buffer(cm)->y_crop_height,
-                                      get_frame_new_buffer(cm)->y_crop_width,
-                                      get_frame_new_buffer(cm)->y_crop_height,
-                                      cm->use_highbitdepth);
+      vp9_setup_scale_factors_for_frame(
+          &sf,
+          get_frame_new_buffer(cm)->y_crop_width,
+          get_frame_new_buffer(cm)->y_crop_height,
+          get_frame_new_buffer(cm)->y_crop_width,
+          get_frame_new_buffer(cm)->y_crop_height,
+          cm->use_highbitdepth);
 #else
-    vp9_setup_scale_factors_for_frame(&sf,
-                                      get_frame_new_buffer(cm)->y_crop_width,
-                                      get_frame_new_buffer(cm)->y_crop_height,
-                                      get_frame_new_buffer(cm)->y_crop_width,
-                                      get_frame_new_buffer(cm)->y_crop_height);
+      vp9_setup_scale_factors_for_frame(
+          &sf,
+          get_frame_new_buffer(cm)->y_crop_width,
+          get_frame_new_buffer(cm)->y_crop_height,
+          get_frame_new_buffer(cm)->y_crop_width,
+          get_frame_new_buffer(cm)->y_crop_height);
 #endif  // CONFIG_VP9_HIGHBITDEPTH
 
-    for (frame = 0; frame < frames_to_blur; ++frame) {
-      if (cm->mi_cols * MI_SIZE != frames[frame]->y_width ||
-          cm->mi_rows * MI_SIZE != frames[frame]->y_height) {
-        if (vp9_realloc_frame_buffer(&cpi->svc.scaled_frames[frame_used],
-                                     cm->width, cm->height,
-                                     cm->subsampling_x, cm->subsampling_y,
+      for (frame = 0; frame < frames_to_blur; ++frame) {
+        if (cm->mi_cols * MI_SIZE != frames[frame]->y_width ||
+            cm->mi_rows * MI_SIZE != frames[frame]->y_height) {
+          if (vp9_realloc_frame_buffer(&cpi->svc.scaled_frames[frame_used],
+                                       cm->width, cm->height,
+                                       cm->subsampling_x, cm->subsampling_y,
 #if CONFIG_VP9_HIGHBITDEPTH
-                                     cm->use_highbitdepth,
+                                       cm->use_highbitdepth,
 #endif
-                                     VP9_ENC_BORDER_IN_PIXELS, NULL, NULL,
-                                     NULL))
-          vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
-                             "Failed to reallocate alt_ref_buffer");
-
-        frames[frame] = vp9_scale_if_required(cm, frames[frame],
-                            &cpi->svc.scaled_frames[frame_used]);
-        ++frame_used;
+                                       VP9_ENC_BORDER_IN_PIXELS, NULL, NULL,
+                                       NULL)) {
+            vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
+                               "Failed to reallocate alt_ref_buffer");
+          }
+          frames[frame] = vp9_scale_if_required(
+              cm, frames[frame], &cpi->svc.scaled_frames[frame_used]);
+          ++frame_used;
+        }
       }
-    }
-  } else {
-    // ARF is produced at the native frame size and resized when coded.
+    } else {
+      // ARF is produced at the native frame size and resized when coded.
 #if CONFIG_VP9_HIGHBITDEPTH
-    vp9_setup_scale_factors_for_frame(&sf,
-                                      frames[0]->y_crop_width,
-                                      frames[0]->y_crop_height,
-                                      frames[0]->y_crop_width,
-                                      frames[0]->y_crop_height,
-                                      cm->use_highbitdepth);
+      vp9_setup_scale_factors_for_frame(&sf,
+                                        frames[0]->y_crop_width,
+                                        frames[0]->y_crop_height,
+                                        frames[0]->y_crop_width,
+                                        frames[0]->y_crop_height,
+                                        cm->use_highbitdepth);
 #else
-    vp9_setup_scale_factors_for_frame(&sf,
-                                      frames[0]->y_crop_width,
-                                      frames[0]->y_crop_height,
-                                      frames[0]->y_crop_width,
-                                      frames[0]->y_crop_height);
+      vp9_setup_scale_factors_for_frame(&sf,
+                                        frames[0]->y_crop_width,
+                                        frames[0]->y_crop_height,
+                                        frames[0]->y_crop_width,
+                                        frames[0]->y_crop_height);
 #endif  // CONFIG_VP9_HIGHBITDEPTH
+    }
   }
 
   temporal_filter_iterate_c(cpi, frames, frames_to_blur,