forked from Nominom/BCnEncoder.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Some more code style changes, more raw api's and duplicate encoder co…
…de removed
- Loading branch information
Showing
35 changed files
with
552 additions
and
451 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# EditorConfig helps developers define and maintain consistent | ||
# coding styles between different editors and IDEs | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
|
||
[*] | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
[*.{diff,md}] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using BCnEncoder.Shared; | ||
|
||
namespace BCnEncoder.Encoder | ||
{ | ||
internal abstract class BaseBcBlockEncoder<T> : IBcBlockEncoder where T : unmanaged | ||
{ | ||
public byte[] Encode(RawBlock4X4Rgba32[] blocks, int blockWidth, int blockHeight, CompressionQuality quality, bool parallel) | ||
{ | ||
var outputData = new byte[blockWidth * blockHeight * Unsafe.SizeOf<T>()]; | ||
var outputBlocks = MemoryMarshal.Cast<byte, T>(outputData); | ||
|
||
if (parallel) | ||
{ | ||
Parallel.For(0, blocks.Length, i => | ||
{ | ||
var outputBlocks = MemoryMarshal.Cast<byte, T>(outputData); | ||
outputBlocks[i] = EncodeBlock(blocks[i], quality); | ||
}); | ||
} | ||
else | ||
{ | ||
for (var i = 0; i < blocks.Length; i++) | ||
{ | ||
outputBlocks[i] = EncodeBlock(blocks[i], quality); | ||
} | ||
} | ||
|
||
return outputData; | ||
} | ||
|
||
public abstract GlInternalFormat GetInternalFormat(); | ||
public abstract GlFormat GetBaseInternalFormat(); | ||
public abstract DxgiFormat GetDxgiFormat(); | ||
|
||
protected abstract T EncodeBlock(RawBlock4X4Rgba32 block, CompressionQuality quality); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.