x265enc: Enhance profile setting with fixing infinite loop condition
x265enc: Enhance profile setting with fixing infinite loop condition
Don't fixate profile caps which will choose the first profile from list.
Instead, store all profiles allowed by peer and try them until x265 can
accept one of them.
x265enc: Fix deadlock on profile setting failure
Don't miss unlock before returning