Skip to content

Commit

Permalink
Updated Windows project
Browse files Browse the repository at this point in the history
  • Loading branch information
MCJack123 committed Jun 13, 2022
1 parent 61be778 commit 20ebd78
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 30 deletions.
15 changes: 12 additions & 3 deletions sanjuuni.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand All @@ -141,15 +142,23 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="sanjuuni.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="32vid-player.lua" />
<None Include="raw-player.lua" />
<None Include="README.md" />
<None Include="vcpkg.json" />
<None Include="websocket-player.lua" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\cc-pixel.cpp" />
<ClCompile Include="src\generator.cpp" />
<ClCompile Include="src\octree.cpp" />
<ClCompile Include="src\quantize.cpp" />
<ClCompile Include="src\sanjuuni.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\sanjuuni.hpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
30 changes: 25 additions & 5 deletions sanjuuni.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="sanjuuni.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="32vid-player.lua">
<Filter>Resource Files</Filter>
Expand All @@ -32,5 +27,30 @@
<None Include="websocket-player.lua">
<Filter>Resource Files</Filter>
</None>
<None Include="raw-player.lua">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\cc-pixel.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\generator.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\octree.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\quantize.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\sanjuuni.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\sanjuuni.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
18 changes: 18 additions & 0 deletions src/octree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ Modified by JackMacWindows for sanjuuni.

#include "sanjuuni.hpp"

struct octree_node {
uint32_t r, g, b;
uint32_t counter;
int leaf;
int leaf_parent;
struct octree_node* subnodes[8];
int palette_entry;
struct octree_node* prev;
struct octree_node* next;
struct octree_node* parent;
};

struct octree_tree {
struct octree_node* root;
uint32_t number_of_leaves;
struct octree_node* leaves_parents;
};

#define BITS_USED 8

static struct octree_node* octree_create_node(struct octree_node* parent) {
Expand Down
9 changes: 7 additions & 2 deletions src/sanjuuni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ int main(int argc, const char * argv[]) {
std::string input, output, subtitle;
bool useDefaultPalette = false, noDither = false, useOctree = false, useKmeans = false;
OutputType mode = OutputType::Default;
int compression = VID32_FLAG_VIDEO_COMPRESSION_DEFLATE;
int compression = VID32_FLAG_VIDEO_COMPRESSION_CUSTOM;
int port = 80, width = -1, height = -1, zlibCompression = 5;
try {
for (int i = 1; i < argc; i++) {
Expand Down Expand Up @@ -496,10 +496,14 @@ int main(int argc, const char * argv[]) {
}

if (useDFPWM) {
#ifdef AV_CODEC_ID_DFPWM
if (avcodec_version() < AV_VERSION_INT(59, 22, 0) || avformat_version() < AV_VERSION_INT(59, 18, 0)) {
#endif
std::cerr << "DFPWM output requires FFmpeg 5.1 or later\n";
return 2;
#ifdef AV_CODEC_ID_DFPWM
}
#endif
}

AVFormatContext * format_ctx = NULL;
Expand Down Expand Up @@ -583,6 +587,7 @@ int main(int argc, const char * argv[]) {
}
}
// Open DFPWM encoder if required
#ifdef AV_CODEC_ID_DFPWM
if (useDFPWM) {
if (!(dfpwm_codec = avcodec_find_encoder(AV_CODEC_ID_DFPWM))) {
std::cerr << "Could not find DFPWM codec\n";
Expand Down Expand Up @@ -611,6 +616,7 @@ int main(int argc, const char * argv[]) {
return error;
}
}
#endif
// Initialize packets/frames
AVPacket * packet = av_packet_alloc(), * dfpwm_packet = useDFPWM ? av_packet_alloc() : NULL;
AVFrame * frame = av_frame_alloc();
Expand Down Expand Up @@ -732,7 +738,6 @@ int main(int argc, const char * argv[]) {
rs.at(y, x) = {data[y*width*3+x*3], data[y*width*3+x*3+1], data[y*width*3+x*3+2]};
delete[] data;
std::vector<Vec3b> palette;
octree_tree tree;
if (useDefaultPalette) palette = defaultPalette;
else if (useOctree) palette = reducePalette_octree(rs, 16);
else if (useKmeans) palette = reducePalette_kMeans(rs, 16);
Expand Down
19 changes: 0 additions & 19 deletions src/sanjuuni.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,25 +183,6 @@ typedef vector2d<Vec3b> Mat;
template<typename T> inline T min(T a, T b) {return a < b ? a : b;}
template<typename T> inline T max(T a, T b) {return a > b ? a : b;}

/* Octree structure definitions. */
struct octree_node {
uint32_t r, g, b;
uint32_t counter;
int leaf;
int leaf_parent;
struct octree_node* subnodes[8];
int palette_entry;
struct octree_node* prev;
struct octree_node* next;
struct octree_node* parent;
};

struct octree_tree {
struct octree_node* root;
uint32_t number_of_leaves;
struct octree_node* leaves_parents;
};

/* 32vid types and constants. */
#define VID32_FLAG_VIDEO_COMPRESSION_NONE 0x0000
#define VID32_FLAG_VIDEO_COMPRESSION_LZW 0x0001
Expand Down
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version-string": "1.0",
"description": "Converts images and videos into a format that can be displayed in ComputerCraft.",
"dependencies": [
"openssl",
{

"name": "poco",
"default-features": true,
"features": ["netssl"]
Expand Down

0 comments on commit 20ebd78

Please sign in to comment.