#pragma once #import #include #include // Immutable renderer-owned snapshot. Channel 0 is Rec.709 luma of the existing // display-encoded analysis samples, not scene-linear luminance or an HDR scope. struct DYHistogram { uint32_t bins[4][256]{}; uint32_t samples=0; }; static inline NSData *DYHistogramFromRGBA(NSData *rgba) { DYHistogram h; if(rgba.length%sizeof(float[4]))return nil; const float *p=(const float *)rgba.bytes; auto bin=[](double v){return (int)std::lround(std::fmax(0.,std::fmin(1.,v))*255.);}; for(NSUInteger i=0;i