Eliminate a race condition with input thread.
Eliminate a race condition with input thread.

Changes communication between the input thread and main thread in
encmain.c so that only one of them uses img_in and retval at a time.
Fixes a race condition which would sometimes result in a deadlock.

ultravideo/kvazaar,ultravideo/kvazaar,ultravideo/kvazaar,ultravideo/kvazaar,ultravideo/kvazaar