I need to use 1000 pulse encoder.
You are using an algorithm which only reads 1/4 of the possible quadrature changes. Do you need the 1000 ppr model, or can you just read more available quadrature states from the 500 ppr model?
You can/will damage the Arduino when applying more than 5.5v to a digital input pin. The totem pole output on your encoder is putting out the encoder supply voltage (12-24 vdc) for a HIGH.
You are going to need a voltage divider or an optocoupler on the outputs.