IT IS TASK OF THE GATEWAY.
Codec conversion can be done only by Media Gateways.
There are atleast two gateways that I know and used that do this.
Mera and Sysmaster.
Normally softswitch vendors include a gateway module to take care of the protocol and codec conversion. For example, Nextone makes a softswitch, but it does not convert codecs.