An extended membrane system with a dynamic nested membrane structure, which is integrated with the evolution-communication mechanism of a cell-like P system with evolutional symport/antiport rules and active membranes (ECP), and the evolutionary mechanisms of particle swarm optimization (PSO) and improved PSO inspired by starling flock behavior (SPSO), named DSPSO-ECP, is designed and developed to try to break application restrictions of P systems in this paper. The purpose of DSPSO-ECP is to enhance the performance of extended membrane system in solving optimization problems. In the proposed DSPSO-ECP, the updated model of velocity and position of standard PSO, as basic evolution rules, are adopted to evolve objects in elementary membranes. The modified updated model of the velocity of improved SPSO is used as local evolution rules to evolve objects in sub-membranes. A group of sub-membranes for elementary membranes are specially designed to avoid prematurity through membrane creation and dissolution rules with promoter/inhibitor. The exchange and sharing of information between different membranes are achieved by communication rules for objects based on evolutional symport rules of ECP. At last, computational results, which are made on numerical benchmark functions and classic test images, are discussed and analyzed to validate the efficiency of the proposed DSPSO-ECP.