decord/source/5399_binarySearchVisibleIndex.js

54 lines
1.4 KiB
JavaScript
Raw Normal View History

2026-07-23 10:11:24 +00:00
// Module ID: 5399
2026-07-24 07:16:23 +00:00
// Function ID: 46267
2026-07-20 16:05:17 +00:00
// Name: binarySearchVisibleIndex
// Dependencies: []
2026-07-23 10:11:24 +00:00
// Module 5399 (binarySearchVisibleIndex)
2026-07-20 16:05:17 +00:00
function binarySearchVisibleIndex(layouts, bound1, horizontal, arg3) {
let diff1;
let sum;
let diff = layouts.length - 1;
let num = -1;
let num2 = -1;
let num3 = 0;
if (0 <= diff) {
do {
let _Math = Math;
let rounded = Math.floor((num3 + diff) / 2);
let size = layouts[rounded];
let tmp3 = horizontal ? size.x : size.y;
if (arg3) {
if (tmp3 < bound1) {
2026-07-23 10:11:24 +00:00
if (tmp3 + (horizontal ? size.width : size.height) <= bound1) {
2026-07-20 16:05:17 +00:00
sum = rounded + 1;
diff1 = diff;
let tmp6 = num;
}
}
diff1 = rounded - 1;
sum = num3;
tmp6 = rounded;
} else if (tmp3 <= bound1) {
sum = rounded + 1;
diff1 = diff;
tmp6 = rounded;
} else {
diff1 = rounded - 1;
sum = num3;
tmp6 = num;
}
num3 = sum;
diff = diff1;
num = tmp6;
num2 = tmp6;
} while (sum <= diff1);
}
return num2;
}
arg5.findFirstVisibleIndex = function findFirstVisibleIndex(layouts, bound1, horizontal) {
return binarySearchVisibleIndex(layouts, bound1, horizontal, true);
};
arg5.findLastVisibleIndex = function findLastVisibleIndex(layouts, bound1, horizontal) {
return binarySearchVisibleIndex(layouts, bound1, horizontal, false);
};