My S5 has been having this problem for months. The biggest issue for me is that it often takes a VERY long time to wake it from sleep. Sometimes it took as long as 10-minutes of repeatedly pressing the power button before the screen would stay lit.
I took it into the store to get it handled this weekend, and they wiped the memory, resetting to factory specs. Everything seemed fine for a few hours, but soon the trouble started back up. I went back in to get it fixed right, and he sentered me away saying it's probably a hardware issue and tried to get me to buy a new phone, but not before he fooled me into wiping the memory again. It was working fine for a little while again, until the auto updates had enough time to reintroduce the problem.
I've tried every solution I've seen, including the developer mode trick, turning off auto brightness, installing the screen filter app, pulling out the SD card (this at least lead to the flickering not happening when the screen dimmed before going to sleep), and a few of the more obscure suggestions. Nothing seems to work.
I am starting to believe that temperature is at least partially to blame for the problems. They have gotten worse recently, just as the weather has gotten colder and I turned down the temp in my house. Yet it seems to respond faster if it has been staying warm in my pocket. I'm going to test this theory and try to determine if it holds any weight.