Add primitive interning for YUV images. …
Also restructure and tidy up some of the code that handles segment building + interned primitives. This reduces some of the code duplication and will simplify porting the remaining primitives to interning.