tensorflow/core/lib/png/png_io.cc
// Convert from 8 bit components to 16. This works in-place.
Convert from 8 bit components to 16. This works in-place.
Convert from 8 bit components to 16 . This works in - place .
static void Convert8to16(const uint8* p8, int num_comps, int p8_row_bytes,
                         int width, int height_in, uint16* p16,
                         int p16_row_bytes) {
  int64_t height = static_cast<int64_t>(height_in);
  width *= num_comps;
  CPTR_INC(uint8, p8, (height - 1) * p8_row_bytes + (width - 1) * sizeof(*p8));
  PTR_INC(uint16, p16,
          (height - 1) * p16_row_bytes + (width - 1) * sizeof(*p16));
  int bump8 = width * sizeof(*p8) - p8_row_bytes;
  int bump16 = width * sizeof(*p16) - p16_row_bytes;
  for (; height-- != 0;
       CPTR_INC(uint8, p8, bump8), PTR_INC(uint16, p16, bump16)) {
    for (int w = width; w-- != 0; --p8, --p16) {
      uint32 pix = *p8;
      pix |= pix << 8;
      *p16 = static_cast<uint16>(pix);
    }
  }
}
static void Convert8to16 ( const uint8 * p8 , int num_comps , int p8_row_bytes , int width , int height_in , uint16 * p16 , int p16_row_bytes ) { int64_t height = static_cast < int64_t > ( height_in ) ; width *= num_comps ; CPTR_INC ( uint8 , p8 , ( height - 1 ) * p8_row_bytes + ( width - 1 ) * sizeof ( * p8 ) ) ; PTR_INC ( uint16 , p16 , ( height - 1 ) * p16_row_bytes + ( width - 1 ) * sizeof ( * p16 ) ) ; int bump8 = width * sizeof ( * p8 ) - p8_row_bytes ; int bump16 = width * sizeof ( * p16 ) - p16_row_bytes ; for ( ; height -- != 0 ; CPTR_INC ( uint8 , p8 , bump8 ) , PTR_INC ( uint16 , p16 , bump16 ) ) { for ( int w = width ; w -- != 0 ; -- p8 , -- p16 ) { uint32 pix = * p8 ; pix |= pix << 8 ; * p16 = static_cast < uint16 > ( pix ) ; } } }
Convert from 8 bit components to 16.
Convert from 8 bit components to 16 .
// Force height*row_bytes computations to use 64 bits. Height*width is // enforced to < 29 bits in decode_png_op.cc, but height*row_bytes is // height*width*channels*(8bit?1:2) which is therefore only constrained to < // 33 bits. // Adjust pointers to copy backwards