// Measure decoded length of a PackBits byte stream, checking run and literal boundaries. Header 128 is a no-op. pub fn packbits_extent(encoded: vector) -> i64 { let mut i = 0; let mut total = 0; while i255.0 || b%1.0 != 0.0 { return -1; } i += 1; if b<128.0 { let mut j = 0; while at([j],0)<=b { if i >= len(encoded) { return -1; } let v = at(encoded,i); if v<0.0 || v>255.0 || v%1.0 != 0.0 { return -1; } i += 1; j += 1; } total += j; } else { if b>128.0 { if i >= len(encoded) { return -1; } let v = at(encoded,i); if v<0.0 || v>255.0 || v%1.0 != 0.0 { return -1; } i += 1; let mut n = 0; while at([n],0)<257.0-b { n += 1; } total += n; } } } total }