h264: use templates to avoid excessive inlining