Move filter_ref initialization

To outside the loop to avoid repeating the operations.

Change-Id: I66c1986e98ce0d7594caad3d3b45de655b299bff
Merge "Move filter_ref initialization"