The `encoder` is actually persistent and only freed when the output is freed, so testing for its existence is not enough to determine whether the output is open. The `fmtctx` can be used for that. Change-Id: I2cc3f00a0e983fafd5915736089a0421385b6ce3 (cherry picked from commitmr10.5.4833c30d69e) (cherry picked from commit22a949aa60)