diff --git a/CMakeLists.txt b/CMakeLists.txt index d5c3244..32f607a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.17) include(CheckIPOSupported) include(tools/CompilerWarnings.cmake) -project(rgbcx) +project(quicktex) # Find dependencies find_package(Python COMPONENTS Interpreter Development REQUIRED) @@ -10,41 +10,61 @@ find_package(OpenMP) add_subdirectory(extern/pybind11) # Collect source files -file(GLOB SOURCE_FILES "src/rgbcx/*.cpp" "src/rgbcx/BC*/*.cpp") -file(GLOB HEADER_FILES "src/rgbcx/*.h" "src/rgbcx/BC*/*.h") -file(GLOB PYTHON_FILES "src/rgbcx/bindings/*.cpp" "src/rgbcx/bindings/*.h") +file(GLOB SOURCE_FILES + "quicktex/*.cpp" + "quicktex/compression/*.cpp" + "quicktex/compression/bc1/*.cpp" + "quicktex/compression/bc3/*.cpp" + "quicktex/compression/bc4/*.cpp" + "quicktex/compression/bc5/*.cpp" + ) + +file(GLOB HEADER_FILES + "quicktex/*.h" + "quicktex/compression/*.h" + "quicktex/compression/bc1/*.h" + "quicktex/compression/bc3/*.h" + "quicktex/compression/bc4/*.h" + "quicktex/compression/bc5/*.h" + "quicktex/formats/blocks/*.h" + ) + file(GLOB TEST_FILES "tests/*.cpp") +set(PYTHON_FILES + "quicktex/bindings/Module.cpp" + "quicktex/compression/bindings/Decoders.cpp" + "quicktex/compression/bindings/Encoders.cpp") + # Organize source files together for some IDEs source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCE_FILES} ${HEADER_FILES} ${PYTHON_FILES}) # Add python module -pybind11_add_module(_rgbcx +pybind11_add_module(_quicktex ${SOURCE_FILES} ${HEADER_FILES} ${PYTHON_FILES}) -add_executable(test_rgbcx +add_executable(test_quicktex ${SOURCE_FILES} ${HEADER_FILES} ${TEST_FILES}) -target_link_libraries(test_rgbcx PRIVATE pybind11::embed) +target_link_libraries(test_quicktex PRIVATE pybind11::embed) -target_compile_definitions(test_rgbcx PRIVATE -DCUSTOM_SYS_PATH="${CMAKE_HOME_DIRECTORY}/env/lib/python3.8/site-packages") -message("\"${CMAKE_HOME_DIRECTORY}/env/lib/python3.8/site-packages\"") +target_compile_definitions(test_quicktex PRIVATE -DCUSTOM_SYS_PATH="${CMAKE_HOME_DIRECTORY}/env/lib/python3.8/site-packages") # enable openMP if available -if(OpenMP_CXX_FOUND) - target_link_libraries(_rgbcx PUBLIC OpenMP::OpenMP_CXX) -endif() +if (OpenMP_CXX_FOUND) + target_link_libraries(_quicktex PUBLIC OpenMP::OpenMP_CXX) +endif () # Set module features, like C/C++ standards -target_compile_features(_rgbcx PUBLIC cxx_std_20 c_std_11) -target_compile_features(test_rgbcx PUBLIC cxx_std_20 c_std_11) +target_compile_features(_quicktex PUBLIC cxx_std_20 c_std_11) +target_compile_features(test_quicktex PUBLIC cxx_std_20 c_std_11) -set_project_warnings(_rgbcx) -set_project_warnings(test_rgbcx) +set_project_warnings(_quicktex) +set_project_warnings(test_quicktex) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3") diff --git a/docs/reference/index.rst b/docs/reference/index.rst new file mode 100644 index 0000000..638d815 --- /dev/null +++ b/docs/reference/index.rst @@ -0,0 +1,2 @@ +index.rst +============ \ No newline at end of file diff --git a/docs/reference/rgbcx.rst b/docs/reference/rgbcx.rst new file mode 100644 index 0000000..e69de29 diff --git a/src/rgbcx/BlockView.h b/quicktex/BlockView.h similarity index 99% rename from src/rgbcx/BlockView.h rename to quicktex/BlockView.h index 9721fbe..b11d94e 100644 --- a/src/rgbcx/BlockView.h +++ b/quicktex/BlockView.h @@ -30,7 +30,7 @@ #include "Vector4Int.h" #include "ndebug.h" -namespace rgbcx { +namespace quicktex { template class RowView { public: RowView(S *start, int pixel_stride = 1) : start(start), pixel_stride(pixel_stride) {} @@ -167,4 +167,4 @@ template class ColorBlockView : public BlockView; using Byte4x4 = BlockView; -} // namespace rgbcx \ No newline at end of file +} // namespace quicktex \ No newline at end of file diff --git a/src/rgbcx/Color.cpp b/quicktex/Color.cpp similarity index 98% rename from src/rgbcx/Color.cpp rename to quicktex/Color.cpp index f512683..a51ee37 100644 --- a/src/rgbcx/Color.cpp +++ b/quicktex/Color.cpp @@ -24,7 +24,7 @@ #include "Vector4Int.h" #include "util.h" // for scale5To8, scale8To5, assert5bit, scale6To8 -namespace rgbcx { +namespace quicktex { Color::Color() { SetRGBA(0, 0, 0, 0xFF); } @@ -122,4 +122,4 @@ uint16_t Color::Pack565Unscaled() const { return Pack565Unscaled(r, g, b); } Color Color::ScaleTo565() const { return Color(scale8To5(r), scale8To6(g), scale8To5(b)); } Color Color::ScaleFrom565() const { return Color(scale5To8(r), scale6To8(g), scale5To8(b)); } -} // namespace rgbcx \ No newline at end of file +} // namespace quicktex \ No newline at end of file diff --git a/src/rgbcx/Color.h b/quicktex/Color.h similarity index 98% rename from src/rgbcx/Color.h rename to quicktex/Color.h index 2cd392d..70dfc25 100644 --- a/src/rgbcx/Color.h +++ b/quicktex/Color.h @@ -23,7 +23,7 @@ #include // for uint8_t, uint16_t -namespace rgbcx { +namespace quicktex { class Vector4; class Vector4Int; @@ -99,4 +99,4 @@ class Color { .882353f, .898039f, .913725f, .929412f, .945098f, .960784f, .976471f, .992157f, 1e+37f}; }; #pragma pack(pop) -} // namespace rgbcx \ No newline at end of file +} // namespace quicktex \ No newline at end of file diff --git a/src/rgbcx/Interpolator.cpp b/quicktex/Interpolator.cpp similarity index 99% rename from src/rgbcx/Interpolator.cpp rename to quicktex/Interpolator.cpp index d2de1d3..3bd05f9 100644 --- a/src/rgbcx/Interpolator.cpp +++ b/quicktex/Interpolator.cpp @@ -26,7 +26,7 @@ #include "util.h" -namespace rgbcx { +namespace quicktex { /* Interpolator::Interpolator() { @@ -196,4 +196,4 @@ uint8_t InterpolatorAMD::Interpolate8(uint8_t v0, uint8_t v1) const { return (v0 uint8_t InterpolatorAMD::InterpolateHalf8(uint8_t v0, uint8_t v1) const { return (v0 + v1 + 1) >> 1; } // endregion -} // namespace rgbcx +} // namespace quicktex diff --git a/src/rgbcx/Interpolator.h b/quicktex/Interpolator.h similarity index 99% rename from src/rgbcx/Interpolator.h rename to quicktex/Interpolator.h index 0c0b66b..5faef8e 100644 --- a/src/rgbcx/Interpolator.h +++ b/quicktex/Interpolator.h @@ -24,7 +24,7 @@ #include "Color.h" // for Color -namespace rgbcx { +namespace quicktex { class Interpolator { public: @@ -171,4 +171,4 @@ class InterpolatorAMD : public Interpolator { Type GetType() const noexcept override { return Type::AMD; } }; -} // namespace rgbcx \ No newline at end of file +} // namespace quicktex \ No newline at end of file diff --git a/src/rgbcx/Matrix4x4.cpp b/quicktex/Matrix4x4.cpp similarity index 97% rename from src/rgbcx/Matrix4x4.cpp rename to quicktex/Matrix4x4.cpp index 71d95da..68f63cf 100644 --- a/src/rgbcx/Matrix4x4.cpp +++ b/quicktex/Matrix4x4.cpp @@ -19,7 +19,7 @@ #include "Matrix4x4.h" -namespace rgbcx { +namespace quicktex { Matrix4x4 operator*(const Matrix4x4& lhs, const Matrix4x4& rhs) { Matrix4x4 trans_rhs = rhs.Transpose(); // 🏳️‍⚧️ @@ -47,4 +47,4 @@ void Matrix4x4::Mirror() { } } -} // namespace rgbcx +} // namespace quicktex diff --git a/src/rgbcx/Matrix4x4.h b/quicktex/Matrix4x4.h similarity index 98% rename from src/rgbcx/Matrix4x4.h rename to quicktex/Matrix4x4.h index a198e9e..444aeda 100644 --- a/src/rgbcx/Matrix4x4.h +++ b/quicktex/Matrix4x4.h @@ -26,7 +26,7 @@ #include "Vector4.h" -namespace rgbcx { +namespace quicktex { class Matrix4x4 { public: @@ -92,4 +92,4 @@ class Matrix4x4 { std::array _r; }; -} // namespace rgbcx +} // namespace quicktex diff --git a/src/rgbcx/Vector4.h b/quicktex/Vector4.h similarity index 98% rename from src/rgbcx/Vector4.h rename to quicktex/Vector4.h index 708b296..ba368f8 100644 --- a/src/rgbcx/Vector4.h +++ b/quicktex/Vector4.h @@ -25,7 +25,7 @@ #include "Color.h" -namespace rgbcx { +namespace quicktex { class Vector4 { public: @@ -121,4 +121,4 @@ class Vector4 { std::array _c; }; -} // namespace rgbcx +} // namespace quicktex diff --git a/src/rgbcx/Vector4Int.h b/quicktex/Vector4Int.h similarity index 99% rename from src/rgbcx/Vector4Int.h rename to quicktex/Vector4Int.h index 82adb13..939dad8 100644 --- a/src/rgbcx/Vector4Int.h +++ b/quicktex/Vector4Int.h @@ -25,7 +25,7 @@ #include "Color.h" #include "Vector4.h" -namespace rgbcx { +namespace quicktex { class Vector4Int { public: @@ -117,4 +117,4 @@ class Vector4Int { std::array _c; }; -} // namespace rgbcx +} // namespace quicktex diff --git a/quicktex/__init__.py b/quicktex/__init__.py new file mode 100644 index 0000000..9ba7e47 --- /dev/null +++ b/quicktex/__init__.py @@ -0,0 +1 @@ +from _quicktex import * \ No newline at end of file diff --git a/src/rgbcx/bindings/Module.cpp b/quicktex/bindings/Module.cpp similarity index 93% rename from src/rgbcx/bindings/Module.cpp rename to quicktex/bindings/Module.cpp index 419c011..5f09fb3 100644 --- a/src/rgbcx/bindings/Module.cpp +++ b/quicktex/bindings/Module.cpp @@ -22,12 +22,12 @@ #include "../Interpolator.h" namespace py = pybind11; -namespace rgbcx::bindings { +namespace quicktex::bindings { void InitEncoders(py::module_ &m); void InitDecoders(py::module_ &m); -PYBIND11_MODULE(_rgbcx, m) { +PYBIND11_MODULE(_quicktex, m) { m.doc() = "More Stuff"; using IType = Interpolator::Type; @@ -41,4 +41,4 @@ PYBIND11_MODULE(_rgbcx, m) { InitDecoders(m); } -} // namespace rgbcx::bindings \ No newline at end of file +} // namespace quicktex::bindings \ No newline at end of file diff --git a/src/rgbcx/bitwiseEnums.h b/quicktex/bitwiseEnums.h similarity index 100% rename from src/rgbcx/bitwiseEnums.h rename to quicktex/bitwiseEnums.h diff --git a/src/rgbcx/BlockDecoder.h b/quicktex/compression/BlockDecoder.h similarity index 96% rename from src/rgbcx/BlockDecoder.h rename to quicktex/compression/BlockDecoder.h index 2ac9812..48abca0 100644 --- a/src/rgbcx/BlockDecoder.h +++ b/quicktex/compression/BlockDecoder.h @@ -21,15 +21,15 @@ #include #include +#include #include #include -#include -#include "BlockView.h" -#include "ndebug.h" -#include "util.h" +#include "../BlockView.h" +#include "../ndebug.h" +#include "../util.h" -namespace rgbcx { +namespace quicktex { class BlockDecoder { public: @@ -87,4 +87,4 @@ class BlockDecoderTemplate : public BlockDecoder { virtual size_t BlockWidth() const override { return N; } virtual size_t BlockHeight() const override { return M; } }; -} // namespace rgbcx +} // namespace quicktex diff --git a/src/rgbcx/BlockEncoder.h b/quicktex/compression/BlockEncoder.h similarity index 98% rename from src/rgbcx/BlockEncoder.h rename to quicktex/compression/BlockEncoder.h index 6b1d6ec..23ec151 100644 --- a/src/rgbcx/BlockEncoder.h +++ b/quicktex/compression/BlockEncoder.h @@ -24,9 +24,9 @@ #include #include -#include "BlockView.h" +#include "../BlockView.h" -namespace rgbcx { +namespace quicktex { class BlockEncoder { public: @@ -89,4 +89,4 @@ template class BlockEncoderTemplate : public Block virtual size_t MTThreshold() const { return SIZE_MAX; }; }; -} // namespace rgbcx +} // namespace quicktex diff --git a/src/rgbcx/BC1/BC1Decoder.cpp b/quicktex/compression/bc1/BC1Decoder.cpp similarity index 91% rename from src/rgbcx/BC1/BC1Decoder.cpp rename to quicktex/compression/bc1/BC1Decoder.cpp index dabbfe5..eba68f4 100644 --- a/src/rgbcx/BC1/BC1Decoder.cpp +++ b/quicktex/compression/bc1/BC1Decoder.cpp @@ -23,12 +23,12 @@ #include #include -#include "../BlockView.h" -#include "../Color.h" -#include "../ndebug.h" -#include "BC1Block.h" +#include "../../BlockView.h" +#include "../../Color.h" +#include "../../formats/blocks/BC1Block.h" +#include "../../ndebug.h" -namespace rgbcx { +namespace quicktex { void BC1Decoder::DecodeBlock(Color4x4 dest, BC1Block *const block) const noexcept(ndebug) { const auto l = block->GetLowColor(); const auto h = block->GetHighColor(); @@ -49,4 +49,4 @@ void BC1Decoder::DecodeBlock(Color4x4 dest, BC1Block *const block) const noexcep } } } -} // namespace rgbcx +} // namespace quicktex diff --git a/src/rgbcx/BC1/BC1Decoder.h b/quicktex/compression/bc1/BC1Decoder.h similarity index 90% rename from src/rgbcx/BC1/BC1Decoder.h rename to quicktex/compression/bc1/BC1Decoder.h index 331e06a..e56264a 100644 --- a/src/rgbcx/BC1/BC1Decoder.h +++ b/quicktex/compression/bc1/BC1Decoder.h @@ -22,13 +22,13 @@ #include #include +#include "../../BlockView.h" +#include "../../Interpolator.h" +#include "../../formats/blocks/BC1Block.h" +#include "../../ndebug.h" #include "../BlockDecoder.h" -#include "../BlockView.h" -#include "../Interpolator.h" -#include "../ndebug.h" -#include "BC1Block.h" -namespace rgbcx { +namespace quicktex { class BC1Decoder final : public BlockDecoderTemplate { public: using InterpolatorPtr = std::shared_ptr; @@ -45,4 +45,4 @@ class BC1Decoder final : public BlockDecoderTemplate { private: const InterpolatorPtr _interpolator; }; -} // namespace rgbcx +} // namespace quicktex diff --git a/src/rgbcx/BC1/BC1Encoder.cpp b/quicktex/compression/bc1/BC1Encoder.cpp similarity index 99% rename from src/rgbcx/BC1/BC1Encoder.cpp rename to quicktex/compression/bc1/BC1Encoder.cpp index 9afacbb..786a943 100644 --- a/src/rgbcx/BC1/BC1Encoder.cpp +++ b/quicktex/compression/bc1/BC1Encoder.cpp @@ -27,19 +27,19 @@ #include #include -#include "../BlockView.h" -#include "../Color.h" -#include "../Interpolator.h" -#include "../Matrix4x4.h" -#include "../Vector4.h" -#include "../Vector4Int.h" -#include "../bitwiseEnums.h" -#include "../util.h" +#include "../../BlockView.h" +#include "../../Color.h" +#include "../../Interpolator.h" +#include "../../Matrix4x4.h" +#include "../../Vector4.h" +#include "../../Vector4Int.h" +#include "../../bitwiseEnums.h" +#include "../../util.h" #include "Histogram.h" #include "OrderTable.h" #include "SingleColorTable.h" -namespace rgbcx { +namespace quicktex { using namespace BC1; // constructors @@ -941,4 +941,4 @@ void BC1Encoder::EndpointSearch(Color4x4 &pixels, EncodeResults &block) const { } } -} // namespace rgbcx \ No newline at end of file +} // namespace quicktex \ No newline at end of file diff --git a/src/rgbcx/BC1/BC1Encoder.h b/quicktex/compression/bc1/BC1Encoder.h similarity index 97% rename from src/rgbcx/BC1/BC1Encoder.h rename to quicktex/compression/bc1/BC1Encoder.h index fe3bc57..94f7bf9 100644 --- a/src/rgbcx/BC1/BC1Encoder.h +++ b/quicktex/compression/bc1/BC1Encoder.h @@ -26,14 +26,14 @@ #include #include +#include "../../BlockView.h" +#include "../../Color.h" +#include "../../Interpolator.h" +#include "../../formats/blocks/BC1Block.h" #include "../BlockEncoder.h" -#include "../BlockView.h" -#include "../Color.h" -#include "../Interpolator.h" -#include "BC1Block.h" #include "SingleColorTable.h" -namespace rgbcx { +namespace quicktex { class Vector4; class BC1Encoder final : public BlockEncoderTemplate { @@ -196,4 +196,4 @@ class BC1Encoder final : public BlockEncoderTemplate { void EndpointSearch(Color4x4 &pixels, EncodeResults &block) const; }; -} // namespace rgbcx +} // namespace quicktex diff --git a/src/rgbcx/BC1/Histogram.h b/quicktex/compression/bc1/Histogram.h similarity index 95% rename from src/rgbcx/BC1/Histogram.h rename to quicktex/compression/bc1/Histogram.h index 9aa40bf..61f4e6a 100644 --- a/src/rgbcx/BC1/Histogram.h +++ b/quicktex/compression/bc1/Histogram.h @@ -27,10 +27,10 @@ #include #include -#include "../Vector4.h" -#include "../util.h" +#include "../../Vector4.h" +#include "../../util.h" -namespace rgbcx::BC1 { +namespace quicktex::BC1 { template class Histogram { public: using Hash = uint16_t; @@ -82,4 +82,4 @@ template class Histogram { private: std::array _bins; }; -} // namespace rgbcx \ No newline at end of file +} // namespace quicktex \ No newline at end of file diff --git a/src/rgbcx/BC1/OrderTable.cpp b/quicktex/compression/bc1/OrderTable.cpp similarity index 99% rename from src/rgbcx/BC1/OrderTable.cpp rename to quicktex/compression/bc1/OrderTable.cpp index c3a0ea1..9e7e746 100644 --- a/src/rgbcx/BC1/OrderTable.cpp +++ b/quicktex/compression/bc1/OrderTable.cpp @@ -21,9 +21,9 @@ #include -#include "../Vector4.h" +#include "../../Vector4.h" -namespace rgbcx::BC1 { +namespace quicktex::BC1 { using Hash = uint16_t; template <> std::atomic OrderTable<3>::generated = false; @@ -324,4 +324,4 @@ const OrderTable<3>::BestOrderArray OrderTable<3>::BestOrders = { template class OrderTable<3>; template class OrderTable<4>; -} // namespace rgbcx \ No newline at end of file +} // namespace quicktex \ No newline at end of file diff --git a/src/rgbcx/BC1/OrderTable.h b/quicktex/compression/bc1/OrderTable.h similarity index 98% rename from src/rgbcx/BC1/OrderTable.h rename to quicktex/compression/bc1/OrderTable.h index 7a8923e..b23fb35 100644 --- a/src/rgbcx/BC1/OrderTable.h +++ b/quicktex/compression/bc1/OrderTable.h @@ -28,10 +28,10 @@ #include #include -#include "../Vector4.h" +#include "../../Vector4.h" #include "Histogram.h" -namespace rgbcx::BC1 { +namespace quicktex::BC1 { template class OrderTable { public: static constexpr unsigned HashCount = 1 << ((N - 1) * 4); // 16**(N-1) @@ -147,4 +147,4 @@ template <> const OrderTable<4>::BestOrderArray OrderTable<4>::BestOrders; extern template class OrderTable<3>; extern template class OrderTable<4>; -} // namespace rgbcx::BC1 \ No newline at end of file +} // namespace quicktex::BC1 \ No newline at end of file diff --git a/src/rgbcx/BC1/OrderTable4.cpp b/quicktex/compression/bc1/OrderTable4.cpp similarity index 99% rename from src/rgbcx/BC1/OrderTable4.cpp rename to quicktex/compression/bc1/OrderTable4.cpp index 061528e..1c285ad 100644 --- a/src/rgbcx/BC1/OrderTable4.cpp +++ b/quicktex/compression/bc1/OrderTable4.cpp @@ -20,7 +20,7 @@ #include "OrderTable.h" // clang-format off -namespace rgbcx::BC1 { +namespace quicktex::BC1 { template <> const OrderTable<4>::BestOrderArray OrderTable<4>::BestOrders = {{ @@ -1966,5 +1966,5 @@ const OrderTable<4>::BestOrderArray OrderTable<4>::BestOrders = {{ { 15,341,13,33,23,77,141,4,0,351,1,260,102,51,82,9,40,349,854,11,115,217,269,137,180,202,922,5,901,22,10,117,21,365,318,197,120,352,64,12,7,153,177,59,291,32,128,2,165,196,372,36,403,317,457,28,18,8,16,304,30,14,450,31,898,37,3,752,48,134,139,494,421,6,453,401,719,90,86,569,523,110,24,55,475,210,49,44,386,17,730,95,247,244,961,143,125,308,342,817,629,98,498,93,96,76,39,275,509,326,99,285,373,57,237,35,402,160,111,253,105,391,221,116,899,72,127,661 } #endif }}; -} // namespace rgbcx::BC1 +} // namespace quicktex::BC1 // clang-format on \ No newline at end of file diff --git a/src/rgbcx/BC1/SingleColorTable.h b/quicktex/compression/bc1/SingleColorTable.h similarity index 96% rename from src/rgbcx/BC1/SingleColorTable.h rename to quicktex/compression/bc1/SingleColorTable.h index ae85507..0e8d618 100644 --- a/src/rgbcx/BC1/SingleColorTable.h +++ b/quicktex/compression/bc1/SingleColorTable.h @@ -23,10 +23,10 @@ #include #include -#include "../Interpolator.h" -#include "../util.h" +#include "../../Interpolator.h" +#include "../../util.h" -namespace rgbcx::BC1 { +namespace quicktex::BC1 { struct BC1MatchEntry { uint8_t high; @@ -90,4 +90,4 @@ template MatchListPtr SingleColorTable(InterpolatorPtr inte } return matches; } -} // namespace rgbcx \ No newline at end of file +} // namespace quicktex::BC1 \ No newline at end of file diff --git a/src/rgbcx/BC3/BC3Decoder.cpp b/quicktex/compression/bc3/BC3Decoder.cpp similarity index 89% rename from src/rgbcx/BC3/BC3Decoder.cpp rename to quicktex/compression/bc3/BC3Decoder.cpp index ebca076..79f749a 100644 --- a/src/rgbcx/BC3/BC3Decoder.cpp +++ b/quicktex/compression/bc3/BC3Decoder.cpp @@ -21,14 +21,14 @@ #include -#include "../BlockView.h" -#include "../ndebug.h" -#include "BC3Block.h" +#include "../../BlockView.h" +#include "../../formats/blocks/BC3Block.h" +#include "../../ndebug.h" -namespace rgbcx { +namespace quicktex { void BC3Decoder::DecodeBlock(Color4x4 dest, BC3Block *const block) const noexcept(ndebug) { _bc1_decoder->DecodeBlock(dest, &(block->color_block)); _bc4_decoder->DecodeBlock(dest, &(block->alpha_block), 3); } -} // namespace rgbcx \ No newline at end of file +} // namespace quicktex \ No newline at end of file diff --git a/src/rgbcx/BC3/BC3Decoder.h b/quicktex/compression/bc3/BC3Decoder.h similarity index 88% rename from src/rgbcx/BC3/BC3Decoder.h rename to quicktex/compression/bc3/BC3Decoder.h index 83e4773..a5310fc 100644 --- a/src/rgbcx/BC3/BC3Decoder.h +++ b/quicktex/compression/bc3/BC3Decoder.h @@ -21,15 +21,15 @@ #include -#include "../BC1/BC1Decoder.h" -#include "../BC4/BC4Decoder.h" +#include "../../BlockView.h" +#include "../../Interpolator.h" +#include "../../formats/blocks/BC3Block.h" +#include "../../ndebug.h" #include "../BlockDecoder.h" -#include "../BlockView.h" -#include "../Interpolator.h" -#include "../ndebug.h" -#include "BC3Block.h" +#include "../bc1/BC1Decoder.h" +#include "../bc4/BC4Decoder.h" -namespace rgbcx { +namespace quicktex { class BC3Decoder : public BlockDecoderTemplate { public: using BC1DecoderPtr = std::shared_ptr; @@ -47,4 +47,4 @@ class BC3Decoder : public BlockDecoderTemplate { const BC1DecoderPtr _bc1_decoder; const BC4DecoderPtr _bc4_decoder; }; -} // namespace rgbcx +} // namespace quicktex diff --git a/src/rgbcx/BC3/BC3Encoder.cpp b/quicktex/compression/bc3/BC3Encoder.cpp similarity index 90% rename from src/rgbcx/BC3/BC3Encoder.cpp rename to quicktex/compression/bc3/BC3Encoder.cpp index 3dc098a..4ae5c90 100644 --- a/src/rgbcx/BC3/BC3Encoder.cpp +++ b/quicktex/compression/bc3/BC3Encoder.cpp @@ -19,12 +19,12 @@ #include "BC3Encoder.h" -#include "../BlockView.h" -#include "BC3Block.h" +#include "../../BlockView.h" +#include "../../formats/blocks/BC3Block.h" -namespace rgbcx { +namespace quicktex { void BC3Encoder::EncodeBlock(Color4x4 pixels, BC3Block *dest) const { _bc1_encoder->EncodeBlock(pixels, &(dest->color_block)); _bc4_encoder->EncodeBlock(pixels, &(dest->alpha_block), 3); } -} // namespace rgbcx \ No newline at end of file +} // namespace quicktex \ No newline at end of file diff --git a/src/rgbcx/BC3/BC3Encoder.h b/quicktex/compression/bc3/BC3Encoder.h similarity index 89% rename from src/rgbcx/BC3/BC3Encoder.h rename to quicktex/compression/bc3/BC3Encoder.h index 6a0ba19..ee2eddd 100644 --- a/src/rgbcx/BC3/BC3Encoder.h +++ b/quicktex/compression/bc3/BC3Encoder.h @@ -21,14 +21,14 @@ #include -#include "../BC1/BC1Encoder.h" -#include "../BC4/BC4Encoder.h" +#include "../../BlockView.h" +#include "../../Interpolator.h" +#include "../../formats/blocks/BC3Block.h" #include "../BlockEncoder.h" -#include "../BlockView.h" -#include "../Interpolator.h" -#include "BC3Block.h" +#include "../bc1/BC1Encoder.h" +#include "../bc4/BC4Encoder.h" -namespace rgbcx { +namespace quicktex { class BC3Encoder : public BlockEncoderTemplate { public: @@ -47,4 +47,4 @@ class BC3Encoder : public BlockEncoderTemplate { const BC1EncoderPtr _bc1_encoder; const BC4EncoderPtr _bc4_encoder; }; -} // namespace rgbcx +} // namespace quicktex diff --git a/src/rgbcx/BC4/BC4Decoder.cpp b/quicktex/compression/bc4/BC4Decoder.cpp similarity index 85% rename from src/rgbcx/BC4/BC4Decoder.cpp rename to quicktex/compression/bc4/BC4Decoder.cpp index 11070c2..51716f8 100644 --- a/src/rgbcx/BC4/BC4Decoder.cpp +++ b/quicktex/compression/bc4/BC4Decoder.cpp @@ -22,11 +22,11 @@ #include // for array #include // for assert -#include "../BlockView.h" // for ColorBlock -#include "../ndebug.h" // for ndebug -#include "BC4Block.h" +#include "../../BlockView.h" // for ColorBlock +#include "../../formats/blocks/BC4Block.h" +#include "../../ndebug.h" // for ndebug -void rgbcx::BC4Decoder::DecodeBlock(Byte4x4 dest, BC4Block *const block) const noexcept(ndebug) { +void quicktex::BC4Decoder::DecodeBlock(Byte4x4 dest, BC4Block *const block) const noexcept(ndebug) { auto l = block->GetLowAlpha(); auto h = block->GetHighAlpha(); diff --git a/src/rgbcx/BC4/BC4Decoder.h b/quicktex/compression/bc4/BC4Decoder.h similarity index 92% rename from src/rgbcx/BC4/BC4Decoder.h rename to quicktex/compression/bc4/BC4Decoder.h index 33ea776..997e025 100644 --- a/src/rgbcx/BC4/BC4Decoder.h +++ b/quicktex/compression/bc4/BC4Decoder.h @@ -23,12 +23,12 @@ #include #include +#include "../../BlockView.h" +#include "../../formats/blocks/BC4Block.h" +#include "../../ndebug.h" #include "../BlockDecoder.h" -#include "../BlockView.h" -#include "../ndebug.h" -#include "BC4Block.h" -namespace rgbcx { +namespace quicktex { class BC4Decoder : public BlockDecoderTemplate { public: BC4Decoder(uint8_t channel = 3) { SetChannel(channel); } @@ -46,4 +46,4 @@ class BC4Decoder : public BlockDecoderTemplate { private: uint8_t _channel; }; -} // namespace rgbcx +} // namespace quicktex diff --git a/src/rgbcx/BC4/BC4Encoder.cpp b/quicktex/compression/bc4/BC4Encoder.cpp similarity index 94% rename from src/rgbcx/BC4/BC4Encoder.cpp rename to quicktex/compression/bc4/BC4Encoder.cpp index 4b42108..1eb7343 100644 --- a/src/rgbcx/BC4/BC4Encoder.cpp +++ b/quicktex/compression/bc4/BC4Encoder.cpp @@ -24,11 +24,11 @@ #include #include -#include "../BlockView.h" -#include "../ndebug.h" -#include "BC4Block.h" +#include "../../BlockView.h" +#include "../../formats/blocks/BC4Block.h" +#include "../../ndebug.h" -namespace rgbcx { +namespace quicktex { void BC4Encoder::EncodeBlock(Byte4x4 pixels, BC4Block *const dest) const noexcept(ndebug) { auto flattened = pixels.Flatten(); auto minmax = std::minmax_element(flattened.begin(), flattened.end()); @@ -70,4 +70,4 @@ void BC4Encoder::EncodeBlock(Byte4x4 pixels, BC4Block *const dest) const noexcep dest->PackSelectors(selectors); } -} // namespace rgbcx \ No newline at end of file +} // namespace quicktex \ No newline at end of file diff --git a/src/rgbcx/BC4/BC4Encoder.h b/quicktex/compression/bc4/BC4Encoder.h similarity index 92% rename from src/rgbcx/BC4/BC4Encoder.h rename to quicktex/compression/bc4/BC4Encoder.h index 4bda401..75110e5 100644 --- a/src/rgbcx/BC4/BC4Encoder.h +++ b/quicktex/compression/bc4/BC4Encoder.h @@ -23,12 +23,12 @@ #include #include +#include "../../BlockView.h" +#include "../../formats/blocks/BC4Block.h" +#include "../../ndebug.h" #include "../BlockEncoder.h" -#include "../BlockView.h" -#include "../ndebug.h" -#include "BC4Block.h" -namespace rgbcx { +namespace quicktex { class BC4Encoder : public BlockEncoderTemplate { public: @@ -47,4 +47,4 @@ class BC4Encoder : public BlockEncoderTemplate { private: uint8_t _channel; }; -} // namespace rgbcx +} // namespace quicktex diff --git a/src/rgbcx/BC5/BC5Decoder.cpp b/quicktex/compression/bc5/BC5Decoder.cpp similarity index 88% rename from src/rgbcx/BC5/BC5Decoder.cpp rename to quicktex/compression/bc5/BC5Decoder.cpp index 41b232f..1df8dd8 100644 --- a/src/rgbcx/BC5/BC5Decoder.cpp +++ b/quicktex/compression/bc5/BC5Decoder.cpp @@ -19,14 +19,14 @@ #include "BC5Decoder.h" -#include "../BlockView.h" -#include "../ndebug.h" -#include "BC5Block.h" +#include "../../BlockView.h" +#include "../../ndebug.h" +#include "../../formats/blocks/BC5Block.h" -namespace rgbcx { +namespace quicktex { void BC5Decoder::DecodeBlock(Color4x4 dest, BC5Block *const block) const noexcept(ndebug) { _chan0_decoder->DecodeBlock(dest, &block->chan0_block); _chan1_decoder->DecodeBlock(dest, &block->chan1_block); } -} // namespace rgbcx \ No newline at end of file +} // namespace quicktex \ No newline at end of file diff --git a/src/rgbcx/BC5/BC5Decoder.h b/quicktex/compression/bc5/BC5Decoder.h similarity index 92% rename from src/rgbcx/BC5/BC5Decoder.h rename to quicktex/compression/bc5/BC5Decoder.h index 3ee8814..cb982e8 100644 --- a/src/rgbcx/BC5/BC5Decoder.h +++ b/quicktex/compression/bc5/BC5Decoder.h @@ -24,13 +24,13 @@ #include #include -#include "../BC4/BC4Decoder.h" +#include "../../BlockView.h" +#include "../../ndebug.h" +#include "../bc4/BC4Decoder.h" #include "../BlockDecoder.h" -#include "../BlockView.h" -#include "../ndebug.h" -#include "BC5Block.h" +#include "../../formats/blocks/BC5Block.h" -namespace rgbcx { +namespace quicktex { class BC5Decoder : public BlockDecoderTemplate { public: using ChannelPair = std::tuple; @@ -54,4 +54,4 @@ class BC5Decoder : public BlockDecoderTemplate { const BC4DecoderPtr _chan0_decoder; const BC4DecoderPtr _chan1_decoder; }; -} // namespace rgbcx +} // namespace quicktex diff --git a/src/rgbcx/BC5/BC5Encoder.cpp b/quicktex/compression/bc5/BC5Encoder.cpp similarity index 96% rename from src/rgbcx/BC5/BC5Encoder.cpp rename to quicktex/compression/bc5/BC5Encoder.cpp index b20521c..f384b9f 100644 --- a/src/rgbcx/BC5/BC5Encoder.cpp +++ b/quicktex/compression/bc5/BC5Encoder.cpp @@ -19,9 +19,9 @@ #include "BC5Encoder.h" -namespace rgbcx { +namespace quicktex { void BC5Encoder::EncodeBlock(Color4x4 pixels, BC5Block *dest) const { _chan0_encoder->EncodeBlock(pixels, &(dest->chan0_block)); _chan1_encoder->EncodeBlock(pixels, &(dest->chan1_block)); } -} // namespace rgbcx \ No newline at end of file +} // namespace quicktex \ No newline at end of file diff --git a/src/rgbcx/BC5/BC5Encoder.h b/quicktex/compression/bc5/BC5Encoder.h similarity index 92% rename from src/rgbcx/BC5/BC5Encoder.h rename to quicktex/compression/bc5/BC5Encoder.h index fb2de76..2b6c1b0 100644 --- a/src/rgbcx/BC5/BC5Encoder.h +++ b/quicktex/compression/bc5/BC5Encoder.h @@ -24,13 +24,13 @@ #include #include -#include "../BC4/BC4Encoder.h" +#include "../../BlockView.h" +#include "../../ndebug.h" +#include "../bc4/BC4Encoder.h" #include "../BlockEncoder.h" -#include "../BlockView.h" -#include "../ndebug.h" -#include "BC5Block.h" +#include "../../formats/blocks/BC5Block.h" -namespace rgbcx { +namespace quicktex { class BC5Encoder : public BlockEncoderTemplate { public: using ChannelPair = std::tuple; @@ -54,4 +54,4 @@ class BC5Encoder : public BlockEncoderTemplate { const BC4EncoderPtr _chan0_encoder; const BC4EncoderPtr _chan1_encoder; }; -} // namespace rgbcx +} // namespace quicktex diff --git a/src/rgbcx/bindings/Decoders.cpp b/quicktex/compression/bindings/Decoders.cpp similarity index 95% rename from src/rgbcx/bindings/Decoders.cpp rename to quicktex/compression/bindings/Decoders.cpp index d9201e1..33a1891 100644 --- a/src/rgbcx/bindings/Decoders.cpp +++ b/quicktex/compression/bindings/Decoders.cpp @@ -19,20 +19,20 @@ #include +#include #include #include #include #include -#include -#include "../BC1/BC1Decoder.h" -#include "../BC3/BC3Decoder.h" -#include "../BC4/BC4Decoder.h" -#include "../BC5/BC5Decoder.h" #include "../BlockDecoder.h" +#include "../bc1/BC1Decoder.h" +#include "../bc3/BC3Decoder.h" +#include "../bc4/BC4Decoder.h" +#include "../bc5/BC5Decoder.h" namespace py = pybind11; -namespace rgbcx::bindings { +namespace quicktex::bindings { py::bytes DecodeImage(const BlockDecoder &self, py::bytes encoded, unsigned image_width, unsigned image_height) { if (image_width % self.BlockWidth() != 0) throw std::invalid_argument("Width is not an even multiple of block_width"); @@ -92,4 +92,4 @@ void InitDecoders(py::module_ &m) { bc5_decoder.def_property_readonly("bc4_decoders", &BC5Decoder::GetBC4Decoders); } -} // namespace rgbcx::bindings \ No newline at end of file +} // namespace quicktex::bindings \ No newline at end of file diff --git a/src/rgbcx/bindings/Encoders.cpp b/quicktex/compression/bindings/Encoders.cpp similarity index 96% rename from src/rgbcx/bindings/Encoders.cpp rename to quicktex/compression/bindings/Encoders.cpp index f9dc3bc..d0dffa6 100644 --- a/src/rgbcx/bindings/Encoders.cpp +++ b/quicktex/compression/bindings/Encoders.cpp @@ -24,18 +24,19 @@ #include #include -#include "../BC1/BC1Encoder.h" -#include "../BC3/BC3Encoder.h" -#include "../BC5/BC5Encoder.h" +#include "../../Color.h" +#include "../../Interpolator.h" #include "../BlockEncoder.h" -#include "../Color.h" -#include "../Interpolator.h" +#include "../bc1/BC1Encoder.h" +#include "../bc3/BC3Encoder.h" +#include "../bc4/BC4Encoder.h" +#include "../bc5/BC5Encoder.h" #define STRINGIFY(x) #x #define MACRO_STRINGIFY(x) STRINGIFY(x) namespace py = pybind11; -namespace rgbcx::bindings { +namespace quicktex::bindings { py::bytes EncodeImage(const BlockEncoder &self, py::bytes decoded, unsigned image_width, unsigned image_height) { if (image_width % self.BlockWidth() != 0) throw std::invalid_argument("Width is not an even multiple of block_width"); @@ -132,4 +133,4 @@ void InitEncoders(py::module_ &m) { bc5_encoder.def_property("channels", &BC5Encoder::GetChannels, &BC5Encoder::SetChannels); bc5_encoder.def_property_readonly("bc4_decoders", &BC5Encoder::GetBC4Encoders); } -} // namespace rgbcx::bindings \ No newline at end of file +} // namespace quicktex::bindings \ No newline at end of file diff --git a/src/rgbcx/BC1/BC1Block.h b/quicktex/formats/blocks/BC1Block.h similarity index 97% rename from src/rgbcx/BC1/BC1Block.h rename to quicktex/formats/blocks/BC1Block.h index 6e14739..4adc4ba 100644 --- a/src/rgbcx/BC1/BC1Block.h +++ b/quicktex/formats/blocks/BC1Block.h @@ -24,10 +24,10 @@ #include #include -#include "../Color.h" -#include "../util.h" +#include "../../Color.h" +#include "../../util.h" -namespace rgbcx { +namespace quicktex { #pragma pack(push, 1) class BC1Block { @@ -82,4 +82,4 @@ class BC1Block { std::array selectors; }; #pragma pack(pop) -} // namespace rgbcx \ No newline at end of file +} // namespace quicktex \ No newline at end of file diff --git a/src/rgbcx/BC3/BC3Block.h b/quicktex/formats/blocks/BC3Block.h similarity index 91% rename from src/rgbcx/BC3/BC3Block.h rename to quicktex/formats/blocks/BC3Block.h index 1032e26..5e36a27 100644 --- a/src/rgbcx/BC3/BC3Block.h +++ b/quicktex/formats/blocks/BC3Block.h @@ -19,10 +19,10 @@ #pragma once -#include "../BC1/BC1Block.h" -#include "../BC4/BC4Block.h" +#include "BC1Block.h" +#include "BC4Block.h" -namespace rgbcx { +namespace quicktex { #pragma pack(push, 1) class BC3Block { @@ -31,4 +31,4 @@ class BC3Block { BC1Block color_block; }; #pragma pack(pop) -} // namespace rgbcx \ No newline at end of file +} // namespace quicktex \ No newline at end of file diff --git a/src/rgbcx/BC4/BC4Block.h b/quicktex/formats/blocks/BC4Block.h similarity index 97% rename from src/rgbcx/BC4/BC4Block.h rename to quicktex/formats/blocks/BC4Block.h index 3ac60cc..a20c4cd 100644 --- a/src/rgbcx/BC4/BC4Block.h +++ b/quicktex/formats/blocks/BC4Block.h @@ -24,11 +24,11 @@ #include #include -#include "../BC1/BC1Block.h" -#include "../Color.h" -#include "../util.h" +#include "../../Color.h" +#include "../../util.h" +#include "BC1Block.h" -namespace rgbcx { +namespace quicktex { #pragma pack(push, 1) class BC4Block { @@ -119,4 +119,4 @@ class BC4Block { std::array selectors; }; #pragma pack(pop) -} // namespace rgbcx +} // namespace quicktex diff --git a/src/rgbcx/BC5/BC5Block.h b/quicktex/formats/blocks/BC5Block.h similarity index 93% rename from src/rgbcx/BC5/BC5Block.h rename to quicktex/formats/blocks/BC5Block.h index e9b886a..d4e5fcb 100644 --- a/src/rgbcx/BC5/BC5Block.h +++ b/quicktex/formats/blocks/BC5Block.h @@ -19,9 +19,9 @@ #pragma once -#include "../BC4/BC4Block.h" +#include "BC4Block.h" -namespace rgbcx { +namespace quicktex { #pragma pack(push, 1) class BC5Block { @@ -30,4 +30,4 @@ class BC5Block { BC4Block chan1_block; }; #pragma pack(pop) -} // namespace rgbcx \ No newline at end of file +} // namespace quicktex \ No newline at end of file diff --git a/src/rgbcx/ndebug.h b/quicktex/ndebug.h similarity index 100% rename from src/rgbcx/ndebug.h rename to quicktex/ndebug.h diff --git a/src/rgbcx/util.h b/quicktex/util.h similarity index 100% rename from src/rgbcx/util.h rename to quicktex/util.h diff --git a/setup.py b/setup.py index 5a90d45..022efa1 100644 --- a/setup.py +++ b/setup.py @@ -102,20 +102,21 @@ class CMakeBuild(build_ext): # The information here can also be placed in setup.cfg - better separation of # logic and declaration, and simpler if you include description/version in a file. setup( - name="rgbcx", + name="quicktex", version="0.0.1", author="Andrew Cassidy", author_email="drewcassidy@me.com", - description="", + description="A fast block compression library for python", long_description="", - ext_modules=[CMakeExtension("_rgbcx")], + python_requires=">=3.6", + ext_modules=[CMakeExtension("_quicktex")], cmdclass={"build_ext": CMakeBuild}, - packages=find_packages('src'), - package_dir={'': 'src'}, + packages=find_packages('.'), + package_dir={'': '.'}, install_requires=["Pillow"], extras_require={ "tests": ["nose", "parameterized"], - "docs": ["sphinx"], + "docs": ["sphinx", "myst-parser", "sphinx-rtd-theme"], }, zip_safe=False, ) diff --git a/src/rgbcx/__init__.py b/src/rgbcx/__init__.py deleted file mode 100644 index 094a8f4..0000000 --- a/src/rgbcx/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from _rgbcx import * diff --git a/src/rgbcx/rgbcxDecoders.h b/src/rgbcx/rgbcxDecoders.h deleted file mode 100644 index 9b33a23..0000000 --- a/src/rgbcx/rgbcxDecoders.h +++ /dev/null @@ -1,25 +0,0 @@ -/* Python-rgbcx Texture Compression Library - Copyright (C) 2021 Andrew Cassidy - Partially derived from rgbcx.h written by Richard Geldreich - 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 . - */ - -#pragma once - -#include "BC1/BC1Decoder.h" -#include "BC3/BC3Decoder.h" -#include "BC4/BC4Decoder.h" -#include "BC5/BC5Decoder.h"