//=============================================================================== // Copyright (c) 2007-2016 Advanced Micro Devices, Inc. All rights reserved. // Copyright (c) 2004-2006 ATI Technologies Inc. //=============================================================================== // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files(the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and / or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions : // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // // // BC7_Decode.cpp : A reference decoder for BC7 // #include "bc7_definitions.h" #include "bc7_partitions.h" #include "bc7_decode.h" #include "bc7_utils.h" #include "common.h" #ifdef TEST_CMP_CORE_DECODER #include "cmp_core.h" #endif // Enable this to print info about the decoded blocks // #define PRINT_DECODE_INFO #ifdef USE_FILEIO #include extern FILE * bc7_File; #endif #ifdef USE_BC7_TESTBLOCK // This is a block that I dumped out of Microsoft's compressor // as a sanity check for the decoder static BYTE testBlock[] = { 0x36, 0x40, 0xf7, 0x87, 0x40, 0xf7, 0x87, 0x40, 0xf7, 0x87, 0x12, 0x8d, 0xf5, 0xef, 0x72, 0x0a }; #endif // // Bit reader - reads one bit from a buffer at the current bit offset // and increments the offset // CMP_DWORD BC7BlockDecoder::ReadBit(CMP_BYTE base[]) { #ifdef USE_DBGTRACE DbgTrace(()); #endif int byteLocation; int remainder; CMP_DWORD bit = 0; byteLocation = m_bitPosition/8; remainder = m_bitPosition % 8; bit = base[byteLocation]; bit >>= remainder; bit &= 0x1; // Increment bit position m_bitPosition++; return (bit); } void BC7BlockDecoder::DecompressDualIndexBlock(double out[MAX_SUBSET_SIZE][MAX_DIMENSION_BIG], CMP_BYTE in[COMPRESSED_BLOCK_SIZE], CMP_DWORD endpoint[2][MAX_DIMENSION_BIG]) { #ifdef USE_DBGTRACE DbgTrace(()); #endif CMP_DWORD i, j, k; double ramp[MAX_DIMENSION_BIG][1< 7) { // Something really bad happened... return; } for(i=0; i