MCPcopy Create free account
hub / github.com/OpenDriveLab/OpenLane / rleMerge

Function rleMerge

eval/CIPO_evaluation/common/maskApi.c:66–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66void rleMerge( const RLE *R, RLE *M, siz n, int intersect ) {
67 uint *cnts, c, ca, cb, cc, ct; int v, va, vb, vp;
68 siz i, a, b, h=R[0].h, w=R[0].w, m=R[0].m; RLE A, B;
69 if(n==0) { rleInit(M,0,0,0,0); return; }
70 if(n==1) { rleInit(M,h,w,m,R[0].cnts); return; }
71 cnts = malloc(sizeof(uint)*(h*w+1));
72 for( a=0; a<m; a++ ) cnts[a]=R[0].cnts[a];
73 for( i=1; i<n; i++ ) {
74 B=R[i]; if(B.h!=h||B.w!=w) { h=w=m=0; break; }
75 rleInit(&A,h,w,m,cnts); ca=A.cnts[0]; cb=B.cnts[0];
76 v=va=vb=0; m=0; a=b=1; cc=0; ct=1;
77 while( ct>0 ) {
78 c=umin(ca,cb); cc+=c; ct=0;
79 ca-=c; if(!ca && a<A.m) { ca=A.cnts[a++]; va=!va; } ct+=ca;
80 cb-=c; if(!cb && b<B.m) { cb=B.cnts[b++]; vb=!vb; } ct+=cb;
81 vp=v; if(intersect) v=va&&vb; else v=va||vb;
82 if( v!=vp||ct==0 ) { cnts[m++]=cc; cc=0; }
83 }
84 rleFree(&A);
85 }
86 rleInit(M,h,w,m,cnts); free(cnts);
87}
88
89void rleArea( const RLE *R, siz n, uint *a ) {
90 siz i, j; for( i=0; i<n; i++ ) {

Callers 1

Calls 3

rleInitFunction · 0.85
uminFunction · 0.85
rleFreeFunction · 0.85

Tested by

no test coverage detected