QSV: move some QSV-specific code to decicated util files (qsv_common.h, .c).