Minecraft wiki entry for Before_1.8, associated text: For each enchantment on the sacrifice:
If the enchantment is incompatible with the target, add 1 per level of enchantment.
If the enchantment is compatible, for each level the target will gain, add twice the cost-per-level from the Base Value tables.
If the enchantment is compatible, but both target and sacrifice are at max level, add the cost-per-level once.
If new enchantments are added, add (number of new enchantments)×(number of final enchantments - 1) + 1.