fix: bound vector-scope coordinates before rounding extreme samples
这个提交包含在:
1 父节点
ded1f22be8
当前提交
0ef847f6bb
2 个文件已更改
+2
-1
没有与搜索条件相匹配的文件
@@ -11,5 +11,6 @@ int main(){
|
||||
RGBA colors[]={{.5f,.5f,.5f,1},{1,0,0,1},{1,0,1,1},{0,0,1,1},{0,1,1,1},{0,1,0,1},{1,1,0,1},{2,2,2,0},{INFINITY,0,0,1}};
|
||||
auto v=measure(colors,9,1);uint64_t total=0;for(auto n:v.vectors)total+=n;assert(total==7&&v.transparent==1&&v.nonfinite==1);assert(v.vectors[(Bins-1-chromaBin(0))*Bins+chromaBin(0)]==1);
|
||||
for(unsigned i=1;i<7;i++){auto p=colors[i];float y=.2126f*p.r+.7152f*p.g+.0722f*p.b;unsigned x=chromaBin((p.b-y)/1.8556f),row=Bins-1-chromaBin((p.r-y)/1.5748f);assert(v.vectors[row*Bins+x]==1);}
|
||||
assert(chromaBin(INFINITY)==Bins-1&&chromaBin(-INFINITY)==0&&chromaBin(std::numeric_limits<float>::max())==Bins-1&&chromaBin(-std::numeric_limits<float>::max())==0);
|
||||
auto vector=vectorImage(v.vectors);assert(vector.size()==Bins*Bins*4);assert(vectorImage({}).empty());for(size_t i=0;i<vector.size()/4;i++)assert(vector[4*i+3]==255);return 0;
|
||||
}
|
||||
@@ -21,7 +21,7 @@ struct Result {
|
||||
inline unsigned bin(float v){if(!(v>Low))return 0;if(v>=High)return Bins-1;return unsigned(std::clamp(std::lround((v-Low)/(High-Low)*(Bins-1)),0l,long(Bins-1)));}
|
||||
// BT.709 colour-difference coordinates on the same encoded display-reference
|
||||
// RGB used by the existing scopes (ITU-R BT.709-6 section 3.3). Not an IRE meter.
|
||||
inline unsigned chromaBin(float v){return unsigned(std::clamp(std::lround((v+.6f)/1.2f*(Bins-1)),0l,long(Bins-1)));}
|
||||
inline unsigned chromaBin(float v){if(!(v>-.6f))return 0;if(v>=.6f)return Bins-1;return unsigned(std::clamp(std::lround((v+.6f)/1.2f*(Bins-1)),0l,long(Bins-1)));}
|
||||
inline Result measure(std::span<const RGBA> pixels,unsigned width=Width,unsigned height=Height){
|
||||
Result r;if(!width||!height||pixels.size()!=size_t(width)*height)return r;bool first=true;
|
||||
for(unsigned y=0;y<height;y++)for(unsigned x=0;x<width;x++){
|
||||
|
||||
在新工单中引用
屏蔽一个用户