pub(super) fn adam7_deinterlace(
    out: &mut [u8],
    inp: &[u8],
    w: u32,
    h: u32,
    bpp: u32,
) {
    let (passw, passh, _, _, passstart) = adam7_get_pass_values(w, h, bpp);
    if bpp >= 8 {
        for i in 0..7 {
            let bytewidth = bpp / 8;
            for y in 0..passh[i] {
                for x in 0..passw[i] {
                    let pixelinstart = (passstart[i]
                        + (y * passw[i] + x) * bytewidth)
                        as usize;
                    let bytewidth = bytewidth as usize;
                    let pixeloutstart = ((ADAM7_IY[i] + y * ADAM7_DY[i]) * w
                        + ADAM7_IX[i]
                        + x * ADAM7_DX[i])
                        as usize
                        * bytewidth;

                    out[pixeloutstart..(bytewidth + pixeloutstart)]
                        .clone_from_slice(
                            &inp[pixelinstart..(bytewidth + pixelinstart)],
                        )
                }
            }
        }
    } else {
        for i in 0..7 {
            let ilinebits = bpp * passw[i];
            let olinebits = bpp * w;
            for y in 0..passh[i] {
                for x in 0..passw[i] {
                    let mut ibp = ((8 * passstart[i])
                        + (y * ilinebits + x * bpp))
                        as usize;
                    let mut obp = ((ADAM7_IY[i] + y * ADAM7_DY[i]) * olinebits
                        + (ADAM7_IX[i] + x * ADAM7_DX[i]) * bpp)
                        as usize;
                    for _ in 0..bpp {
                        let bit = read_bit_from_reversed_stream(&mut ibp, inp);
                        /*note that this function assumes the out buffer is completely 0, use set_bit_of_reversed_stream otherwise*/
                        set_bit_of_reversed_stream0(&mut obp, out, bit);
                    }
                }
            }
        }
    };
}
/*
in: Adam7 interlaced image, with no padding bits between scanlines, but between
 reduced images so that each reduced image starts at a byte.
out: the same pixels, but re-ordered so that they're now a non-interlaced image with size w*h
bpp: bits per pixel
out has the following size in bits: w * h * bpp.
in is possibly bigger due to padding bits between reduced images.
out must be big enough AND must be 0 everywhere if bpp < 8 in the current implementation
(because that's likely a little bit faster)
NOTE: comments about padding bits are only relevant if bpp < 8
*/
Adam7 interlaced image, with no padding bits between scanlines, but between
reduced images so that each reduced image starts at a byte.
out: the same pixels, but re-ordered so that they're now a non-interlaced image with size w*h
bpp: bits per pixel
out has the following size in bits: w * h * bpp.
in is possibly bigger due to padding bits between reduced images.
out must be big enough AND must be 0 everywhere if bpp < 8 in the current implementation
(because that's likely a little bit faster)
NOTE: comments about padding bits are only relevant if bpp < 8
Adam7 interlaced image with no padding bits between scanlines but between reduced images so that each reduced image starts at a byte . out : the same pixels but re - ordered so that they ' re now a non - interlaced image with size w * h bpp : bits per pixel out has the following size in bits : w * h * bpp . in is possibly bigger due to padding bits between reduced images . out must be big enough AND must be 0 everywhere if bpp < 8 in the current implementation ( because that ' s likely a little bit faster ) NOTE : comments about padding bits are only relevant if bpp < 8
pub(super) fn adam7_deinterlace(
    out: &mut [u8],
    inp: &[u8],
    w: u32,
    h: u32,
    bpp: u32,
) {
    let (passw, passh, _, _, passstart) = adam7_get_pass_values(w, h, bpp);
    if bpp >= 8 {
        for i in 0..7 {
            let bytewidth = bpp / 8;
            for y in 0..passh[i] {
                for x in 0..passw[i] {
                    let pixelinstart = (passstart[i]
                        + (y * passw[i] + x) * bytewidth)
                        as usize;
                    let bytewidth = bytewidth as usize;
                    let pixeloutstart = ((ADAM7_IY[i] + y * ADAM7_DY[i]) * w
                        + ADAM7_IX[i]
                        + x * ADAM7_DX[i])
                        as usize
                        * bytewidth;
                    out[pixeloutstart..(bytewidth + pixeloutstart)]
                        .clone_from_slice(
                            &inp[pixelinstart..(bytewidth + pixelinstart)],
                        )
                }
            }
        }
    } else {
        for i in 0..7 {
            let ilinebits = bpp * passw[i];
            let olinebits = bpp * w;
            for y in 0..passh[i] {
                for x in 0..passw[i] {
                    let mut ibp = ((8 * passstart[i])
                        + (y * ilinebits + x * bpp))
                        as usize;
                    let mut obp = ((ADAM7_IY[i] + y * ADAM7_DY[i]) * olinebits
                        + (ADAM7_IX[i] + x * ADAM7_DX[i]) * bpp)
                        as usize;
                    for _ in 0..bpp {
                        let bit = read_bit_from_reversed_stream(&mut ibp, inp);
                        /*note that this function assumes the out buffer is completely 0, use set_bit_of_reversed_stream otherwise*/
                        set_bit_of_reversed_stream0(&mut obp, out, bit);
                    }
                }
            }
        }
    };
}
pub ( super ) fn adam7_deinterlace ( out : & mut [ u8 ] , inp : & [ u8 ] , w : u32 , h : u32 , bpp : u32 , ) { let ( passw , passh , _ , _ , passstart ) = adam7_get_pass_values ( w , h , bpp ) ; if bpp >= 8 { for i in 0 .. 7 { let bytewidth = bpp / 8 ; for y in 0 .. passh [ i ] { for x in 0 .. passw [ i ] { let pixelinstart = ( passstart [ i ] + ( y * passw [ i ] + x ) * bytewidth ) as usize ; let bytewidth = bytewidth as usize ; let pixeloutstart = ( ( ADAM7_IY [ i ] + y * ADAM7_DY [ i ] ) * w + ADAM7_IX [ i ] + x * ADAM7_DX [ i ] ) as usize * bytewidth ; out [ pixeloutstart .. ( bytewidth + pixeloutstart ) ] . clone_from_slice ( & inp [ pixelinstart .. ( bytewidth + pixelinstart ) ] , ) } } } } else { for i in 0 .. 7 { let ilinebits = bpp * passw [ i ] ; let olinebits = bpp * w ; for y in 0 .. passh [ i ] { for x in 0 .. passw [ i ] { let mut ibp = ( ( 8 * passstart [ i ] ) + ( y * ilinebits + x * bpp ) ) as usize ; let mut obp = ( ( ADAM7_IY [ i ] + y * ADAM7_DY [ i ] ) * olinebits + ( ADAM7_IX [ i ] + x * ADAM7_DX [ i ] ) * bpp ) as usize ; for _ in 0 .. bpp { let bit = read_bit_from_reversed_stream ( & mut ibp , inp ) ; /*note that this function assumes the out buffer is completely 0, use set_bit_of_reversed_stream otherwise*/ set_bit_of_reversed_stream0 ( & mut obp , out , bit ) ; } } } } } ; }
in: Adam7 interlaced image, with no padding bits between scanlines, but between
reduced images so that each reduced image starts at a byte.
in : Adam7 interlaced image with no padding bits between scanlines but between reduced images so that each reduced image starts at a byte .
out
&mut [u8]
inp
&[u8]
w
u32
h
u32
bpp
u32