Merge "Make encoder and decoder share common thread function"