Paying more $$$ in groceries? How restaurants gain
Paul . Richards | AFP | Getty Images

Due in part to a pig virus, historically small cattle herds and a Brazilian drought, grocery shoppers everywhere have been feeling pain at the checkout. But there could be a silver lining, at least for the restaurant industry, according to one firm.

The reason? When grocery prices rise faster than the cost of food elsewhere, restaurants typically benefit as their relative value improves modestly, according to Bernstein Research.

"When agricultural inflation is going up, it means costs in general are going to rise faster for the food-at-home sector than restaurants," said Alexia Howard, an analyst at Bernstein. "And that's going to disproportionately push input costs for food-at-home products higher and traffic up for the restaurant sector." Input costs are expenses for material and labor related to production of goods.

One of the most important drivers of choosing whether to cook at home or to dine out is this relative price of food at home vs. food away from home.

Read More Fast food jobs pay $20 here...voluntarily

For the year ended in May, prices of food away from home ticked up 2.2 percent while the grocery price metric of food at home rose 2.7 percent, according to the Consumer Price Index.

This is a reversal of prior trends for this metric. Grocery inflation had been lower for most of 2012 and all of 2013 before flipping in May.

Bernstein expects the trend to accelerate. The firm's analysts forecast food-at-home inflation will rise to about 3.5 percent through the back half of the year while food-away-from-home inflation ticks up to around 2.5 percent.

Since higher grocery prices lead to lower discretionary spending, Bernstein expects food-at-home inflation to be "more unambiguously positive for restaurants with more affluent customers like fast casuals" and specialty coffee chains, such as Chipotle (NYSE:CMG - News), Panera Bread (NASDAQ:PNRA - News) and Starbucks (NASDAQ:SBUX - News). Chains that specialize in high-inflationary products, like steak, are also set to benefit.

Complicating the situation, though, are input costs that aren't rising uniformly and the fierce competition among processed food makers that could result in additional promotions. Because of this, the impact for restaurants is "not as clear cut this time around," said another Bernstein analyst Sara Senatore.

RBC Capital Markets analyst David Palmer expects a modest acceleration in food-at-home inflation, which he views as a "modest positive for the fast food industry and a slight negative for casual dining," which has bigger input costs and less pricing power due to higher check averages.