Use the common function between encoder and decoder. Change-Id: I0a85ddc864db21971cd97ab811792f9bbc7e96bb