Fix incorrect comparison of frame size
authorJohn Koleszar <jkoleszar@google.com>
Thu, 28 Feb 2013 18:52:04 +0000 (10:52 -0800)
committerJohn Koleszar <jkoleszar@google.com>
Thu, 28 Feb 2013 19:33:02 +0000 (11:33 -0800)
The width and height stored in the reference frames are padded out to
a multiple of 16. The Width and Height variables in common are the
displayed size, which may be smaller. The incorrect comparison was
causing scaling related code to be called when it shouldn't have
been. A notable case where this happens is 1080p, since 1088 != 1080.

Change-Id: I55f743eeeeaefbf2e777e193bc9a77ff726e16b5

vp9/encoder/vp9_onyx_if.c

index ab3d199..b9d3049 100644 (file)
@@ -2598,7 +2598,7 @@ static void scale_references(VP9_COMP *cpi) {
   for (i = 0; i < 3; i++) {
     YV12_BUFFER_CONFIG *ref = &cm->yv12_fb[cm->ref_frame_map[i]];
 
-    if (ref->y_width != cm->Width || ref->y_height != cm->Height) {
+    if (ref->y_width != cm->mb_cols * 16 || ref->y_height != cm->mb_rows * 16) {
       int new_fb = get_free_fb(cm);
 
       vp8_yv12_realloc_frame_buffer(&cm->yv12_fb[new_fb],
@@ -2672,8 +2672,8 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
   int64_t mcomp_filter_cost[4];
 
   /* Scale the source buffer, if required */
-  if (cm->Width != cpi->un_scaled_source->y_width ||
-      cm->Height != cpi->un_scaled_source->y_height) {
+  if (cm->mb_cols * 16 != cpi->un_scaled_source->y_width ||
+      cm->mb_rows * 16 != cpi->un_scaled_source->y_height) {
     scale_and_extend_frame(cpi->un_scaled_source, &cpi->scaled_source);
     cpi->Source = &cpi->scaled_source;
   } else {