rEFIt_UEFI/libeg/lodepng.cpp
/*out must be buffer big enough to contain full image, and in must contain the full decompressed data from
the IDAT chunks (with filter index bytes and possible padding bits)
return value is error*/
out must be buffer big enough to contain full image, and in must contain the full decompressed data from
the IDAT chunks (with filter index bytes and possible padding bits)
return value is error
out must be buffer big enough to contain full image and in must contain the full decompressed data from the IDAT chunks ( with filter index bytes and possible padding bits ) return value is error
static unsigned postProcessScanlines(unsigned char* out, unsigned char* in,
                                     unsigned w, unsigned h, const LodePNGInfo* info_png) {
  unsigned bpp = lodepng_get_bpp(&info_png->color);
  if(bpp == 0) return 31; 
  if(info_png->interlace_method == 0) {
    if(bpp < 8 && w * bpp != ((w * bpp + 7u) / 8u) * 8u) {
      CERROR_TRY_RETURN(unfilter(in, in, w, h, bpp));
      removePaddingBits(out, in, w * bpp, ((w * bpp + 7u) / 8u) * 8u, h);
    }
    else CERROR_TRY_RETURN(unfilter(out, in, w, h, bpp));
  } else  {
    unsigned passw[7], passh[7]; size_t filter_passstart[8], padded_passstart[8], passstart[8];
    unsigned i;
    Adam7_getpassvalues(passw, passh, filter_passstart, padded_passstart, passstart, w, h, bpp);
    for(i = 0; i != 7; ++i) {
      CERROR_TRY_RETURN(unfilter(&in[padded_passstart[i]], &in[filter_passstart[i]], passw[i], passh[i], bpp));
      if(bpp < 8) {
        removePaddingBits(&in[passstart[i]], &in[padded_passstart[i]], passw[i] * bpp,
                          ((passw[i] * bpp + 7u) / 8u) * 8u, passh[i]);
      }
    }
    Adam7_deinterlace(out, in, w, h, bpp);
  }
  return 0;
}
static unsigned postProcessScanlines ( unsigned char * out , unsigned char * in , unsigned w , unsigned h , const LodePNGInfo * info_png ) { unsigned bpp = lodepng_get_bpp ( & info_png -> color ) ; if ( bpp == 0 ) return 31 ; if ( info_png -> interlace_method == 0 ) { if ( bpp < 8 && w * bpp != ( ( w * bpp + 7u ) / 8u ) * 8u ) { CERROR_TRY_RETURN ( unfilter ( in , in , w , h , bpp ) ) ; removePaddingBits ( out , in , w * bpp , ( ( w * bpp + 7u ) / 8u ) * 8u , h ) ; } else CERROR_TRY_RETURN ( unfilter ( out , in , w , h , bpp ) ) ; } else { unsigned passw [ 7 ] , passh [ 7 ] ; size_t filter_passstart [ 8 ] , padded_passstart [ 8 ] , passstart [ 8 ] ; unsigned i ; Adam7_getpassvalues ( passw , passh , filter_passstart , padded_passstart , passstart , w , h , bpp ) ; for ( i = 0 ; i != 7 ; ++ i ) { CERROR_TRY_RETURN ( unfilter ( & in [ padded_passstart [ i ] ] , & in [ filter_passstart [ i ] ] , passw [ i ] , passh [ i ] , bpp ) ) ; if ( bpp < 8 ) { removePaddingBits ( & in [ passstart [ i ] ] , & in [ padded_passstart [ i ] ] , passw [ i ] * bpp , ( ( passw [ i ] * bpp + 7u ) / 8u ) * 8u , passh [ i ] ) ; } } Adam7_deinterlace ( out , in , w , h , bpp ) ; } return 0 ; }
out must be buffer big enough to contain full image, and in must contain the full decompressed data from
the IDAT chunks (with filter index bytes and possible padding bits)
return value is error
out must be buffer big enough to contain full image and in must contain the full decompressed data from the IDAT chunks ( with filter index bytes and possible padding bits ) return value is error
/*
  This function converts the filtered-padded-interlaced data into pure 2D image buffer with the PNG's colortype.
  Steps:
  *) if no Adam7: 1) unfilter 2) remove padding bits (= possible extra bits per scanline if bpp < 8)
  *) if adam7: 1) 7x unfilter 2) 7x remove padding bits 3) Adam7_deinterlace
  NOTE: the in buffer will be overwritten with intermediate data!
  */ /*error: invalid colortype*/ /*we can immediately filter into the out buffer, no other steps needed*/ /*interlace_method is 1 (Adam7)*/ /*TODO: possible efficiency improvement: if in this reduced image the bits fit nicely in 1 scanline,
      move bytes instead of bits or move not at all*/ /*remove padding bits in scanlines; after this there still may be padding
        bits between the different reduced images: each reduced image still starts nicely at a byte*/