Example #1
0
bool LICECaptureDecompressor::NextFrame() // TRUE if out of frames
{
  if (++m_frameidx >= m_frame_deltas[m_rd_which].GetSize())
  {
    m_rd_which=!m_rd_which;

    DecompressBlock(m_rd_which,1.0);
    if (!ReadHdr(!m_rd_which))
      memset(&m_curhdr[!m_rd_which],0,sizeof(m_curhdr[!m_rd_which]));
    m_frameidx=0;
    if (!m_curhdr[m_rd_which].bpp) return false;
    DecodeSlices();
  }
  else
    DecompressBlock(!m_rd_which,m_frameidx/(double)m_frame_deltas[m_rd_which].GetSize());
  return false;
}
Example #2
0
int LICECaptureDecompressor::Seek(unsigned int offset_ms)
{

  memset(m_curhdr,0,sizeof(m_curhdr));
  if (!m_file) return -1;

  int rval=0;

  unsigned int seekpos=0;
  m_frameidx=0;
  if (offset_ms>0&&m_file_frame_info.GetSize())
  {
    int x;
    for(x=0;x<m_file_frame_info.GetSize()-2;x+=2)
    {
      if (offset_ms < m_file_frame_info.Get()[x+2+1]) break;
    }
    seekpos = m_file_frame_info.Get()[x];
    offset_ms -= m_file_frame_info.Get()[x+1];
    // figure out the best place to seek
  }
  else 
  {
    if (offset_ms>0) rval=-1;
    offset_ms=0;
  }

  m_rd_which=0;
  m_file->SetPosition(seekpos);
  if (!ReadHdr(m_rd_which)||!DecompressBlock(m_rd_which,1.0)) 
  {
    rval=-1;
    memset(&m_curhdr,0,sizeof(m_curhdr));
  }
  else
  {
    if (offset_ms>0 && rval==0)
    {
      int x;
      for (x = 1; x < m_frame_deltas[m_rd_which].GetSize(); x++)
      {
        if (offset_ms < m_frame_deltas[m_rd_which].Get()[x])
        {
          rval = offset_ms;
          break;
        }
        offset_ms -= m_frame_deltas[m_rd_which].Get()[x];
      }
      m_frameidx=x-1;
    }
    if (!ReadHdr(!m_rd_which))
        memset(&m_curhdr[!m_rd_which],0,sizeof(m_curhdr[!m_rd_which]));

    DecodeSlices();
  }

  return rval;
}
Example #3
0
// Allocates using new[], doesn't free.
uint8_t *ETC1ToRGBA(uint8_t *etc1, int width, int height) {
	uint8_t *rgba = new uint8_t[width * height * 4];
	memset(rgba, 0xFF, width * height * 4);
	for (int y = 0; y < height; y += 4) {
		for (int x = 0; x < width; x += 4) {
			DecompressBlock(etc1 + ((y / 4) * width/4 + (x / 4)) * 8,
											rgba + (y * width + x) * 4, width, 255);
		}
	}
	return rgba;
}
/*
========================
idLZWCompressor::ReadByte
========================
*/
int idLZWCompressor::ReadByte( bool ignoreOverflow ) {
	if ( blockIndex == blockSize ) {
		DecompressBlock();
	}

	if ( blockIndex == blockSize ) { //-V581 DecompressBlock() updates these values, the if() isn't redundant
		if ( !ignoreOverflow ) {
			overflowed = true;
			assert( !"idLZWCompressor::ReadByte overflowed!" );
		}
		return -1;
	}
	
	return block[blockIndex++];
}