Viacom Inc’s Paramount Pictures has reached a deal for a $1 billion cash investment from two Chinese film companies, Shanghai Film Group and Huahua Media, the companies said on Thursday.

As part of the agreement, Shanghai Film Group and Huahua Media will finance a combined 25 percent of all Paramount’s films for the next three years, with the option to extend it, according to a source familiar with the situation.

The deal will give Paramount, which has been struggling to turn itself around, stability and resources without giving up control of the studio. It also marks the first major move by Paramount head Brad Grey since Viacom’s former CEO, Philippe Dauman, tried to sell a stake in the movie studio to Chinese real estate conglomerate Dalian Wanda Group.

Dauman left Viacom in August after losing a battle for the company to controlling shareholders Shari and Sumner Redstone. He has been replaced by Bob Bakish, who previously ran Viacom’s international business.

Grey went to China in November to meet with Shanghai Film Group and Huahua Media, the source said. The deal was signed on Dec. 31, said the source, who wished to remain anonymous because he is not permitted to speak publicly about the deal.

Grey was not immediately available for comment.

Huahua has partnered with Paramount on several films, including “Transformers: the Age of Extinction” and “Star Trek Beyond”. Shanghai Film Group, which is one of the largest theater chains in China, was an investor in “Jack Reacher: Never Go Back”.

Viacom shares moved higher in afternoon trading but pared gains to close at $39.80.