encoding first pass - beginning of ch6sc2