Fix error that mthresh and vthresh was not properly initialized

and allocate buffer in getframe to prevent from being written by more
than one thread