Merge "Prevent negative cost for highbitdepth"