]> granicus.if.org Git - libvpx/commitdiff
fix uninitialized value in multi-res encoding
authorJohn Koleszar <jkoleszar@google.com>
Wed, 3 Oct 2012 21:52:56 +0000 (14:52 -0700)
committerJohn Koleszar <jkoleszar@google.com>
Wed, 3 Oct 2012 21:53:05 +0000 (14:53 -0700)
If a parent mb is available but is intra coded, then parent_ref_mv is
invalid. Check that the parent is inter coded before trying to access
the parent_ref_mv. Previously the parent_ref_mv was being read from
an uninitialized stack allocation, causing potential OOB reads and
other undefined behavior.

Change-Id: I0c93cd412a19c3a184bcf6decaa145b3a036a6c0

vp8/encoder/pickinter.c

index 3cad8bfd9a277cbc4d26605ddb18252c24a7c44d..6050d15fda8dd27ea0c6a1595ec674ab910fb9b5 100644 (file)
@@ -865,7 +865,8 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
             if (cpi->oxcf.mr_encoder_id && !cpi->mr_low_res_mv_avail)
                 cpi->sf.improved_mv_pred = 0;
 
-            if (cpi->oxcf.mr_encoder_id && cpi->mr_low_res_mv_avail)
+            if (cpi->oxcf.mr_encoder_id && cpi->mr_low_res_mv_avail
+                && parent_ref_frame)
             {
                 /* Use parent MV as predictor. Adjust search range
                  * accordingly.
@@ -911,6 +912,7 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
 #if CONFIG_MULTI_RES_ENCODING
             if (cpi->oxcf.mr_encoder_id && cpi->mr_low_res_mv_avail &&
                 dissim <= 2 &&
+                parent_ref_frame &&
                 MAX(abs(best_ref_mv.as_mv.row - parent_ref_mv.as_mv.row),
                     abs(best_ref_mv.as_mv.col - parent_ref_mv.as_mv.col)) <= 4)
             {