コード例 #1
0
ファイル: CompressorPVRLib.cpp プロジェクト: GammaUNC/FasTC
  void CompressPVRLib(const FasTC::CompressionJob &cj,
                      bool bTwoBitMode,
                      const EWrapMode) {
    pvrtexture::CPVRTextureHeader pvrTexHdr;
    pvrTexHdr.setPixelFormat(pvrtexture::PVRStandard8PixelType);
    pvrTexHdr.setWidth(cj.Width());
    pvrTexHdr.setHeight(cj.Height());
    pvrTexHdr.setIsFileCompressed(false);
    pvrTexHdr.setIsPreMultiplied(false);

    pvrtexture::CPVRTexture pvrTex = pvrtexture::CPVRTexture(pvrTexHdr, cj.InBuf());
    bool result = pvrtexture::Transcode(pvrTex,
                                        ePVRTPF_PVRTCI_4bpp_RGBA,
                                        ePVRTVarTypeUnsignedByte,
                                        ePVRTCSpacelRGB,
                                        pvrtexture::ePVRTCFast);
    assert(result);
    (void)result;

    memcpy(cj.OutBuf(), static_cast<uint8 *>(pvrTex.getDataPtr()), cj.Width() * cj.Height() / 2);
  }
コード例 #2
0
ファイル: Compressor.cpp プロジェクト: Nuos/FasTC
  void Compress_RG(const FasTC::CompressionJob &cj) {

    rg_etc1::etc1_pack_params params;
    params.m_quality = rg_etc1::cLowQuality;
    rg_etc1::pack_etc1_block_init();

    uint32 kBlockSz = GetBlockSize(FasTC::eCompressionFormat_ETC1);
    const uint32 startBlock = cj.CoordsToBlockIdx(cj.XStart(), cj.YStart());
    uint8 *outBuf = cj.OutBuf() + startBlock * kBlockSz;

    const uint32 endY = std::min(cj.YEnd(), cj.Height() - 4);
    uint32 startX = cj.XStart();
    for(uint32 j = cj.YStart(); j <= endY; j += 4) {
      const uint32 endX = j == cj.YEnd()? cj.XEnd() : cj.Width();
      for(uint32 i = startX; i < endX; i += 4) {

        uint32 pixels[16];
        const uint32 *inPixels = reinterpret_cast<const uint32 *>(cj.InBuf());
        memcpy(pixels, inPixels + j*cj.Width() + i, 4 * sizeof(uint32));
        memcpy(pixels + 4, inPixels + (j+1)*cj.Width() + i, 4 * sizeof(uint32));
        memcpy(pixels + 8, inPixels + (j+2)*cj.Width() + i, 4 * sizeof(uint32));
        memcpy(pixels + 12, inPixels + (j+3)*cj.Width() + i, 4 * sizeof(uint32));

        pack_etc1_block(outBuf, pixels, params);
        outBuf += kBlockSz;
      }
      startX = 0;
    }
  }