First thing I'd try is to use a wire brush on say a drill and try to clean up the threads...they have a lot of gunk on them. The whole stub would need t obe cleaned off if you go with a banded coupling (this is a neoprene rubber sleeve with a metal jacket on it and clamps to hold it to the pipe and seal - don't use the all rubber one with clamps). Then, see if the adapter will thread on. If it won't, you have enough stub sticking out to cut off the threads and use a banded coupling to a stub of pvc that you would then glue the trap adapter onto. If the start of the threads is munged up, you might take a triangle file and clean it up some that way (if you had a die, you could run that down it, but most people won't have one of those lying around!). You'd likely need a 24" or larger pipe wrench to undo that stub from the coupling in the wall, and then, if it isn't anchored well, maybe stress nearby ones, or what's there might drop a little, making it really tough to install the new piece since it would no longer line up.