Meier cut it to 3-2 at 17:30 of the second period with a spinning shot from the goal line.
Barabanov tied it 3-3 at 11:07 of the third period when he scored from the edge of the crease, and Couture put the Sharks up 4-3 at 11:35 when his shot bounced off Markstrom's left pad before trickling over the goal line.
"I just thought that we did a pretty terrible job in front of 'Marky' tonight, especially in the third," Calgary forward Matthew Tkachuk said. "We're up 3-2 going into the third at home, that's a great spot to be in. And then we allow a wide-open chance in front, somebody by himself, and you can't do that. You've got to make sure that doesn't happen. And then basically a 2-on-0 at the end. That's a goal on any goalie in the league. No excuse. He's been our MVP this year, and we did a terrible job, especially in the third, in front of him."
Reimer made a glove save on Gaudreau's penalty shot at 14:59 of the second period with the Flames up 3-1.
"That was a big turning point in the game," San Jose coach Bob Boughner said. "That's 4-1. It gave us a chance to come back and score that second goal and make it a one-goal game. 'Reims,' he made a couple of those saves tonight for us, especially at the end. He came up big and he's been solid for us all year. I thought he was our first star tonight."
Reimer also made a sprawling left-pad save on Tkachuk with 38 seconds remaining in the third period, and another save on Andrew Mangiapane in close with 21 seconds left.
"It took us a while to get going but once we did I thought we played a pretty responsible game," Boughner said. "That's a great team offensively, obviously. 'Reims' came up huge at the end with some stops. Coming into this building after a trade deadline, having guys injured and out of the lineup...I thought it was a great team effort."