enc_qsv: cleanup encoding loop, part 3.

Move encoding loop to its own function and simplify encqsvWork.