Fix line-break handling in SRT codec

Also some style and efficiency improvements in SRT and VTT codecs.