improve encode implement direct encode P13