avcodec/options: factorize avcodec_copy_context() cleanup code