Backport of "avaudenc/avvidenc: Reopen encoding session if it's required" into 1.18
Backport of !99 (merged) "avaudenc/avvidenc: Reopen encoding session if it's required".
Commits:
- 89bb244a avaudenc/avvidenc: Reopen encoding session if it's required