Fix global-motion + error-resilient-mode Patch https://aomedia-review.googlesource.com/c/21783 changed things so that error-resilient frames use the default global motion parameters as a reference, rather than taking the reference from the previous frame. This was implemented by clearing out cm->prev_frame->global_motion when we have an error-resilient frame. Unfortunately, this causes an issue: if we have an error resilient frame which isn't stored into any reference slots, followed by a non-error-resilient frame, then both frames refer to the same prev_frame. The second frame then delta-codes against cm->prev_frame->global_motion, but this was reset to the default values by the intervening error-resilient frame! In order to allow the above case to work as intended, expand the default warp parameter set to a full WarpedMotionParams struct, and use that as the reference for error-resilient frames. This also allows us to remove set_default_warp_params, as we can now just copy directly from default_warp_params. Change-Id: I9645615db2700c1d3810e6e42f4f1da626fcd5e3
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c index 6107b2f..a363352 100644 --- a/av1/decoder/decodeframe.c +++ b/av1/decoder/decodeframe.c
@@ -4480,7 +4480,7 @@ #if CONFIG_GLOBAL_MOTION static int read_global_motion_params(WarpedMotionParams *params, - WarpedMotionParams *ref_params, + const WarpedMotionParams *ref_params, struct aom_read_bit_buffer *rb, int allow_hp) { TransformationType type = aom_rb_read_bit(rb); @@ -4498,7 +4498,7 @@ int trans_bits; int trans_dec_factor; int trans_prec_diff; - set_default_warp_params(params); + *params = default_warp_params; params->wmtype = type; switch (type) { case HOMOGRAPHY: @@ -4577,11 +4577,11 @@ static void read_global_motion(AV1_COMMON *cm, struct aom_read_bit_buffer *rb) { int frame; for (frame = LAST_FRAME; frame <= ALTREF_FRAME; ++frame) { - if (cm->error_resilient_mode) - set_default_warp_params(&cm->prev_frame->global_motion[frame]); + const WarpedMotionParams *ref_params = + cm->error_resilient_mode ? &default_warp_params + : &cm->prev_frame->global_motion[frame]; int good_params = read_global_motion_params( - &cm->global_motion[frame], &cm->prev_frame->global_motion[frame], rb, - cm->allow_high_precision_mv); + &cm->global_motion[frame], ref_params, rb, cm->allow_high_precision_mv); if (!good_params) aom_internal_error(&cm->error, AOM_CODEC_CORRUPT_FRAME, "Invalid shear parameters for global motion."); @@ -4597,7 +4597,7 @@ &cm->prev_frame->global_motion[frame], rb, cm->allow_high_precision_mv); } else { - set_default_warp_params(&cm->global_motion[frame]); + cm->global_motion[frame] = default_warp_params; } */ /* @@ -5456,8 +5456,8 @@ #if CONFIG_GLOBAL_MOTION int i; for (i = LAST_FRAME; i <= ALTREF_FRAME; ++i) { - set_default_warp_params(&cm->global_motion[i]); - set_default_warp_params(&cm->cur_frame->global_motion[i]); + cm->global_motion[i] = default_warp_params; + cm->cur_frame->global_motion[i] = default_warp_params; } xd->global_motion = cm->global_motion; #endif // CONFIG_GLOBAL_MOTION