mirror of
https://github.com/drewcassidy/quicktex.git
synced 2024-09-13 06:37:34 +00:00
Some debugging for single tables
This commit is contained in:
parent
c879061e4e
commit
8f48330191
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -2,3 +2,6 @@
|
|||||||
path = extern/pybind11
|
path = extern/pybind11
|
||||||
url = https://github.com/pybind/pybind11.git
|
url = https://github.com/pybind/pybind11.git
|
||||||
branch = stable
|
branch = stable
|
||||||
|
[submodule "extern/gif-h"]
|
||||||
|
path = extern/gif-h
|
||||||
|
url = https://github.com/charlietangora/gif-h.git
|
||||||
|
@ -16,6 +16,8 @@ file(GLOB TEST_FILES "src/test/*.c" "src/test/*.cpp" "src/test/*.h")
|
|||||||
# Organize source files together for some IDEs
|
# Organize source files together for some IDEs
|
||||||
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCE_FILES} ${HEADER_FILES} ${PYTHON_FILES})
|
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCE_FILES} ${HEADER_FILES} ${PYTHON_FILES})
|
||||||
|
|
||||||
|
include_directories(${CMAKE_SOURCE_DIR}/extern/gif-h)
|
||||||
|
|
||||||
# Add python module
|
# Add python module
|
||||||
pybind11_add_module(python_rgbcx
|
pybind11_add_module(python_rgbcx
|
||||||
${SOURCE_FILES}
|
${SOURCE_FILES}
|
||||||
|
1
extern/gif-h
vendored
Submodule
1
extern/gif-h
vendored
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 3d2657b9ad40aac9fd6f75ad079335856e94d664
|
@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
#include "BC1Encoder.h"
|
#include "BC1Encoder.h"
|
||||||
|
|
||||||
|
#include <gif.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@ -47,13 +50,19 @@ inline void PrepSingleColorTableEntry(unsigned &error, MatchList &match_table, u
|
|||||||
match_table[i].high = (uint8_t)high;
|
match_table[i].high = (uint8_t)high;
|
||||||
match_table[i].error = (uint8_t)new_error;
|
match_table[i].error = (uint8_t)new_error;
|
||||||
|
|
||||||
error = new_error;
|
// error = new_error;
|
||||||
}
|
}
|
||||||
|
error = new_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <size_t S> void PrepSingleColorTable(MatchList &match_table, MatchList &match_table_half, Interpolator &interpolator) {
|
template <size_t S> void PrepSingleColorTable(MatchList &match_table, MatchList &match_table_half, Interpolator &interpolator) {
|
||||||
unsigned size = 1 << S;
|
unsigned size = 1 << S;
|
||||||
|
|
||||||
|
std::vector<uint8_t> frame(size * size * 4, 0);
|
||||||
|
auto fileName = "lut" + std::to_string(S) + ".gif";
|
||||||
|
GifWriter g;
|
||||||
|
GifBegin(&g, fileName.c_str(), size, size, 10);
|
||||||
|
|
||||||
assert((S == 5 && size == 32) || (S == 6 && size == 64));
|
assert((S == 5 && size == 32) || (S == 6 && size == 64));
|
||||||
|
|
||||||
bool ideal = interpolator.IsIdeal();
|
bool ideal = interpolator.IsIdeal();
|
||||||
@ -69,7 +78,7 @@ template <size_t S> void PrepSingleColorTable(MatchList &match_table, MatchList
|
|||||||
uint8_t low8 = (S == 5) ? scale5To8(low) : scale6To8(low);
|
uint8_t low8 = (S == 5) ? scale5To8(low) : scale6To8(low);
|
||||||
|
|
||||||
for (uint8_t high = 0; high < size; high++) {
|
for (uint8_t high = 0; high < size; high++) {
|
||||||
uint8_t high8 = (S == 5) ? scale5To8(high) : scale6To8(low);
|
uint8_t high8 = (S == 5) ? scale5To8(high) : scale6To8(high);
|
||||||
uint8_t value, value_half;
|
uint8_t value, value_half;
|
||||||
|
|
||||||
if (use_8bit) {
|
if (use_8bit) {
|
||||||
@ -82,9 +91,17 @@ template <size_t S> void PrepSingleColorTable(MatchList &match_table, MatchList
|
|||||||
|
|
||||||
PrepSingleColorTableEntry(error, match_table, value, i, low, high, low8, high8, ideal);
|
PrepSingleColorTableEntry(error, match_table, value, i, low, high, low8, high8, ideal);
|
||||||
PrepSingleColorTableEntry(error_half, match_table_half, value_half, i, low, high, low8, high8, ideal);
|
PrepSingleColorTableEntry(error_half, match_table_half, value_half, i, low, high, low8, high8, ideal);
|
||||||
|
frame[(low + (size * high))*4] = error;
|
||||||
|
frame[(low + (size * high))*4+1] = error;
|
||||||
|
frame[(low + (size * high))*4+2] = error;
|
||||||
|
frame[(low + (size * high))*4+3] = 255;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
GifWriteFrame(&g, frame.data(), size, size, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GifEnd(&g);
|
||||||
}
|
}
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
|
45
src/BC1/SelectorHistogram.h
Normal file
45
src/BC1/SelectorHistogram.h
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/* Python-rgbcx Texture Compression Library
|
||||||
|
Copyright (C) 2021 Andrew Cassidy <drewcassidy@me.com>
|
||||||
|
Partially derived from rgbcx.h written by Richard Geldreich <richgel99@gmail.com>
|
||||||
|
and licenced under the public domain
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
|
namespace rgbcx {
|
||||||
|
//
|
||||||
|
//class SelectorHistogram<size_t Size, size_t Max> {
|
||||||
|
// public:
|
||||||
|
// std::array<uint8_t, Size> histogram;
|
||||||
|
//
|
||||||
|
// bool operator==(const SelectorHistogram<N> &other) const {
|
||||||
|
// for (unsigned i = 0; i < Size; i++) {
|
||||||
|
// if (histogram[i] != other.histogram[i]) return false;
|
||||||
|
// }
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// bool AnyMax() cost {
|
||||||
|
// for (unsigned i = 0; i < Size; i++) {
|
||||||
|
// if (histogram[i] == Max) return true;
|
||||||
|
// }
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
//};
|
||||||
|
|
||||||
|
} // namespace rgbcx
|
Loading…
Reference in New Issue
Block a user