Probably a worn out mechanical rotary encoder. Once enough of the contact fingers wear away, they typically become so intermittent that the debouncing can no longer cope and the direction of movement can no longer be reliably determined. If it is a mechanical encoder, its not too far gone, and you can get the encoder open without FUBARing it, then a thorough cleanout, retensioning the contact fingers and applying a good quality contact lubricant may get a bit more life out of it.