Skip to content

Commit

Permalink
exclude black frame from pixel sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
eyaler committed Jul 2, 2024
1 parent b04bdbd commit 50bd591
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,22 @@ const effect_funcs = {
for (let y = 0; y < H; y++) {
const yUV = (y >> 1) * stride
const line = []
let start
let end
for (let x = 0; x < W; x++) {
const xUV = x >> 1
const Y = yuv[x + y*W]
const U = yuv[Voffset + xUV + yUV]
const V = yuv[Uoffset + xUV + yUV]
line.push({Y, U, V})
if (Y != 16 || U != 128 || V != 128) {
start ??= x
end = x
}
}
line.sort((a, b) => (a.Y - b.Y))
const part = line.splice(start, end - start + 1)
part.sort((a, b) => (a.Y - b.Y))
line.splice(start, 0, ...part)
for (let x = 0; x < W; x++) {
const {Y, U, V} = line[x]
const offset4 = (x+y*W) * 4
Expand Down

0 comments on commit 50bd591

Please sign in to comment.