Added rate cost to SAO mode selection calculations

Decreased BD-rate 1% on LP configuration with 600 frames of BQMall, QP 22,27,32,37
Merge check is now performed in a function to ease the checking