mirror of
https://github.com/aaru-dps/Aaru.Compression.Native.git
synced 2025-12-16 19:24:31 +00:00
Compare commits
12 Commits
v6.0.0-alp
...
v6.0.0-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
b3474d88f6
|
|||
|
9ed17b84c3
|
|||
|
8ba4d258bf
|
|||
|
9db2e3212d
|
|||
|
6637fb486f
|
|||
|
17d4446fb1
|
|||
|
b285754ad4
|
|||
|
36102254a5
|
|||
|
c215979aaf
|
|||
|
e948c31fba
|
|||
|
123879fc7c
|
|||
|
47e6c8e50f
|
144
.clang-format
144
.clang-format
@@ -1,94 +1,92 @@
|
||||
---
|
||||
Language: Cpp
|
||||
AccessModifierOffset: -2
|
||||
Language: Cpp
|
||||
# BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: true
|
||||
AlignConsecutiveDeclarations: true
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: true
|
||||
AlignArrayOfStructures: Right
|
||||
AlignConsecutiveAssignments: AcrossComments
|
||||
AlignConsecutiveBitFields: true
|
||||
AlignConsecutiveDeclarations: AcrossComments
|
||||
AlignConsecutiveMacros: AcrossComments
|
||||
AlignConsecutiveShortCaseStatements:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: true
|
||||
AlignCaseColons: false
|
||||
AlignEscapedNewlines: Left
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: true
|
||||
AllowShortCaseLabelsOnASingleLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortBlocksOnASingleLine: Always
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortEnumsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: Always
|
||||
AllowShortIfStatementsOnASingleLine: true
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
BraceWrapping:
|
||||
AfterClass: true
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BitFieldColonSpacing: Both
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: true
|
||||
AfterClass: false
|
||||
AfterControlStatement: true
|
||||
AfterEnum: true
|
||||
AfterFunction: true
|
||||
AfterNamespace: true
|
||||
AfterObjCDeclaration: true
|
||||
AfterStruct: true
|
||||
AfterUnion: true
|
||||
AfterEnum: true
|
||||
AfterFunction: true
|
||||
AfterNamespace: true
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: true
|
||||
AfterUnion: true
|
||||
AfterExternBlock: true
|
||||
BeforeCatch: true
|
||||
BeforeElse: true
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: false
|
||||
SplitEmptyNamespace: false
|
||||
BeforeCatch: true
|
||||
BeforeElse: true
|
||||
IndentBraces: false
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Allman
|
||||
BreakBeforeInheritanceComma: false
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 120
|
||||
ColumnLimit: 120
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
DisableFormat: false
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IncludeBlocks: Regroup
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '^(<winsock2.h>)'
|
||||
Priority: -3
|
||||
SortPriority: -4
|
||||
- Regex: '^(<windows.h>)'
|
||||
Priority: -3
|
||||
SortPriority: -3
|
||||
- Regex: '^(<.*)'
|
||||
Priority: -2
|
||||
SortPriority: -2
|
||||
- Regex: '^("(win32|windows))'
|
||||
Priority: 1
|
||||
SortPriority: -1
|
||||
- Regex: '^("library.h")'
|
||||
Priority: 0
|
||||
SortPriority: -1
|
||||
- Regex: '.*'
|
||||
Priority: 0
|
||||
SortPriority: 0
|
||||
IncludeIsMainRegex: '(Test)?$'
|
||||
- Regex: '^<ext/.*\.h>'
|
||||
Priority: 2
|
||||
- Regex: '^<.*\.h>'
|
||||
Priority: 1
|
||||
- Regex: '^<.*'
|
||||
Priority: 2
|
||||
- Regex: 'library\.h'
|
||||
Priority: 2
|
||||
- Regex: '.*'
|
||||
Priority: 3
|
||||
IndentCaseLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: true
|
||||
JavaScriptQuotes: Double
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
LineEnding: LF
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: All
|
||||
ObjCBlockIndentWidth: 4
|
||||
NamespaceIndentation: None
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakAssignment: 2
|
||||
@@ -98,23 +96,21 @@ PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
PointerAlignment: Left
|
||||
ReflowComments: true
|
||||
SortIncludes: true
|
||||
SortUsingDeclarations: true
|
||||
PointerAlignment: Right
|
||||
ReflowComments: true
|
||||
SeparateDefinitionBlocks: Always
|
||||
SortIncludes: CaseInsensitive
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterTemplateKeyword: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeParens: Never
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
SpacesInContainerLiterals: false
|
||||
SpacesBeforeTrailingComments: 2
|
||||
SpacesInAngles: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Cpp11
|
||||
TabWidth: 8
|
||||
UseTab: Never
|
||||
...
|
||||
|
||||
Standard: Latest
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
||||
|
||||
2086
.editorconfig
2086
.editorconfig
File diff suppressed because it is too large
Load Diff
115
.idea/codeStyles/Project.xml
generated
115
.idea/codeStyles/Project.xml
generated
@@ -24,6 +24,105 @@
|
||||
<option name="TEMPLATE_CALL_ARGUMENTS_ALIGN_MULTILINE_PARS" value="true" />
|
||||
<option name="ALIGN_DICTIONARY_PAIR_VALUES" value="true" />
|
||||
</Objective-C>
|
||||
<RiderCodeStyleSettings>
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppClangFormat/EnableClangFormatSupport/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/EditorConfig/EnableClangFormatSupport/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_BINARY_EXPRESSIONS_CHAIN/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_CALLS_CHAIN/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXPRESSION/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_FOR_STMT/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTIPLE_DECLARATION/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_TERNARY/@EntryValue" value="ALIGN_ALL" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_CLASS_DEFINITION/@EntryValue" value="1" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_BLANK_LINES_IN_DECLARATIONS/@EntryValue" value="2" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_BLANK_LINES_IN_CODE/@EntryValue" value="2" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_USER_LINEBREAKS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CASE_FROM_SWITCH/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_COMMENT/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INT_ALIGN_EQ/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SIMPLE_BLOCK_STYLE/@EntryValue" value="DO_NOT_CHANGE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COMMA_IN_TEMPLATE_ARGS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COMMA_IN_TEMPLATE_PARAMS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_FOR_SEMICOLON/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_FOR_SEMICOLON/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_UNARY_OPERATOR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_ARRAY_ACCESS_BRACKETS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_CAST_EXPRESSION_PARENTHESES/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_INITIALIZER_BRACES/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_METHOD_PARENTHESES/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_INITIALIZER_BRACES/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPECIAL_ELSE_IF_TREATMENT/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_CAST_EXPRESSION_PARENTHESES/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_BINARY_OPSIGN/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_TERNARY_OPSIGNS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TYPE_DECLARATION_BRACES/@EntryValue" value="NEXT_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/OTHER_BRACES/@EntryValue" value="NEXT_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CASE_BLOCK_BRACES/@EntryValue" value="NEXT_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_FUNCTION_DECLARATION/@EntryValue" value="1" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_FUNCTION_DEFINITION/@EntryValue" value="1" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_WHILE_ON_NEW_LINE/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_ELSE_ON_NEW_LINE/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_CATCH_ON_NEW_LINE/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_INDENTATION/@EntryValue" value="All" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_ARGUMENT/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXTENDS_LIST/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_PARAMETER/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_ARGUMENT/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_PARAMETER/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_DECLARATIONS/@EntryValue" value="0" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_ACCESS_SPECIFIERS_FROM_CLASS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CLASS_MEMBERS_FROM_ACCESS_SPECIFIERS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LINE_BREAK_AFTER_COLON_IN_MEMBER_INITIALIZER_LISTS/@EntryValue" value="ON_SINGLE_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/MEMBER_INITIALIZER_LIST_STYLE/@EntryValue" value="DO_NOT_CHANGE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/PLACE_NAMESPACE_DEFINITIONS_ON_SAME_LINE/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COLON_IN_BITFIELD_DECLARATOR/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_COLON_IN_BITFIELD_DECLARATOR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_EXTENDS_COLON/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_EXTENDS_COLON/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_FOR_COLON/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_FOR_COLON/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_DATA_MEMBER/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_DATA_MEMBERS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_METHOD/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_NESTED_DECLARATOR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_DATA_MEMBER/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_DATA_MEMBERS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_METHOD/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_ABSTRACT_DECL/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_DATA_MEMBER/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_DATA_MEMBERS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_METHOD/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_ABSTRACT_DECL/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_DATA_MEMBER/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_DATA_MEMBERS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_METHOD/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_TEMPLATE_ARGS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BETWEEN_CLOSING_ANGLE_BRACKETS_IN_TEMPLATE_ARGS/@EntryValue" value="true" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_TEMPLATE_ARGS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_DECLARATION_PARENTHESES/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_BLOCKS/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_INVOCATION_LPAR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_INVOCATION_LPAR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_INVOCATION_RPAR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_DECLARATION_LPAR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_DECLARATION_LPAR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_DECLARATION_RPAR/@EntryValue" value="false" type="bool" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_ARGUMENTS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_PARAMETERS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BREAK_TEMPLATE_DECLARATION/@EntryValue" value="LINE_BREAK" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_DECLARATION_BRACES/@EntryValue" value="NEXT_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/FREE_BLOCK_BRACES/@EntryValue" value="NEXT_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INVOCABLE_DECLARATION_BRACES/@EntryValue" value="NEXT_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue" value="NEXT_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INITIALIZER_BRACES/@EntryValue" value="NEXT_LINE" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_STYLE/@EntryValue" value="Space" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_SIZE/@EntryValue" value="4" type="int" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CONTINUOUS_LINE_INDENT/@EntryValue" value="Double" type="string" />
|
||||
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TAB_WIDTH/@EntryValue" value="4" type="int" />
|
||||
</RiderCodeStyleSettings>
|
||||
<Shell_Script>
|
||||
<option name="SWITCH_CASES_INDENTED" value="true" />
|
||||
<option name="REDIRECT_FOLLOWED_BY_SPACE" value="true" />
|
||||
@@ -36,22 +135,6 @@
|
||||
<option name="SPACE_BEFORE_FOR_PARENTHESES" value="false" />
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="ObjectiveC">
|
||||
<option name="BRACE_STYLE" value="2" />
|
||||
<option name="CLASS_BRACE_STYLE" value="2" />
|
||||
<option name="ELSE_ON_NEW_LINE" value="true" />
|
||||
<option name="WHILE_ON_NEW_LINE" value="true" />
|
||||
<option name="CATCH_ON_NEW_LINE" value="true" />
|
||||
<option name="FINALLY_ON_NEW_LINE" value="true" />
|
||||
<option name="ALIGN_MULTILINE_CHAINED_METHODS" value="true" />
|
||||
<option name="ALIGN_GROUP_FIELD_DECLARATIONS" value="true" />
|
||||
<option name="SPACE_AFTER_TYPE_CAST" value="false" />
|
||||
<option name="SPACE_BEFORE_IF_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_WHILE_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_FOR_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_CATCH_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_SWITCH_PARENTHESES" value="false" />
|
||||
<option name="SPACE_BEFORE_SYNCHRONIZED_PARENTHESES" value="false" />
|
||||
<option name="METHOD_CALL_CHAIN_WRAP" value="1" />
|
||||
<indentOptions>
|
||||
<option name="LABEL_INDENT_ABSOLUTE" value="true" />
|
||||
</indentOptions>
|
||||
|
||||
40
3rdparty/bzip2.cmake
vendored
40
3rdparty/bzip2.cmake
vendored
@@ -17,28 +17,28 @@ message(STATUS "BZIP2 VERSION: ${BZ_VERSION}")
|
||||
|
||||
# Do not disable assertions based on CMAKE_BUILD_TYPE.
|
||||
foreach(_build_type Release MinSizeRel RelWithDebInfo)
|
||||
foreach(_lang C)
|
||||
string(TOUPPER CMAKE_${_lang}_FLAGS_${_build_type} _var)
|
||||
string(REGEX REPLACE "(^|)[/-]D *NDEBUG($|)" " " ${_var} "${${_var}}")
|
||||
endforeach()
|
||||
foreach(_lang C)
|
||||
string(TOUPPER CMAKE_${_lang}_FLAGS_${_build_type} _var)
|
||||
string(REGEX REPLACE "(^|)[/-]D *NDEBUG($|)" " " ${_var} "${${_var}}")
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
# Support the latest c++ standard available.
|
||||
include(ExtractValidFlags)
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the build type" FORCE)
|
||||
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the build type" FORCE)
|
||||
|
||||
# Include "None" as option to disable any additional (optimization) flags,
|
||||
# relying on just CMAKE_C_FLAGS and CMAKE_CXX_FLAGS (which are empty by
|
||||
# default). These strings are presented in cmake-gui.
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
|
||||
None Debug Release MinSizeRel RelWithDebInfo)
|
||||
# Include "None" as option to disable any additional (optimization) flags,
|
||||
# relying on just CMAKE_C_FLAGS and CMAKE_CXX_FLAGS (which are empty by
|
||||
# default). These strings are presented in cmake-gui.
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
|
||||
None Debug Release MinSizeRel RelWithDebInfo)
|
||||
endif()
|
||||
|
||||
# Always use '-fPIC'/'-fPIE' option, except when using MingW to compile for WoA.
|
||||
if(NOT "${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW" OR (NOT "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "aarch64" AND NOT "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm"))
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
endif()
|
||||
|
||||
# Checks for header files.
|
||||
@@ -60,13 +60,13 @@ include(CheckTypeSize)
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
# AC_TYPE_SIZE_T
|
||||
if(NOT "${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW" OR (NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm" AND NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64"))
|
||||
check_type_size("ssize_t" SIZEOF_SSIZE_T)
|
||||
check_type_size("ssize_t" SIZEOF_SSIZE_T)
|
||||
endif()
|
||||
|
||||
if(NOT SIZEOF_SSIZE_T)
|
||||
# ssize_t is a signed type in POSIX storing at least -1.
|
||||
# Set it to "int" to match the behavior of AC_TYPE_SSIZE_T (autotools).
|
||||
set(ssize_t int)
|
||||
# ssize_t is a signed type in POSIX storing at least -1.
|
||||
# Set it to "int" to match the behavior of AC_TYPE_SSIZE_T (autotools).
|
||||
set(ssize_t int)
|
||||
endif()
|
||||
|
||||
include(CheckStructHasMember)
|
||||
@@ -82,11 +82,11 @@ include(CheckSymbolExists)
|
||||
# XXX does this correctly detect initgroups (un)availability on cygwin?
|
||||
check_symbol_exists(initgroups grp.h HAVE_DECL_INITGROUPS)
|
||||
if(NOT HAVE_DECL_INITGROUPS AND HAVE_UNISTD_H)
|
||||
# FreeBSD declares initgroups() in unistd.h
|
||||
check_symbol_exists(initgroups unistd.h HAVE_DECL_INITGROUPS2)
|
||||
if(HAVE_DECL_INITGROUPS2)
|
||||
set(HAVE_DECL_INITGROUPS 1)
|
||||
endif()
|
||||
# FreeBSD declares initgroups() in unistd.h
|
||||
check_symbol_exists(initgroups unistd.h HAVE_DECL_INITGROUPS2)
|
||||
if(HAVE_DECL_INITGROUPS2)
|
||||
set(HAVE_DECL_INITGROUPS 1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# The build targets.
|
||||
|
||||
62
3rdparty/flac.cmake
vendored
62
3rdparty/flac.cmake
vendored
@@ -51,13 +51,13 @@ check_include_file("arm_neon.h" FLAC__HAS_NEONINTRIN)
|
||||
check_include_file("semaphore.h" HAVE_SEMAPHORE_H)
|
||||
|
||||
if(NOT HAVE_STDINT_H OR NOT HAVE_STDBOOL_H)
|
||||
message(SEND_ERROR "Header stdint.h and/or stdbool.h not found")
|
||||
message(SEND_ERROR "Header stdint.h and/or stdbool.h not found")
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
check_include_file("intrin.h" FLAC__HAS_X86INTRIN)
|
||||
check_include_file("intrin.h" FLAC__HAS_X86INTRIN)
|
||||
else()
|
||||
check_include_file("x86intrin.h" FLAC__HAS_X86INTRIN)
|
||||
check_include_file("x86intrin.h" FLAC__HAS_X86INTRIN)
|
||||
endif()
|
||||
|
||||
check_function_exists(fseeko HAVE_FSEEKO)
|
||||
@@ -66,14 +66,14 @@ check_c_source_compiles("int main() { return __builtin_bswap16 (0) ; }" HAVE_BSW
|
||||
check_c_source_compiles("int main() { return __builtin_bswap32 (0) ; }" HAVE_BSWAP32)
|
||||
|
||||
if(NOT "${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW" OR (NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm" AND NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64"))
|
||||
test_big_endian(CPU_IS_BIG_ENDIAN)
|
||||
test_big_endian(CPU_IS_BIG_ENDIAN)
|
||||
endif()
|
||||
|
||||
check_c_compiler_flag(-mstackrealign HAVE_STACKREALIGN_FLAG)
|
||||
|
||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "i686" AND HAVE_STACKREALIGN_FLAG)
|
||||
add_compile_options(-mstackrealign)
|
||||
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-mstackrealign>)
|
||||
add_compile_options(-mstackrealign)
|
||||
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-mstackrealign>)
|
||||
endif()
|
||||
|
||||
include_directories("3rdparty/flac/include")
|
||||
@@ -82,9 +82,9 @@ include_directories("${CMAKE_CURRENT_BINARY_DIR}/3rdparty/flac")
|
||||
add_definitions(-DHAVE_CONFIG_H)
|
||||
|
||||
if(MSVC)
|
||||
add_definitions(
|
||||
-D_CRT_SECURE_NO_WARNINGS
|
||||
-D_USE_MATH_DEFINES)
|
||||
add_definitions(
|
||||
-D_CRT_SECURE_NO_WARNINGS
|
||||
-D_USE_MATH_DEFINES)
|
||||
endif()
|
||||
|
||||
option(WITH_ASM "Use any assembly optimization routines" ON)
|
||||
@@ -101,36 +101,36 @@ include(CheckA64NEON)
|
||||
|
||||
check_cpu_arch_x64(FLAC__CPU_X86_64)
|
||||
if(NOT FLAC__CPU_X86_64)
|
||||
check_cpu_arch_x86(FLAC__CPU_IA32)
|
||||
check_cpu_arch_x86(FLAC__CPU_IA32)
|
||||
endif()
|
||||
|
||||
if(FLAC__CPU_X86_64 OR FLAC__CPU_IA32)
|
||||
set(FLAC__ALIGN_MALLOC_DATA 1)
|
||||
option(WITH_AVX "Enable AVX, AVX2 optimizations (with runtime detection, resulting binary does not require AVX2, so only necessary when a compiler doesn't know about AVX)" ON)
|
||||
if(WITH_AVX AND MSVC)
|
||||
set_source_files_properties(fixed_intrin_avx2.c lpc_intrin_avx2.c stream_encoder_intrin_avx2.c PROPERTIES COMPILE_FLAGS /arch:AVX2)
|
||||
set_source_files_properties(lpc_intrin_fma.c PROPERTIES COMPILE_FLAGS "/arch:AVX2 /fp:fast")
|
||||
endif()
|
||||
if(WITH_AVX AND (CMAKE_C_COMPILER_ID MATCHES "Clang"))
|
||||
set_source_files_properties(lpc_intrin_fma.c PROPERTIES COMPILE_FLAGS "-ffast-math")
|
||||
endif()
|
||||
set(FLAC__ALIGN_MALLOC_DATA 1)
|
||||
option(WITH_AVX "Enable AVX, AVX2 optimizations (with runtime detection, resulting binary does not require AVX2, so only necessary when a compiler doesn't know about AVX)" ON)
|
||||
if(WITH_AVX AND MSVC)
|
||||
set_source_files_properties(fixed_intrin_avx2.c lpc_intrin_avx2.c stream_encoder_intrin_avx2.c PROPERTIES COMPILE_FLAGS /arch:AVX2)
|
||||
set_source_files_properties(lpc_intrin_fma.c PROPERTIES COMPILE_FLAGS "/arch:AVX2 /fp:fast")
|
||||
endif()
|
||||
if(WITH_AVX AND (CMAKE_C_COMPILER_ID MATCHES "Clang"))
|
||||
set_source_files_properties(lpc_intrin_fma.c PROPERTIES COMPILE_FLAGS "-ffast-math")
|
||||
endif()
|
||||
else()
|
||||
if(FLAC__CPU_ARM64)
|
||||
check_a64neon(FLAC__HAS_A64NEONINTRIN)
|
||||
endif()
|
||||
if(FLAC__CPU_ARM64)
|
||||
check_a64neon(FLAC__HAS_A64NEONINTRIN)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT WITH_ASM)
|
||||
add_definitions(-DFLAC__NO_ASM)
|
||||
add_definitions(-DFLAC__NO_ASM)
|
||||
endif()
|
||||
|
||||
if(HAVE_SEMAPHORE_H)
|
||||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
find_package(Threads)
|
||||
if(CMAKE_USE_PTHREADS_INIT)
|
||||
set(HAVE_PTHREAD 1)
|
||||
endif()
|
||||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
find_package(Threads)
|
||||
if(CMAKE_USE_PTHREADS_INIT)
|
||||
set(HAVE_PTHREAD 1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include_directories("3rdparty/flac/src/libFLAC/include")
|
||||
@@ -177,13 +177,13 @@ target_compile_definitions("Aaru.Compression.Native" PUBLIC FLAC__NO_FILEIO)
|
||||
|
||||
# Disable fortify source when not-release or when cross-building with MingW for WoA
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Debug OR CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo OR "${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW")
|
||||
set(DODEFINE_FORTIFY_SOURCE 0)
|
||||
set(DODEFINE_FORTIFY_SOURCE 0)
|
||||
endif()
|
||||
|
||||
set_property(TARGET "Aaru.Compression.Native" PROPERTY C_VISIBILITY_PRESET hidden)
|
||||
|
||||
if(ARCHITECTURE_IS_64BIT)
|
||||
set(ENABLE_64_BIT_WORDS 1)
|
||||
set(ENABLE_64_BIT_WORDS 1)
|
||||
endif()
|
||||
|
||||
configure_file(3rdparty/flac/config.cmake.h.in 3rdparty/flac/config.h)
|
||||
|
||||
26
3rdparty/lzfse.cmake
vendored
26
3rdparty/lzfse.cmake
vendored
@@ -8,28 +8,28 @@ include(CheckCCompilerFlag)
|
||||
# set it to OFF in your project before you add_subdirectory(lzfse).
|
||||
get_directory_property(LZFSE_PARENT_DIRECTORY PARENT_DIRECTORY)
|
||||
if("${LZFSE_BUNDLE_MODE}" STREQUAL "")
|
||||
# Bundled mode hasn't been set one way or the other, set the default
|
||||
# depending on whether or not we are the top-level project.
|
||||
if(LZFSE_PARENT_DIRECTORY)
|
||||
set(LZFSE_BUNDLE_MODE ON)
|
||||
else()
|
||||
set(LZFSE_BUNDLE_MODE OFF)
|
||||
endif(LZFSE_PARENT_DIRECTORY)
|
||||
# Bundled mode hasn't been set one way or the other, set the default
|
||||
# depending on whether or not we are the top-level project.
|
||||
if(LZFSE_PARENT_DIRECTORY)
|
||||
set(LZFSE_BUNDLE_MODE ON)
|
||||
else()
|
||||
set(LZFSE_BUNDLE_MODE OFF)
|
||||
endif(LZFSE_PARENT_DIRECTORY)
|
||||
endif()
|
||||
mark_as_advanced(LZFSE_BUNDLE_MODE)
|
||||
|
||||
if(CMAKE_VERSION VERSION_GREATER 3.2)
|
||||
cmake_policy(SET CMP0063 NEW)
|
||||
cmake_policy(SET CMP0063 NEW)
|
||||
endif()
|
||||
|
||||
if(CMAKE_VERSION VERSION_GREATER 3.9)
|
||||
cmake_policy(SET CMP0069 NEW)
|
||||
cmake_policy(SET CMP0069 NEW)
|
||||
endif()
|
||||
|
||||
if(ENABLE_SANITIZER)
|
||||
set(CMAKE_C_FLAGS " ${CMAKE_C_FLAGS} -fsanitize=${ENABLE_SANITIZER}")
|
||||
set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -fsanitize=${ENABLE_SANITIZER}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${ENABLE_SANITIZER}")
|
||||
set(CMAKE_C_FLAGS " ${CMAKE_C_FLAGS} -fsanitize=${ENABLE_SANITIZER}")
|
||||
set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -fsanitize=${ENABLE_SANITIZER}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${ENABLE_SANITIZER}")
|
||||
endif()
|
||||
|
||||
set(LZFSE_SOURCES
|
||||
@@ -47,5 +47,5 @@ target_sources("Aaru.Compression.Native" PRIVATE ${LZFSE_SOURCES})
|
||||
|
||||
|
||||
if(NOT AARU_MUSL AND (NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm"))
|
||||
set_property(TARGET "Aaru.Compression.Native" PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||
set_property(TARGET "Aaru.Compression.Native" PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||
endif()
|
||||
64
3rdparty/lzma.cmake
vendored
64
3rdparty/lzma.cmake
vendored
@@ -11,29 +11,29 @@ target_compile_definitions("Aaru.Compression.Native" PUBLIC _7ZIP_ST)
|
||||
# All assembly for x86 and x64 disabled because it uses a custom, non GAS, non MASM, assembler
|
||||
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64")
|
||||
set(IS_X64 1)
|
||||
target_compile_definitions("Aaru.Compression.Native" PUBLIC IS_X64)
|
||||
set(IS_X64 1)
|
||||
target_compile_definitions("Aaru.Compression.Native" PUBLIC IS_X64)
|
||||
|
||||
# if(NOT "${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang")
|
||||
# set(USE_ASM 1)
|
||||
# endif()
|
||||
# if(NOT "${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang")
|
||||
# set(USE_ASM 1)
|
||||
# endif()
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "i686")
|
||||
set(IS_X86 1)
|
||||
target_compile_definitions("Aaru.Compression.Native" PUBLIC IS_X86)
|
||||
# set(USE_ASM 1)
|
||||
set(IS_X86 1)
|
||||
target_compile_definitions("Aaru.Compression.Native" PUBLIC IS_X86)
|
||||
# set(USE_ASM 1)
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
|
||||
set(IS_ARM64 1)
|
||||
target_compile_definitions("Aaru.Compression.Native" PUBLIC IS_ARM64)
|
||||
set(USE_ASM 1)
|
||||
set(IS_ARM64 1)
|
||||
target_compile_definitions("Aaru.Compression.Native" PUBLIC IS_ARM64)
|
||||
set(USE_ASM 1)
|
||||
endif()
|
||||
|
||||
if("${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang" OR "${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
|
||||
set(USE_CLANG 1)
|
||||
target_compile_definitions("Aaru.Compression.Native" PUBLIC USE_CLANG)
|
||||
set(USE_CLANG 1)
|
||||
target_compile_definitions("Aaru.Compression.Native" PUBLIC USE_CLANG)
|
||||
endif()
|
||||
|
||||
if(DEFINED AARU_MUSL)
|
||||
target_compile_definitions("Aaru.Compression.Native" PUBLIC Z7_AFFINITY_DISABLE)
|
||||
target_compile_definitions("Aaru.Compression.Native" PUBLIC Z7_AFFINITY_DISABLE)
|
||||
endif()
|
||||
|
||||
#target_compile_options(lzma PUBLIC -Wall)
|
||||
@@ -43,10 +43,10 @@ target_compile_definitions("Aaru.Compression.Native" PUBLIC $<$<COMPILE_LANGUAGE
|
||||
|
||||
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64")
|
||||
target_compile_options("Aaru.Compression.Native" PUBLIC $<$<COMPILE_LANGUAGE:ASM>:-elf64>)
|
||||
target_compile_options("Aaru.Compression.Native" PUBLIC $<$<COMPILE_LANGUAGE:ASM>:-elf64>)
|
||||
else()
|
||||
target_compile_options("Aaru.Compression.Native" PUBLIC $<$<COMPILE_LANGUAGE:ASM>:-elf>)
|
||||
target_compile_definitions("Aaru.Compression.Native" PUBLIC $<$<COMPILE_LANGUAGE:ASM>:-DABI_CDECL>)
|
||||
target_compile_options("Aaru.Compression.Native" PUBLIC $<$<COMPILE_LANGUAGE:ASM>:-elf>)
|
||||
target_compile_definitions("Aaru.Compression.Native" PUBLIC $<$<COMPILE_LANGUAGE:ASM>:-DABI_CDECL>)
|
||||
endif()
|
||||
|
||||
#target_sources("Aaru.Compression.Native" PRIVATE ${LZMA_C_DIRECTORY}/7zAlloc.c)
|
||||
@@ -104,9 +104,9 @@ target_sources("Aaru.Compression.Native" PRIVATE ${LZMA_C_DIRECTORY}/LzmaLib.c)
|
||||
#target_sources("Aaru.Compression.Native" PRIVATE ${LZMA_ASM_DIRECTORY}/x86/7zCrcOpt.asm)
|
||||
|
||||
if(USE_ASM)
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "i686" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64")
|
||||
set(USE_X86_ASM 1)
|
||||
endif()
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "i686" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64")
|
||||
set(USE_X86_ASM 1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#if(USE_X86_ASM)
|
||||
@@ -124,21 +124,21 @@ endif()
|
||||
#endif()
|
||||
|
||||
if(USE_LZMA_DEC_ASM)
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64")
|
||||
target_sources("Aaru.Compression.Native" PRIVATE ${LZMA_ASM_DIRECTORY}/x86/LzFindOpt.asm)
|
||||
target_sources("Aaru.Compression.Native" PRIVATE ${LZMA_ASM_DIRECTORY}/x86/LzmaDecOpt.asm)
|
||||
endif()
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64")
|
||||
target_sources("Aaru.Compression.Native" PRIVATE ${LZMA_ASM_DIRECTORY}/x86/LzFindOpt.asm)
|
||||
target_sources("Aaru.Compression.Native" PRIVATE ${LZMA_ASM_DIRECTORY}/x86/LzmaDecOpt.asm)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
|
||||
target_sources("Aaru.Compression.Native" PRIVATE ${LZMA_ASM_DIRECTORY}/arm64/LzmaDecOpt.S)
|
||||
# target_sources("Aaru.Compression.Native" PRIVATE ${LZMA_ASM_DIRECTORY}/arm64/7zAsm.S)
|
||||
endif()
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
|
||||
target_sources("Aaru.Compression.Native" PRIVATE ${LZMA_ASM_DIRECTORY}/arm64/LzmaDecOpt.S)
|
||||
# target_sources("Aaru.Compression.Native" PRIVATE ${LZMA_ASM_DIRECTORY}/arm64/7zAsm.S)
|
||||
endif()
|
||||
|
||||
target_sources("Aaru.Compression.Native" PRIVATE ${LZMA_C_DIRECTORY}/LzFindOpt.c)
|
||||
target_sources("Aaru.Compression.Native" PRIVATE ${LZMA_C_DIRECTORY}/LzmaDec.c)
|
||||
target_sources("Aaru.Compression.Native" PRIVATE ${LZMA_C_DIRECTORY}/LzFindOpt.c)
|
||||
target_sources("Aaru.Compression.Native" PRIVATE ${LZMA_C_DIRECTORY}/LzmaDec.c)
|
||||
else()
|
||||
target_sources("Aaru.Compression.Native" PRIVATE ${LZMA_C_DIRECTORY}/LzFindOpt.c)
|
||||
target_sources("Aaru.Compression.Native" PRIVATE ${LZMA_C_DIRECTORY}/LzmaDec.c)
|
||||
target_sources("Aaru.Compression.Native" PRIVATE ${LZMA_C_DIRECTORY}/LzFindOpt.c)
|
||||
target_sources("Aaru.Compression.Native" PRIVATE ${LZMA_C_DIRECTORY}/LzmaDec.c)
|
||||
endif()
|
||||
|
||||
#target_sources("Aaru.Compression.Native" PRIVATE ${LZMA_C_DIRECTORY}/XzDec.c)
|
||||
|
||||
256
3rdparty/zstd.cmake
vendored
256
3rdparty/zstd.cmake
vendored
@@ -14,12 +14,12 @@ cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
|
||||
set(ZSTD_MAX_VALIDATED_CMAKE_MAJOR_VERSION "3")
|
||||
set(ZSTD_MAX_VALIDATED_CMAKE_MINOR_VERSION "13") #Policies never changed at PATCH level
|
||||
if("${CMAKE_MAJOR_VERSION}" LESS 3)
|
||||
set(ZSTD_CMAKE_POLICY_VERSION "${CMAKE_VERSION}")
|
||||
set(ZSTD_CMAKE_POLICY_VERSION "${CMAKE_VERSION}")
|
||||
elseif("${ZSTD_MAX_VALIDATED_CMAKE_MAJOR_VERSION}" EQUAL "${CMAKE_MAJOR_VERSION}" AND
|
||||
"${ZSTD_MAX_VALIDATED_CMAKE_MINOR_VERSION}" GREATER "${CMAKE_MINOR_VERSION}")
|
||||
set(ZSTD_CMAKE_POLICY_VERSION "${CMAKE_VERSION}")
|
||||
set(ZSTD_CMAKE_POLICY_VERSION "${CMAKE_VERSION}")
|
||||
else()
|
||||
set(ZSTD_CMAKE_POLICY_VERSION "${ZSTD_MAX_VALIDATED_CMAKE_MAJOR_VERSION}.${ZSTD_MAX_VALIDATED_CMAKE_MINOR_VERSION}.0")
|
||||
set(ZSTD_CMAKE_POLICY_VERSION "${ZSTD_MAX_VALIDATED_CMAKE_MAJOR_VERSION}.${ZSTD_MAX_VALIDATED_CMAKE_MINOR_VERSION}.0")
|
||||
endif()
|
||||
cmake_policy(VERSION ${ZSTD_CMAKE_POLICY_VERSION})
|
||||
|
||||
@@ -32,22 +32,22 @@ include(GetZstdLibraryVersion)
|
||||
getzstdlibraryversion(${LIBRARY_DIR}/zstd.h zstd_VERSION_MAJOR zstd_VERSION_MINOR zstd_VERSION_PATCH)
|
||||
|
||||
if(CMAKE_MAJOR_VERSION LESS 3)
|
||||
## Provide cmake 3+ behavior for older versions of cmake
|
||||
project(zstd)
|
||||
set(PROJECT_VERSION_MAJOR ${zstd_VERSION_MAJOR})
|
||||
set(PROJECT_VERSION_MINOR ${zstd_VERSION_MINOR})
|
||||
set(PROJECT_VERSION_PATCH ${zstd_VERSION_PATCH})
|
||||
set(PROJECT_VERSION "${zstd_VERSION_MAJOR}.${zstd_VERSION_MINOR}.${zstd_VERSION_PATCH}")
|
||||
enable_language(C) # Main library is in C
|
||||
enable_language(ASM) # And ASM
|
||||
enable_language(CXX) # Testing contributed code also utilizes CXX
|
||||
## Provide cmake 3+ behavior for older versions of cmake
|
||||
project(zstd)
|
||||
set(PROJECT_VERSION_MAJOR ${zstd_VERSION_MAJOR})
|
||||
set(PROJECT_VERSION_MINOR ${zstd_VERSION_MINOR})
|
||||
set(PROJECT_VERSION_PATCH ${zstd_VERSION_PATCH})
|
||||
set(PROJECT_VERSION "${zstd_VERSION_MAJOR}.${zstd_VERSION_MINOR}.${zstd_VERSION_PATCH}")
|
||||
enable_language(C) # Main library is in C
|
||||
enable_language(ASM) # And ASM
|
||||
enable_language(CXX) # Testing contributed code also utilizes CXX
|
||||
else()
|
||||
project(zstd
|
||||
VERSION "${zstd_VERSION_MAJOR}.${zstd_VERSION_MINOR}.${zstd_VERSION_PATCH}"
|
||||
LANGUAGES C # Main library is in C
|
||||
ASM # And ASM
|
||||
CXX # Testing contributed code also utilizes CXX
|
||||
)
|
||||
project(zstd
|
||||
VERSION "${zstd_VERSION_MAJOR}.${zstd_VERSION_MINOR}.${zstd_VERSION_PATCH}"
|
||||
LANGUAGES C # Main library is in C
|
||||
ASM # And ASM
|
||||
CXX # Testing contributed code also utilizes CXX
|
||||
)
|
||||
endif()
|
||||
|
||||
message(STATUS "ZSTD VERSION: ${zstd_VERSION}")
|
||||
@@ -56,10 +56,10 @@ set(zstd_DESCRIPTION "Zstandard is a real-time compression algorithm, providing
|
||||
|
||||
# Set a default build type if none was specified
|
||||
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
message(STATUS "Setting build type to 'Release' as none was specified.")
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
|
||||
# Set the possible values of build type for cmake-gui
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
||||
message(STATUS "Setting build type to 'Release' as none was specified.")
|
||||
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
|
||||
# Set the possible values of build type for cmake-gui
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
@@ -70,83 +70,83 @@ include(CheckCXXCompilerFlag)
|
||||
include(CheckCCompilerFlag)
|
||||
|
||||
function(enablecompilerflag _flag _C _CXX)
|
||||
string(REGEX REPLACE "\\+" "PLUS" varname "${_flag}")
|
||||
string(REGEX REPLACE "[^A-Za-z0-9]+" "_" varname "${varname}")
|
||||
string(REGEX REPLACE "^_+" "" varname "${varname}")
|
||||
string(TOUPPER "${varname}" varname)
|
||||
if(_C)
|
||||
check_c_compiler_flag(${_flag} C_FLAG_${varname})
|
||||
if(C_FLAG_${varname})
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_flag}" PARENT_SCOPE)
|
||||
endif()
|
||||
string(REGEX REPLACE "\\+" "PLUS" varname "${_flag}")
|
||||
string(REGEX REPLACE "[^A-Za-z0-9]+" "_" varname "${varname}")
|
||||
string(REGEX REPLACE "^_+" "" varname "${varname}")
|
||||
string(TOUPPER "${varname}" varname)
|
||||
if(_C)
|
||||
check_c_compiler_flag(${_flag} C_FLAG_${varname})
|
||||
if(C_FLAG_${varname})
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_flag}" PARENT_SCOPE)
|
||||
endif()
|
||||
if(_CXX)
|
||||
check_cxx_compiler_flag(${_flag} CXX_FLAG_${varname})
|
||||
if(CXX_FLAG_${varname})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_flag}" PARENT_SCOPE)
|
||||
endif()
|
||||
endif()
|
||||
if(_CXX)
|
||||
check_cxx_compiler_flag(${_flag} CXX_FLAG_${varname})
|
||||
if(CXX_FLAG_${varname})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_flag}" PARENT_SCOPE)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
macro(add_zstd_compilation_flags)
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" OR MINGW) #Not only UNIX but also WIN32 for MinGW
|
||||
#Set c++11 by default
|
||||
enablecompilerflag("-std=c++11" false true)
|
||||
#Set c99 by default
|
||||
enablecompilerflag("-std=c99" true false)
|
||||
# if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND MSVC)
|
||||
# # clang-cl normally maps -Wall to -Weverything.
|
||||
# EnableCompilerFlag("/clang:-Wall" true true)
|
||||
# else ()
|
||||
# EnableCompilerFlag("-Wall" true true)
|
||||
# endif ()
|
||||
# EnableCompilerFlag("-Wextra" true true)
|
||||
# EnableCompilerFlag("-Wundef" true true)
|
||||
# EnableCompilerFlag("-Wshadow" true true)
|
||||
# EnableCompilerFlag("-Wcast-align" true true)
|
||||
# EnableCompilerFlag("-Wcast-qual" true true)
|
||||
# EnableCompilerFlag("-Wstrict-prototypes" true false)
|
||||
# Enable asserts in Debug mode
|
||||
if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
enablecompilerflag("-DDEBUGLEVEL=1" true true)
|
||||
endif()
|
||||
elseif(MSVC) # Add specific compilation flags for Windows Visual
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" OR MINGW) #Not only UNIX but also WIN32 for MinGW
|
||||
#Set c++11 by default
|
||||
enablecompilerflag("-std=c++11" false true)
|
||||
#Set c99 by default
|
||||
enablecompilerflag("-std=c99" true false)
|
||||
# if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND MSVC)
|
||||
# # clang-cl normally maps -Wall to -Weverything.
|
||||
# EnableCompilerFlag("/clang:-Wall" true true)
|
||||
# else ()
|
||||
# EnableCompilerFlag("-Wall" true true)
|
||||
# endif ()
|
||||
# EnableCompilerFlag("-Wextra" true true)
|
||||
# EnableCompilerFlag("-Wundef" true true)
|
||||
# EnableCompilerFlag("-Wshadow" true true)
|
||||
# EnableCompilerFlag("-Wcast-align" true true)
|
||||
# EnableCompilerFlag("-Wcast-qual" true true)
|
||||
# EnableCompilerFlag("-Wstrict-prototypes" true false)
|
||||
# Enable asserts in Debug mode
|
||||
if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
enablecompilerflag("-DDEBUGLEVEL=1" true true)
|
||||
endif()
|
||||
elseif(MSVC) # Add specific compilation flags for Windows Visual
|
||||
|
||||
set(ACTIVATE_MULTITHREADED_COMPILATION "ON" CACHE BOOL "activate multi-threaded compilation (/MP flag)")
|
||||
if(CMAKE_GENERATOR MATCHES "Visual Studio" AND ACTIVATE_MULTITHREADED_COMPILATION)
|
||||
enablecompilerflag("/MP" true true)
|
||||
endif()
|
||||
|
||||
# UNICODE SUPPORT
|
||||
enablecompilerflag("/D_UNICODE" true true)
|
||||
enablecompilerflag("/DUNICODE" true true)
|
||||
# Enable asserts in Debug mode
|
||||
if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
enablecompilerflag("/DDEBUGLEVEL=1" true true)
|
||||
endif()
|
||||
set(ACTIVATE_MULTITHREADED_COMPILATION "ON" CACHE BOOL "activate multi-threaded compilation (/MP flag)")
|
||||
if(CMAKE_GENERATOR MATCHES "Visual Studio" AND ACTIVATE_MULTITHREADED_COMPILATION)
|
||||
enablecompilerflag("/MP" true true)
|
||||
endif()
|
||||
|
||||
# Remove duplicates compilation flags
|
||||
# UNICODE SUPPORT
|
||||
enablecompilerflag("/D_UNICODE" true true)
|
||||
enablecompilerflag("/DUNICODE" true true)
|
||||
# Enable asserts in Debug mode
|
||||
if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
enablecompilerflag("/DDEBUGLEVEL=1" true true)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Remove duplicates compilation flags
|
||||
foreach(flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||
if(${flag_var})
|
||||
separate_arguments(${flag_var})
|
||||
string(REPLACE ";" " " ${flag_var} "${${flag_var}}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(MSVC AND ZSTD_USE_STATIC_RUNTIME)
|
||||
foreach(flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||
if(${flag_var})
|
||||
separate_arguments(${flag_var})
|
||||
string(REPLACE ";" " " ${flag_var} "${${flag_var}}")
|
||||
endif()
|
||||
if(${flag_var})
|
||||
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(MSVC AND ZSTD_USE_STATIC_RUNTIME)
|
||||
foreach(flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
||||
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||
if(${flag_var})
|
||||
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endmacro()
|
||||
|
||||
@@ -170,31 +170,31 @@ add_definitions(-DXXH_NAMESPACE=ZSTD_)
|
||||
option(ZSTD_LEGACY_SUPPORT "LEGACY SUPPORT" OFF)
|
||||
|
||||
if(ZSTD_LEGACY_SUPPORT)
|
||||
message(STATUS "ZSTD_LEGACY_SUPPORT defined!")
|
||||
add_definitions(-DZSTD_LEGACY_SUPPORT=5)
|
||||
message(STATUS "ZSTD_LEGACY_SUPPORT defined!")
|
||||
add_definitions(-DZSTD_LEGACY_SUPPORT=5)
|
||||
else()
|
||||
message(STATUS "ZSTD_LEGACY_SUPPORT not defined!")
|
||||
add_definitions(-DZSTD_LEGACY_SUPPORT=0)
|
||||
message(STATUS "ZSTD_LEGACY_SUPPORT not defined!")
|
||||
add_definitions(-DZSTD_LEGACY_SUPPORT=0)
|
||||
endif()
|
||||
|
||||
# Multi-threading support
|
||||
if(ANDROID)
|
||||
option(ZSTD_MULTITHREAD_SUPPORT "MULTITHREADING SUPPORT" OFF)
|
||||
option(ZSTD_MULTITHREAD_SUPPORT "MULTITHREADING SUPPORT" OFF)
|
||||
else()
|
||||
option(ZSTD_MULTITHREAD_SUPPORT "MULTITHREADING SUPPORT" ON)
|
||||
option(ZSTD_MULTITHREAD_SUPPORT "MULTITHREADING SUPPORT" ON)
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# External dependencies
|
||||
#-----------------------------------------------------------------------------
|
||||
if(ZSTD_MULTITHREAD_SUPPORT AND UNIX)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
if(CMAKE_USE_PTHREADS_INIT)
|
||||
set(THREADS_LIBS "${CMAKE_THREAD_LIBS_INIT}")
|
||||
else()
|
||||
message(SEND_ERROR "ZSTD currently does not support thread libraries other than pthreads")
|
||||
endif()
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
if(CMAKE_USE_PTHREADS_INIT)
|
||||
set(THREADS_LIBS "${CMAKE_THREAD_LIBS_INIT}")
|
||||
else()
|
||||
message(SEND_ERROR "ZSTD currently does not support thread libraries other than pthreads")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
project(libzstd C)
|
||||
@@ -230,32 +230,32 @@ set(Headers
|
||||
${DictBuilderHeaders})
|
||||
|
||||
if(ZSTD_LEGACY_SUPPORT)
|
||||
set(LIBRARY_LEGACY_DIR ${LIBRARY_DIR}/legacy)
|
||||
include_directories(${LIBRARY_LEGACY_DIR})
|
||||
set(LIBRARY_LEGACY_DIR ${LIBRARY_DIR}/legacy)
|
||||
include_directories(${LIBRARY_LEGACY_DIR})
|
||||
|
||||
set(Sources ${Sources}
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v01.c
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v02.c
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v03.c
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v04.c
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v05.c
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v06.c
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v07.c)
|
||||
set(Sources ${Sources}
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v01.c
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v02.c
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v03.c
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v04.c
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v05.c
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v06.c
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v07.c)
|
||||
|
||||
set(Headers ${Headers}
|
||||
${LIBRARY_LEGACY_DIR}/zstd_legacy.h
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v01.h
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v02.h
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v03.h
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v04.h
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v05.h
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v06.h
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v07.h)
|
||||
set(Headers ${Headers}
|
||||
${LIBRARY_LEGACY_DIR}/zstd_legacy.h
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v01.h
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v02.h
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v03.h
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v04.h
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v05.h
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v06.h
|
||||
${LIBRARY_LEGACY_DIR}/zstd_v07.h)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
set(MSVC_RESOURCE_DIR ${ZSTD_SOURCE_DIR}/build/VS2010/libzstd-dll)
|
||||
set(PlatformDependResources ${MSVC_RESOURCE_DIR}/libzstd-dll.rc)
|
||||
set(MSVC_RESOURCE_DIR ${ZSTD_SOURCE_DIR}/build/VS2010/libzstd-dll)
|
||||
set(PlatformDependResources ${MSVC_RESOURCE_DIR}/libzstd-dll.rc)
|
||||
endif()
|
||||
|
||||
# Explicitly set the language to C for all files, including ASM files.
|
||||
@@ -270,23 +270,23 @@ set(library_targets)
|
||||
add_library(libzstd_static STATIC ${Sources} ${Headers})
|
||||
list(APPEND library_targets libzstd_static)
|
||||
if(ZSTD_MULTITHREAD_SUPPORT)
|
||||
set_property(TARGET libzstd_static APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_MULTITHREAD")
|
||||
if(UNIX)
|
||||
target_link_libraries(libzstd_static ${THREADS_LIBS})
|
||||
endif()
|
||||
set_property(TARGET libzstd_static APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_MULTITHREAD")
|
||||
if(UNIX)
|
||||
target_link_libraries(libzstd_static ${THREADS_LIBS})
|
||||
endif()
|
||||
endif()
|
||||
#endif ()
|
||||
|
||||
# Add specific compile definitions for MSVC project
|
||||
if(MSVC)
|
||||
set_property(TARGET libzstd_static APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_HEAPMODE=0;_CRT_SECURE_NO_WARNINGS")
|
||||
set_property(TARGET libzstd_static APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_HEAPMODE=0;_CRT_SECURE_NO_WARNINGS")
|
||||
endif()
|
||||
|
||||
# With MSVC static library needs to be renamed to avoid conflict with import library
|
||||
if(MSVC)
|
||||
set(STATIC_LIBRARY_BASE_NAME zstd_static)
|
||||
set(STATIC_LIBRARY_BASE_NAME zstd_static)
|
||||
else()
|
||||
set(STATIC_LIBRARY_BASE_NAME zstd)
|
||||
set(STATIC_LIBRARY_BASE_NAME zstd)
|
||||
endif()
|
||||
|
||||
# Define static and shared library names
|
||||
@@ -298,5 +298,5 @@ set_target_properties(
|
||||
#endif ()
|
||||
|
||||
if(NOT "${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW" OR (NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm" AND NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64"))
|
||||
set_property(TARGET libzstd_static PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
set_property(TARGET libzstd_static PROPERTY POSITION_INDEPENDENT_CODE ON)
|
||||
endif()
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>Aaru.Compression.Native</id>
|
||||
<version>6.0.0-alpha10</version>
|
||||
<version>6.0.0-alpha.11.1</version>
|
||||
<description>C implementation of compression algorithms used by Aaru.</description>
|
||||
<authors>claunia</authors>
|
||||
<projectUrl>https://github.com/aaru-dps/Aaru.Compression.Native</projectUrl>
|
||||
<licenseUrl>https://spdx.org/licenses/LGPL-2.1-only.html</licenseUrl>
|
||||
<copyright>Copyright © 2011-2023 Natalia Portillo</copyright>
|
||||
<copyright>Copyright © 2011-2025 Natalia Portillo</copyright>
|
||||
<repository type="git" url="https://github.com/aaru-dps/Aaru.Compression.Native.git" />
|
||||
</metadata>
|
||||
<files>
|
||||
|
||||
196
CMakeLists.txt
196
CMakeLists.txt
@@ -1,7 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
|
||||
# This file is part of the Aaru Data Preservation Suite.
|
||||
# Copyright (c) 2019-2023 Natalia Portillo.
|
||||
# Copyright (c) 2019-2025 Natalia Portillo.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as
|
||||
@@ -17,48 +17,48 @@ cmake_minimum_required(VERSION 3.15)
|
||||
# License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
if(APPLE)
|
||||
# Too early cmake has not yet set it
|
||||
if((NOT DEFINED CMAKE_SYSTEM_PROCESSOR) AND (NOT DEFINED AARU_MACOS_TARGET_ARCH))
|
||||
execute_process(COMMAND uname -m OUTPUT_VARIABLE AARU_MACOS_TARGET_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
endif()
|
||||
# Too early cmake has not yet set it
|
||||
if((NOT DEFINED CMAKE_SYSTEM_PROCESSOR) AND (NOT DEFINED AARU_MACOS_TARGET_ARCH))
|
||||
execute_process(COMMAND uname -m OUTPUT_VARIABLE AARU_MACOS_TARGET_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED AARU_MACOS_TARGET_ARCH)
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64")
|
||||
set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Build architectures for macOS" FORCE)
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64")
|
||||
set(CMAKE_OSX_ARCHITECTURES "arm64" CACHE STRING "Build architectures for macOS" FORCE)
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown system processor ${CMAKE_SYSTEM_PROCESSOR} for macOS")
|
||||
endif()
|
||||
elseif(AARU_MACOS_TARGET_ARCH STREQUAL "x86_64")
|
||||
set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Build architectures for macOS" FORCE)
|
||||
elseif(AARU_MACOS_TARGET_ARCH STREQUAL "arm64")
|
||||
set(CMAKE_OSX_ARCHITECTURES "arm64" CACHE STRING "Build architectures for macOS" FORCE)
|
||||
if(NOT DEFINED AARU_MACOS_TARGET_ARCH)
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64")
|
||||
set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Build architectures for macOS" FORCE)
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64")
|
||||
set(CMAKE_OSX_ARCHITECTURES "arm64" CACHE STRING "Build architectures for macOS" FORCE)
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown Aaru target architecture ${AARU_MACOS_TARGET_ARCH} for macOS")
|
||||
message(FATAL_ERROR "Unknown system processor ${CMAKE_SYSTEM_PROCESSOR} for macOS")
|
||||
endif()
|
||||
elseif(AARU_MACOS_TARGET_ARCH STREQUAL "x86_64")
|
||||
set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "Build architectures for macOS" FORCE)
|
||||
elseif(AARU_MACOS_TARGET_ARCH STREQUAL "arm64")
|
||||
set(CMAKE_OSX_ARCHITECTURES "arm64" CACHE STRING "Build architectures for macOS" FORCE)
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown Aaru target architecture ${AARU_MACOS_TARGET_ARCH} for macOS")
|
||||
endif()
|
||||
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version")
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version")
|
||||
endif(APPLE)
|
||||
|
||||
project("Aaru.Compression.Native" C)
|
||||
|
||||
if("${CMAKE_C_COMPILER_ID}" MATCHES "MSVC" AND "${CMAKE_C_COMPILER_ARCHITECTURE_ID}" MATCHES "ARMV7")
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
else()
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
endif()
|
||||
|
||||
if("${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW")
|
||||
if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "aarch64" OR "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm")
|
||||
set(WIN32 TRUE)
|
||||
endif()
|
||||
if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "aarch64" OR "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm")
|
||||
set(WIN32 TRUE)
|
||||
endif()
|
||||
|
||||
add_link_options(-static-libgcc)
|
||||
add_link_options(-static-libgcc)
|
||||
endif()
|
||||
|
||||
if(DEFINED AARU_MACOS_TARGET_ARCH)
|
||||
message("Requested target architecture: ${AARU_MACOS_TARGET_ARCH}")
|
||||
message("Requested target architecture: ${AARU_MACOS_TARGET_ARCH}")
|
||||
endif()
|
||||
message("Detected system processor: ${CMAKE_SYSTEM_PROCESSOR}")
|
||||
message("Detected vs platform name: ${CMAKE_C_COMPILER_ARCHITECTURE_ID}")
|
||||
@@ -69,66 +69,68 @@ message("Size of (void*): ${CMAKE_SIZEOF_VOID_P}")
|
||||
|
||||
# Check if target is 64-bit
|
||||
if("${CMAKE_SIZEOF_VOID_P}" MATCHES "8" OR "${CMAKE_C_COMPILER_ARCHITECTURE_ID}" MATCHES "x64" OR "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86_64" OR "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "AMD64" OR "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "aarch64")
|
||||
set(ARCHITECTURE_IS_64BIT TRUE)
|
||||
set(ARCHITECTURE_IS_64BIT TRUE)
|
||||
endif()
|
||||
|
||||
if("${CMAKE_BUILD_TYPE}" MATCHES "Release" OR "${CMAKE_BUILD_TYPE}" MATCHES "RelWithDebInfo" OR "${CMAKE_BUILD_TYPE}" MATCHES "MinSizeRel")
|
||||
if("${CMAKE_BUILD_TYPE}" MATCHES "Release")
|
||||
add_compile_definitions(NDEBUG)
|
||||
if("${CMAKE_BUILD_TYPE}" MATCHES "Release")
|
||||
add_compile_definitions(NDEBUG)
|
||||
endif()
|
||||
|
||||
if("${CMAKE_C_COMPILER_ID}" MATCHES "MSVC")
|
||||
add_compile_options("/O2 /Ob2 /Oi /Ot /Oy /Og /fp:fast")
|
||||
if(${CMAKE_C_COMPILER_ARCHITECTURE_ID} MATCHES "X86")
|
||||
add_compile_options("/arch:SSE2")
|
||||
elseif(${CMAKE_C_COMPILER_ARCHITECTURE_ID} MATCHES "ARM")
|
||||
add_compile_options("/arch:VFPv4")
|
||||
endif()
|
||||
else()
|
||||
add_compile_options(-ffast-math -Ofast)
|
||||
|
||||
if("${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang")
|
||||
if(${AARU_MACOS_TARGET_ARCH} MATCHES "x86_64")
|
||||
add_compile_options(-march=ivybridge -mtune=westmere -msse4.2)
|
||||
elseif(${AARU_MACOS_TARGET_ARCH} MATCHES "arm64")
|
||||
add_compile_options(-mcpu=apple-m1 -mtune=apple-m1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if("${CMAKE_C_COMPILER_ID}" MATCHES "MSVC")
|
||||
add_compile_options("/O2 /Ob2 /Oi /Ot /Oy /Og /fp:fast")
|
||||
if(${CMAKE_C_COMPILER_ARCHITECTURE_ID} MATCHES "X86")
|
||||
add_compile_options("/arch:SSE2")
|
||||
elseif(${CMAKE_C_COMPILER_ARCHITECTURE_ID} MATCHES "ARM")
|
||||
add_compile_options("/arch:VFPv4")
|
||||
endif()
|
||||
else()
|
||||
add_compile_options(-ffast-math -Ofast)
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "i686" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64")
|
||||
if(NOT "${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang")
|
||||
add_compile_options(-march=westmere -mtune=skylake -mfpmath=sse)
|
||||
add_compile_options(-msse4.2)
|
||||
endif()
|
||||
|
||||
if("${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang")
|
||||
if(${AARU_MACOS_TARGET_ARCH} MATCHES "x86_64")
|
||||
add_compile_options(-march=ivybridge -mtune=westmere -msse4.2)
|
||||
elseif(${AARU_MACOS_TARGET_ARCH} MATCHES "arm64")
|
||||
add_compile_options(-mcpu=apple-m1 -mtune=apple-m1)
|
||||
endif()
|
||||
endif()
|
||||
if(NOT "${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW")
|
||||
add_compile_options(-flto)
|
||||
endif()
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
|
||||
if(NOT "${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang")
|
||||
add_compile_options(-mtune=cortex-a53)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "i686" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "AMD64")
|
||||
if(NOT "${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang")
|
||||
add_compile_options(-march=westmere -mtune=skylake -mfpmath=sse)
|
||||
add_compile_options(-msse4.2)
|
||||
endif()
|
||||
|
||||
if(NOT "${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW")
|
||||
add_compile_options(-flto)
|
||||
endif()
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
|
||||
if(NOT "${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang")
|
||||
add_compile_options(-mtune=cortex-a53)
|
||||
endif()
|
||||
|
||||
if(NOT "${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW")
|
||||
add_compile_options(-flto)
|
||||
endif()
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "armv7l" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm" AND NOT "${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang")
|
||||
if("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
|
||||
add_compile_options(-mtune=cortex-a53 -mcpu=cortex-a7)
|
||||
else()
|
||||
add_compile_options(-mtune=cortex-a53 -march=armv7-a+neon-vfpv4)
|
||||
endif()
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "mips")
|
||||
if(NOT "${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW")
|
||||
add_compile_options(-flto)
|
||||
endif()
|
||||
endif()
|
||||
if(NOT "${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW")
|
||||
add_compile_options(-flto)
|
||||
endif()
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "armv7l" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm" AND NOT "${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang")
|
||||
if("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
|
||||
add_compile_options(-mtune=cortex-a53 -mcpu=cortex-a7)
|
||||
else()
|
||||
add_compile_options(-mtune=cortex-a53 -march=armv7-a+neon-vfpv4)
|
||||
endif()
|
||||
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "mips")
|
||||
if(NOT "${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW")
|
||||
add_compile_options(-flto)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_subdirectory(3rdparty)
|
||||
|
||||
add_library("Aaru.Compression.Native" SHARED library.c apple_rle.c apple_rle.h adc.c adc.h lzip.c flac.c flac.h)
|
||||
add_library("Aaru.Compression.Native" SHARED library.c apple_rle.c apple_rle.h adc.c adc.h lzip.c flac.c flac.h
|
||||
zoo/lzd.c
|
||||
zoo/lzd.h)
|
||||
|
||||
include(3rdparty/bzip2.cmake)
|
||||
include(3rdparty/flac.cmake)
|
||||
@@ -137,22 +139,22 @@ include(3rdparty/lzip.cmake)
|
||||
include(3rdparty/lzma.cmake)
|
||||
|
||||
macro(target_link_libraries_whole_archive target)
|
||||
if("${CMAKE_C_COMPILER_ID}" MATCHES "MSVC")
|
||||
foreach(arg IN LISTS ARGN)
|
||||
set_target_properties(
|
||||
${target} PROPERTIES LINK_FLAGS "/WHOLEARCHIVE:${lib}"
|
||||
)
|
||||
endforeach()
|
||||
if("${CMAKE_C_COMPILER_ID}" MATCHES "MSVC")
|
||||
foreach(arg IN LISTS ARGN)
|
||||
set_target_properties(
|
||||
${target} PROPERTIES LINK_FLAGS "/WHOLEARCHIVE:${lib}"
|
||||
)
|
||||
endforeach()
|
||||
else()
|
||||
if("${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang")
|
||||
set(LINK_FLAGS "-Wl,-all_load")
|
||||
set(UNDO_FLAGS "-Wl")
|
||||
else()
|
||||
if("${CMAKE_C_COMPILER_ID}" MATCHES "AppleClang")
|
||||
set(LINK_FLAGS "-Wl,-all_load")
|
||||
set(UNDO_FLAGS "-Wl")
|
||||
else()
|
||||
set(LINK_FLAGS "-Wl,--whole-archive")
|
||||
set(UNDO_FLAGS "-Wl,--no-whole-archive")
|
||||
endif()
|
||||
target_link_libraries(${target} ${LINK_FLAGS} ${ARGN} ${UNDO_FLAGS})
|
||||
set(LINK_FLAGS "-Wl,--whole-archive")
|
||||
set(UNDO_FLAGS "-Wl,--no-whole-archive")
|
||||
endif()
|
||||
target_link_libraries(${target} ${LINK_FLAGS} ${ARGN} ${UNDO_FLAGS})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
target_link_libraries_whole_archive("Aaru.Compression.Native" libzstd_static m)
|
||||
@@ -160,22 +162,22 @@ target_link_libraries_whole_archive("Aaru.Compression.Native" libzstd_static m)
|
||||
check_include_file("semaphore.h" HAVE_SEMAPHORE_H)
|
||||
|
||||
if(HAVE_SEMAPHORE_H)
|
||||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
find_package(Threads)
|
||||
if(CMAKE_USE_PTHREADS_INIT)
|
||||
set(HAVE_PTHREAD 1)
|
||||
endif()
|
||||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
find_package(Threads)
|
||||
if(CMAKE_USE_PTHREADS_INIT)
|
||||
set(HAVE_PTHREAD 1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(HAVE_PTHREAD)
|
||||
target_link_libraries_whole_archive("Aaru.Compression.Native" Threads::Threads)
|
||||
target_link_libraries_whole_archive("Aaru.Compression.Native" Threads::Threads)
|
||||
endif()
|
||||
|
||||
if(NOT "${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW" OR (NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm" AND NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64"))
|
||||
set_property(TARGET "Aaru.Compression.Native" PROPERTY POSITION_INDEPENDENT_CODE TRUE)
|
||||
set_property(TARGET "Aaru.Compression.Native" PROPERTY POSITION_INDEPENDENT_CODE TRUE)
|
||||
else()
|
||||
set_property(TARGET "Aaru.Compression.Native" PROPERTY POSITION_INDEPENDENT_CODE FALSE)
|
||||
set_property(TARGET "Aaru.Compression.Native" PROPERTY POSITION_INDEPENDENT_CODE FALSE)
|
||||
endif()
|
||||
|
||||
add_subdirectory(tests)
|
||||
|
||||
@@ -4,11 +4,14 @@ This repository contains the Aaru.Compression.Native library for [Aaru](https://
|
||||
|
||||
The purpose of this library is to provide compression and de-compression algorithms for Aaru.
|
||||
|
||||
No archiver processing code should fall here, those go in [Aaru.Compression](https://github.com/aaru-dps/Aaru/tree/devel/Aaru.Compression).
|
||||
No archiver processing code should fall here, those go
|
||||
in [Aaru.Compression](https://github.com/aaru-dps/Aaru/tree/devel/Aaru.Compression).
|
||||
|
||||
To build you just need Docker on Linux and run `build.sh`, that will generate a NuGet package for use with Aaru.Compression.
|
||||
To build you just need Docker on Linux and run `build.sh`, that will generate a NuGet package for use with
|
||||
Aaru.Compression.
|
||||
|
||||
Currently implemented algorithms are:
|
||||
|
||||
- Apple Data Compression (RLE with sliding dictionary created for Apple Disk Copy's NDIF)
|
||||
- Apple RLE (Run Length Encoding created for Apple DART)
|
||||
- [BZIP2](https://gitlab.com/bzip2/bzip2.git)
|
||||
@@ -24,4 +27,4 @@ The resulting output of `build.sh` falls under the LGPL 2.1 license as stated in
|
||||
|
||||
Any new algorithm added should be under a license compatible with the LGPL 2.1 license to be accepted.
|
||||
|
||||
© 2021-2023 Natalia Portillo
|
||||
© 2021-2025 Natalia Portillo
|
||||
30
adc.c
30
adc.c
@@ -19,10 +19,14 @@ FORCE_INLINE int GetChunkSize(uint8_t byt)
|
||||
{
|
||||
switch(GetChunkType(byt))
|
||||
{
|
||||
case ADC_PLAIN: return (byt & 0x7F) + 1;
|
||||
case ADC_TWO_BYTE: return ((byt & 0x3F) >> 2) + 3;
|
||||
case ADC_THREE_BYTE: return (byt & 0x3F) + 4;
|
||||
default: return -1;
|
||||
case ADC_PLAIN:
|
||||
return (byt & 0x7F) + 1;
|
||||
case ADC_TWO_BYTE:
|
||||
return ((byt & 0x3F) >> 2) + 3;
|
||||
case ADC_THREE_BYTE:
|
||||
return (byt & 0x3F) + 4;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,17 +34,19 @@ FORCE_INLINE int GetOffset(uint8_t chunk[])
|
||||
{
|
||||
switch(GetChunkType(chunk[0]))
|
||||
{
|
||||
case ADC_PLAIN: return 0;
|
||||
case ADC_TWO_BYTE: return ((chunk[0] & 0x03) << 8) + chunk[1];
|
||||
case ADC_THREE_BYTE: return (chunk[1] << 8) + chunk[2];
|
||||
default: return -1;
|
||||
case ADC_PLAIN:
|
||||
return 0;
|
||||
case ADC_TWO_BYTE:
|
||||
return ((chunk[0] & 0x03) << 8) + chunk[1];
|
||||
case ADC_THREE_BYTE:
|
||||
return (chunk[1] << 8) + chunk[2];
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_adc_decode_buffer(uint8_t* dst_buffer,
|
||||
int32_t dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
int32_t src_size)
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_adc_decode_buffer(uint8_t *dst_buffer, int32_t dst_size, const uint8_t *src_buffer,
|
||||
int32_t src_size)
|
||||
{
|
||||
int inputPosition = 0;
|
||||
int chunkSize;
|
||||
|
||||
6
adc.h
6
adc.h
@@ -5,8 +5,8 @@
|
||||
#ifndef AARU_COMPRESSION_NATIVE__ADC_H_
|
||||
#define AARU_COMPRESSION_NATIVE__ADC_H_
|
||||
|
||||
#define ADC_PLAIN 1
|
||||
#define ADC_TWO_BYTE 2
|
||||
#define ADC_PLAIN 1
|
||||
#define ADC_TWO_BYTE 2
|
||||
#define ADC_THREE_BYTE 3
|
||||
|
||||
#endif // AARU_COMPRESSION_NATIVE__ADC_H_
|
||||
#endif // AARU_COMPRESSION_NATIVE__ADC_H_
|
||||
|
||||
12
apple_rle.c
12
apple_rle.c
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Aaru Data Preservation Suite.
|
||||
* Copyright (c) 2019-2023 Natalia Portillo.
|
||||
* Copyright (c) 2019-2025 Natalia Portillo.
|
||||
* Copyright © 2018-2019 David Ryskalczyk
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
@@ -24,15 +24,13 @@
|
||||
#include "library.h"
|
||||
#include "apple_rle.h"
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_apple_rle_decode_buffer(uint8_t* dst_buffer,
|
||||
int32_t dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
int32_t src_size)
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_apple_rle_decode_buffer(uint8_t *dst_buffer, int32_t dst_size,
|
||||
const uint8_t *src_buffer, int32_t src_size)
|
||||
{
|
||||
static int32_t count = 0;
|
||||
static bool nextA = true; // true if A, false if B
|
||||
static bool nextA = true; // true if A, false if B
|
||||
static uint8_t repeatedByteA = 0, repeatedByteB = 0;
|
||||
static bool repeatMode = false; // true if we're repeating, false if we're just copying
|
||||
static bool repeatMode = false; // true if we're repeating, false if we're just copying
|
||||
int32_t in_pos = 0, out_pos = 0;
|
||||
|
||||
while(in_pos <= src_size && out_pos <= dst_size)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Aaru Data Preservation Suite.
|
||||
* Copyright (c) 2019-2023 Natalia Portillo.
|
||||
* Copyright (c) 2019-2025 Natalia Portillo.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
@@ -21,4 +21,4 @@
|
||||
|
||||
#define DART_CHUNK 20960
|
||||
|
||||
#endif // AARU_CHECKSUMS_NATIVE__APPLE_RLE_H_
|
||||
#endif // AARU_CHECKSUMS_NATIVE__APPLE_RLE_H_
|
||||
|
||||
7
build.sh
7
build.sh
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This file is part of the Aaru Data Preservation Suite.
|
||||
# Copyright (c) 2019-2023 Natalia Portillo.
|
||||
# Copyright (c) 2019-2025 Natalia Portillo.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as
|
||||
@@ -198,7 +198,7 @@ mv libAaru.Compression.Native.so runtimes/win-arm64/native/libAaru.Compression.N
|
||||
# TODO: Requires MSVCRT.DLL
|
||||
rm -f CMakeCache.txt
|
||||
mkdir -p runtimes/win-x64/native
|
||||
docker run --rm dockcross/windows-shared-x64 > docker/dockcross-win-x64
|
||||
docker run --rm dockcross/windows-static-x64 > docker/dockcross-win-x64
|
||||
chmod +x docker/dockcross-win-x64
|
||||
docker/dockcross-win-x64 cmake -DCMAKE_BUILD_TYPE=Release -DAARU_BUILD_PACKAGE=1 .
|
||||
docker/dockcross-win-x64 make Aaru.Compression.Native
|
||||
@@ -209,7 +209,7 @@ mv libAaru.Compression.Native.dll runtimes/win-x64/native/
|
||||
# TODO: Requires MSVCRT.DLL
|
||||
rm -f CMakeCache.txt
|
||||
mkdir -p runtimes/win-x86/native
|
||||
docker run --rm dockcross/windows-shared-x86 > docker/dockcross-win-x86
|
||||
docker run --rm dockcross/windows-static-x86 > docker/dockcross-win-x86
|
||||
chmod +x docker/dockcross-win-x86
|
||||
docker/dockcross-win-x86 cmake -DCMAKE_BUILD_TYPE=Release -DAARU_BUILD_PACKAGE=1 .
|
||||
docker/dockcross-win-x86 make Aaru.Compression.Native
|
||||
@@ -222,6 +222,7 @@ if [[ ${OS_NAME} == Darwin ]]; then
|
||||
make Aaru.Compression.Native
|
||||
mkdir -p runtimes/osx-x64/native
|
||||
mv libAaru.Compression.Native.dylib runtimes/osx-x64/native
|
||||
make clean
|
||||
|
||||
rm -f CMakeCache.txt
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DAARU_BUILD_PACKAGE=1 -DAARU_MACOS_TARGET_ARCH=arm64 .
|
||||
|
||||
1
codealike.json
Normal file
1
codealike.json
Normal file
@@ -0,0 +1 @@
|
||||
{"projectId":"748d69bc-5b46-4b80-9066-57e2fbcd92d0","projectName":"Aaru.Compression.Native"}
|
||||
101
flac.c
101
flac.c
@@ -6,29 +6,34 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "library.h"
|
||||
#include "3rdparty/flac/include/FLAC/metadata.h"
|
||||
#include "3rdparty/flac/include/FLAC/stream_decoder.h"
|
||||
#include "3rdparty/flac/include/FLAC/stream_encoder.h"
|
||||
#include "library.h"
|
||||
#include "flac.h"
|
||||
|
||||
static FLAC__StreamDecoderReadStatus
|
||||
read_callback(const FLAC__StreamDecoder* decoder, FLAC__byte buffer[], size_t* bytes, void* client_data);
|
||||
static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder* decoder,
|
||||
const FLAC__Frame* frame,
|
||||
const FLAC__int32* const buffer[],
|
||||
void* client_data);
|
||||
static void
|
||||
error_callback(const FLAC__StreamDecoder* decoder, FLAC__StreamDecoderErrorStatus status, void* client_data);
|
||||
static FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder,
|
||||
FLAC__byte buffer[],
|
||||
size_t * bytes,
|
||||
void * client_data);
|
||||
|
||||
AARU_EXPORT size_t AARU_CALL AARU_flac_decode_redbook_buffer(uint8_t* dst_buffer,
|
||||
static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder,
|
||||
const FLAC__Frame * frame,
|
||||
const FLAC__int32 *const buffer[],
|
||||
void * client_data);
|
||||
|
||||
static void error_callback(const FLAC__StreamDecoder * decoder,
|
||||
FLAC__StreamDecoderErrorStatus status,
|
||||
void * client_data);
|
||||
|
||||
AARU_EXPORT size_t AARU_CALL AARU_flac_decode_redbook_buffer(uint8_t * dst_buffer,
|
||||
size_t dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
const uint8_t *src_buffer,
|
||||
size_t src_size)
|
||||
{
|
||||
FLAC__StreamDecoder* decoder;
|
||||
FLAC__StreamDecoder * decoder;
|
||||
FLAC__StreamDecoderInitStatus init_status;
|
||||
aaru_flac_ctx* ctx = (aaru_flac_ctx*)malloc(sizeof(aaru_flac_ctx));
|
||||
aaru_flac_ctx * ctx = (aaru_flac_ctx *)malloc(sizeof(aaru_flac_ctx));
|
||||
size_t ret_size;
|
||||
|
||||
memset(ctx, 0, sizeof(aaru_flac_ctx));
|
||||
@@ -51,8 +56,16 @@ AARU_EXPORT size_t AARU_CALL AARU_flac_decode_redbook_buffer(uint8_t* dst_
|
||||
|
||||
FLAC__stream_decoder_set_md5_checking(decoder, false);
|
||||
|
||||
init_status = FLAC__stream_decoder_init_stream(
|
||||
decoder, read_callback, NULL, NULL, NULL, NULL, write_callback, NULL, error_callback, ctx);
|
||||
init_status = FLAC__stream_decoder_init_stream(decoder, read_callback, // 1
|
||||
NULL, // 2 seek
|
||||
NULL, // 3 tell
|
||||
NULL, // 4 length
|
||||
NULL, // 5 eof
|
||||
write_callback, // 6 write
|
||||
NULL, // 7 metadata
|
||||
error_callback, // 8 error
|
||||
ctx // 9 client_data
|
||||
);
|
||||
|
||||
if(init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK)
|
||||
{
|
||||
@@ -72,10 +85,12 @@ AARU_EXPORT size_t AARU_CALL AARU_flac_decode_redbook_buffer(uint8_t* dst_
|
||||
return ret_size;
|
||||
}
|
||||
|
||||
static FLAC__StreamDecoderReadStatus
|
||||
read_callback(const FLAC__StreamDecoder* decoder, FLAC__byte buffer[], size_t* bytes, void* client_data)
|
||||
static FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder,
|
||||
FLAC__byte buffer[],
|
||||
size_t * bytes,
|
||||
void * client_data)
|
||||
{
|
||||
aaru_flac_ctx* ctx = (aaru_flac_ctx*)client_data;
|
||||
aaru_flac_ctx *ctx = (aaru_flac_ctx *)client_data;
|
||||
|
||||
if(ctx->src_len - ctx->src_pos < *bytes) *bytes = ctx->src_len - ctx->src_pos;
|
||||
|
||||
@@ -87,14 +102,14 @@ static FLAC__StreamDecoderReadStatus
|
||||
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder* decoder,
|
||||
const FLAC__Frame* frame,
|
||||
const FLAC__int32* const buffer[],
|
||||
void* client_data)
|
||||
static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder,
|
||||
const FLAC__Frame * frame,
|
||||
const FLAC__int32 *const buffer[],
|
||||
void * client_data)
|
||||
{
|
||||
aaru_flac_ctx* ctx = (aaru_flac_ctx*)client_data;
|
||||
aaru_flac_ctx *ctx = (aaru_flac_ctx *)client_data;
|
||||
size_t i;
|
||||
uint16_t* buffer16 = (uint16_t*)(ctx->dst_buffer + ctx->dst_pos);
|
||||
uint16_t * buffer16 = (uint16_t *)(ctx->dst_buffer + ctx->dst_pos);
|
||||
|
||||
// Why FLAC does not interleave the channels as PCM do, oh the mistery, we could use memcpy instead of looping
|
||||
for(i = 0; i < frame->header.blocksize && ctx->dst_pos < ctx->dst_len; i++)
|
||||
@@ -119,47 +134,47 @@ static FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder*
|
||||
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
|
||||
}
|
||||
|
||||
static void error_callback(const FLAC__StreamDecoder* decoder, FLAC__StreamDecoderErrorStatus status, void* client_data)
|
||||
static void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data)
|
||||
{
|
||||
aaru_flac_ctx* ctx = (aaru_flac_ctx*)client_data;
|
||||
aaru_flac_ctx *ctx = (aaru_flac_ctx *)client_data;
|
||||
|
||||
fprintf(stderr, "Got error callback: %s\n", FLAC__StreamDecoderErrorStatusString[status]);
|
||||
|
||||
ctx->error = 1;
|
||||
}
|
||||
|
||||
static FLAC__StreamEncoderWriteStatus encoder_write_callback(const FLAC__StreamEncoder* encoder,
|
||||
static FLAC__StreamEncoderWriteStatus encoder_write_callback(const FLAC__StreamEncoder *encoder,
|
||||
const FLAC__byte buffer[],
|
||||
size_t bytes,
|
||||
uint32_t samples,
|
||||
uint32_t current_frame,
|
||||
void* client_data);
|
||||
void * client_data);
|
||||
|
||||
AARU_EXPORT size_t AARU_CALL AARU_flac_encode_redbook_buffer(uint8_t* dst_buffer,
|
||||
AARU_EXPORT size_t AARU_CALL AARU_flac_encode_redbook_buffer(uint8_t * dst_buffer,
|
||||
size_t dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
const uint8_t *src_buffer,
|
||||
size_t src_size,
|
||||
uint32_t blocksize,
|
||||
int32_t do_mid_side_stereo,
|
||||
int32_t loose_mid_side_stereo,
|
||||
const char* apodization,
|
||||
const char * apodization,
|
||||
uint32_t max_lpc_order,
|
||||
uint32_t qlp_coeff_precision,
|
||||
int32_t do_qlp_coeff_prec_search,
|
||||
int32_t do_exhaustive_model_search,
|
||||
uint32_t min_residual_partition_order,
|
||||
uint32_t max_residual_partition_order,
|
||||
const char* application_id,
|
||||
const char * application_id,
|
||||
uint32_t application_id_len)
|
||||
{
|
||||
FLAC__StreamEncoder* encoder;
|
||||
aaru_flac_ctx* ctx = (aaru_flac_ctx*)malloc(sizeof(aaru_flac_ctx));
|
||||
FLAC__StreamEncoder * encoder;
|
||||
aaru_flac_ctx * ctx = (aaru_flac_ctx *)malloc(sizeof(aaru_flac_ctx));
|
||||
FLAC__StreamEncoderInitStatus init_status;
|
||||
size_t ret_size;
|
||||
FLAC__int32* pcm;
|
||||
FLAC__int32 * pcm;
|
||||
int i;
|
||||
int16_t* buffer16 = (int16_t*)src_buffer;
|
||||
FLAC__StreamMetadata* metadata[1];
|
||||
int16_t * buffer16 = (int16_t *)src_buffer;
|
||||
FLAC__StreamMetadata * metadata[1];
|
||||
|
||||
memset(ctx, 0, sizeof(aaru_flac_ctx));
|
||||
|
||||
@@ -213,8 +228,8 @@ AARU_EXPORT size_t AARU_CALL AARU_flac_encode_redbook_buffer(uint8_t* dst_
|
||||
|
||||
if(application_id_len > 0 && application_id != NULL)
|
||||
if((metadata[0] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_APPLICATION)) != NULL)
|
||||
FLAC__metadata_object_application_set_data(
|
||||
metadata[0], (unsigned char*)application_id, application_id_len, true);
|
||||
FLAC__metadata_object_application_set_data(metadata[0], (unsigned char *)application_id, application_id_len,
|
||||
true);
|
||||
|
||||
FLAC__stream_encoder_set_metadata(encoder, metadata, 1);
|
||||
|
||||
@@ -228,7 +243,7 @@ AARU_EXPORT size_t AARU_CALL AARU_flac_encode_redbook_buffer(uint8_t* dst_
|
||||
|
||||
pcm = malloc((src_size / 2) * sizeof(FLAC__int32));
|
||||
|
||||
for(i = 0; i < src_size / 2; i++) pcm[i] = (FLAC__int32) * (buffer16++);
|
||||
for(i = 0; i < src_size / 2; i++) pcm[i] = (FLAC__int32)*(buffer16++);
|
||||
|
||||
FLAC__stream_encoder_process_interleaved(encoder, pcm, src_size / 4);
|
||||
|
||||
@@ -245,14 +260,14 @@ AARU_EXPORT size_t AARU_CALL AARU_flac_encode_redbook_buffer(uint8_t* dst_
|
||||
return ret_size;
|
||||
}
|
||||
|
||||
static FLAC__StreamEncoderWriteStatus encoder_write_callback(const FLAC__StreamEncoder* encoder,
|
||||
static FLAC__StreamEncoderWriteStatus encoder_write_callback(const FLAC__StreamEncoder *encoder,
|
||||
const FLAC__byte buffer[],
|
||||
size_t bytes,
|
||||
uint32_t samples,
|
||||
uint32_t current_frame,
|
||||
void* client_data)
|
||||
void * client_data)
|
||||
{
|
||||
aaru_flac_ctx* ctx = (aaru_flac_ctx*)client_data;
|
||||
aaru_flac_ctx *ctx = (aaru_flac_ctx *)client_data;
|
||||
|
||||
if(bytes > ctx->dst_len - ctx->dst_pos) bytes = ctx->dst_len - ctx->dst_pos;
|
||||
|
||||
|
||||
6
flac.h
6
flac.h
@@ -7,13 +7,13 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const uint8_t* src_buffer;
|
||||
const uint8_t *src_buffer;
|
||||
size_t src_len;
|
||||
size_t src_pos;
|
||||
uint8_t* dst_buffer;
|
||||
uint8_t *dst_buffer;
|
||||
size_t dst_len;
|
||||
size_t dst_pos;
|
||||
uint8_t error;
|
||||
} aaru_flac_ctx;
|
||||
|
||||
#endif // AARU_COMPRESSION_NATIVE__FLAC_H_
|
||||
#endif // AARU_COMPRESSION_NATIVE__FLAC_H_
|
||||
|
||||
79
library.c
79
library.c
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Aaru Data Preservation Suite.
|
||||
* Copyright (c) 2019-2023 Natalia Portillo.
|
||||
* Copyright (c) 2019-2025 Natalia Portillo.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
@@ -25,86 +25,59 @@
|
||||
#include "3rdparty/lzma/C/LzmaLib.h"
|
||||
#include "3rdparty/zstd/lib/zstd.h"
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_bzip2_decode_buffer(uint8_t* dst_buffer,
|
||||
uint32_t* dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
uint32_t src_size)
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_bzip2_decode_buffer(uint8_t *dst_buffer, uint32_t *dst_size,
|
||||
const uint8_t *src_buffer, uint32_t src_size)
|
||||
{
|
||||
return BZ2_bzBuffToBuffDecompress((char*)dst_buffer, dst_size, (char*)src_buffer, src_size, 0, 0);
|
||||
return BZ2_bzBuffToBuffDecompress((char *)dst_buffer, dst_size, (char *)src_buffer, src_size, 0, 0);
|
||||
}
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_bzip2_encode_buffer(uint8_t* dst_buffer,
|
||||
uint32_t* dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
uint32_t src_size,
|
||||
int32_t blockSize100k)
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_bzip2_encode_buffer(uint8_t *dst_buffer, uint32_t *dst_size,
|
||||
const uint8_t *src_buffer, uint32_t src_size,
|
||||
int32_t blockSize100k)
|
||||
{
|
||||
return BZ2_bzBuffToBuffCompress((char*)dst_buffer, dst_size, (char*)src_buffer, src_size, blockSize100k, 0, 0);
|
||||
return BZ2_bzBuffToBuffCompress((char *)dst_buffer, dst_size, (char *)src_buffer, src_size, blockSize100k, 0, 0);
|
||||
}
|
||||
|
||||
AARU_EXPORT size_t AARU_CALL AARU_lzfse_decode_buffer(uint8_t* dst_buffer,
|
||||
size_t dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
size_t src_size,
|
||||
void* scratch_buffer)
|
||||
AARU_EXPORT size_t AARU_CALL AARU_lzfse_decode_buffer(uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer,
|
||||
size_t src_size, void *scratch_buffer)
|
||||
{
|
||||
return lzfse_decode_buffer(dst_buffer, dst_size, src_buffer, src_size, scratch_buffer);
|
||||
}
|
||||
AARU_EXPORT size_t AARU_CALL AARU_lzfse_encode_buffer(uint8_t* dst_buffer,
|
||||
size_t dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
size_t src_size,
|
||||
void* scratch_buffer)
|
||||
|
||||
AARU_EXPORT size_t AARU_CALL AARU_lzfse_encode_buffer(uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer,
|
||||
size_t src_size, void *scratch_buffer)
|
||||
{
|
||||
return lzfse_encode_buffer(dst_buffer, dst_size, src_buffer, src_size, scratch_buffer);
|
||||
}
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_lzma_decode_buffer(uint8_t* dst_buffer,
|
||||
size_t* dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
size_t* srcLen,
|
||||
const uint8_t* props,
|
||||
size_t propsSize)
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_lzma_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
|
||||
size_t *srcLen, const uint8_t *props, size_t propsSize)
|
||||
{
|
||||
return LzmaUncompress(dst_buffer, dst_size, src_buffer, srcLen, props, propsSize);
|
||||
}
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_lzma_encode_buffer(uint8_t* dst_buffer,
|
||||
size_t* dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
size_t srcLen,
|
||||
uint8_t* outProps,
|
||||
size_t* outPropsSize,
|
||||
int32_t level,
|
||||
uint32_t dictSize,
|
||||
int32_t lc,
|
||||
int32_t lp,
|
||||
int32_t pb,
|
||||
int32_t fb,
|
||||
int32_t numThreads)
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_lzma_encode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
|
||||
size_t srcLen, uint8_t *outProps, size_t *outPropsSize,
|
||||
int32_t level, uint32_t dictSize, int32_t lc, int32_t lp,
|
||||
int32_t pb, int32_t fb, int32_t numThreads)
|
||||
{
|
||||
return LzmaCompress(
|
||||
dst_buffer, dst_size, src_buffer, srcLen, outProps, outPropsSize, level, dictSize, lc, lp, pb, fb, numThreads);
|
||||
return LzmaCompress(dst_buffer, dst_size, src_buffer, srcLen, outProps, outPropsSize, level, dictSize, lc, lp, pb,
|
||||
fb, numThreads);
|
||||
}
|
||||
|
||||
AARU_EXPORT size_t AARU_CALL AARU_zstd_decode_buffer(void* dst_buffer,
|
||||
size_t dst_size,
|
||||
const void* src_buffer,
|
||||
size_t src_size)
|
||||
AARU_EXPORT size_t AARU_CALL AARU_zstd_decode_buffer(void *dst_buffer, size_t dst_size, const void *src_buffer,
|
||||
size_t src_size)
|
||||
{
|
||||
return ZSTD_decompress(dst_buffer, dst_size, src_buffer, src_size);
|
||||
}
|
||||
|
||||
AARU_EXPORT size_t AARU_CALL AARU_zstd_encode_buffer(void* dst_buffer,
|
||||
size_t dst_size,
|
||||
const void* src_buffer,
|
||||
size_t src_size,
|
||||
int32_t compressionLevel)
|
||||
AARU_EXPORT size_t AARU_CALL AARU_zstd_encode_buffer(void *dst_buffer, size_t dst_size, const void *src_buffer,
|
||||
size_t src_size, int32_t compressionLevel)
|
||||
{
|
||||
return ZSTD_compress(dst_buffer, dst_size, src_buffer, src_size, compressionLevel);
|
||||
}
|
||||
|
||||
// This is required if BZ_NO_STDIO
|
||||
void bz_internal_error ( int errcode ) { }
|
||||
void bz_internal_error(int errcode) {}
|
||||
|
||||
AARU_EXPORT uint64_t AARU_CALL AARU_get_acn_version() { return AARU_CHECKUMS_NATIVE_VERSION; }
|
||||
139
library.h
139
library.h
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Aaru Data Preservation Suite.
|
||||
* Copyright (c) 2019-2023 Natalia Portillo.
|
||||
* Copyright (c) 2019-2025 Natalia Portillo.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
@@ -26,7 +26,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define AARU_CALL __stdcall
|
||||
#define AARU_CALL __stdcall
|
||||
#define AARU_EXPORT EXTERNC __declspec(dllexport)
|
||||
#define AARU_LOCAL
|
||||
#ifndef PATH_MAX
|
||||
@@ -36,11 +36,11 @@
|
||||
#define AARU_CALL
|
||||
#if defined(__APPLE__)
|
||||
#define AARU_EXPORT EXTERNC __attribute__((visibility("default")))
|
||||
#define AARU_LOCAL __attribute__((visibility("hidden")))
|
||||
#define AARU_LOCAL __attribute__((visibility("hidden")))
|
||||
#else
|
||||
#if __GNUC__ >= 4
|
||||
#define AARU_EXPORT EXTERNC __attribute__((visibility("default")))
|
||||
#define AARU_LOCAL __attribute__((visibility("hidden")))
|
||||
#define AARU_LOCAL __attribute__((visibility("hidden")))
|
||||
#else
|
||||
#define AARU_EXPORT EXTERNC
|
||||
#define AARU_LOCAL
|
||||
@@ -54,107 +54,66 @@
|
||||
#define FORCE_INLINE static inline __attribute__((always_inline))
|
||||
#endif
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_adc_decode_buffer(uint8_t* dst_buffer,
|
||||
int32_t dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
int32_t src_size);
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_adc_decode_buffer(uint8_t *dst_buffer, int32_t dst_size, const uint8_t *src_buffer,
|
||||
int32_t src_size);
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_apple_rle_decode_buffer(uint8_t* dst_buffer,
|
||||
int32_t dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
int32_t src_size);
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_apple_rle_decode_buffer(uint8_t *dst_buffer, int32_t dst_size,
|
||||
const uint8_t *src_buffer, int32_t src_size);
|
||||
|
||||
AARU_EXPORT size_t AARU_CALL AARU_flac_decode_redbook_buffer(uint8_t* dst_buffer,
|
||||
size_t dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
size_t src_size);
|
||||
AARU_EXPORT size_t AARU_CALL AARU_flac_decode_redbook_buffer(uint8_t *dst_buffer, size_t dst_size,
|
||||
const uint8_t *src_buffer, size_t src_size);
|
||||
|
||||
AARU_EXPORT size_t AARU_CALL AARU_flac_encode_redbook_buffer(uint8_t* dst_buffer,
|
||||
size_t dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
size_t src_size,
|
||||
uint32_t blocksize,
|
||||
int32_t do_mid_side_stereo,
|
||||
int32_t loose_mid_side_stereo,
|
||||
const char* apodization,
|
||||
uint32_t max_lpc_order,
|
||||
uint32_t qlp_coeff_precision,
|
||||
int32_t do_qlp_coeff_prec_search,
|
||||
int32_t do_exhaustive_model_search,
|
||||
uint32_t min_residual_partition_order,
|
||||
uint32_t max_residual_partition_order,
|
||||
const char* application_id,
|
||||
uint32_t application_id_len);
|
||||
AARU_EXPORT size_t AARU_CALL AARU_flac_encode_redbook_buffer(
|
||||
uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer, size_t src_size, uint32_t blocksize,
|
||||
int32_t do_mid_side_stereo, int32_t loose_mid_side_stereo, const char *apodization, uint32_t max_lpc_order,
|
||||
uint32_t qlp_coeff_precision, int32_t do_qlp_coeff_prec_search, int32_t do_exhaustive_model_search,
|
||||
uint32_t min_residual_partition_order, uint32_t max_residual_partition_order, const char *application_id,
|
||||
uint32_t application_id_len);
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_lzip_decode_buffer(uint8_t* dst_buffer,
|
||||
int32_t dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
int32_t src_size);
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_lzip_decode_buffer(uint8_t *dst_buffer, int32_t dst_size, const uint8_t *src_buffer,
|
||||
int32_t src_size);
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_lzip_encode_buffer(uint8_t* dst_buffer,
|
||||
int32_t dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
int32_t src_size,
|
||||
int32_t dictionary_size,
|
||||
int32_t match_len_limit);
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_lzip_encode_buffer(uint8_t *dst_buffer, int32_t dst_size, const uint8_t *src_buffer,
|
||||
int32_t src_size, int32_t dictionary_size,
|
||||
int32_t match_len_limit);
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_bzip2_decode_buffer(uint8_t* dst_buffer,
|
||||
uint32_t* dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
uint32_t src_size);
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_bzip2_decode_buffer(uint8_t *dst_buffer, uint32_t *dst_size,
|
||||
const uint8_t *src_buffer, uint32_t src_size);
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_bzip2_encode_buffer(uint8_t* dst_buffer,
|
||||
uint32_t* dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
uint32_t src_size,
|
||||
int32_t blockSize100k);
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_bzip2_encode_buffer(uint8_t *dst_buffer, uint32_t *dst_size,
|
||||
const uint8_t *src_buffer, uint32_t src_size,
|
||||
int32_t blockSize100k);
|
||||
|
||||
AARU_EXPORT size_t AARU_CALL AARU_lzfse_decode_buffer(uint8_t* dst_buffer,
|
||||
size_t dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
size_t src_size,
|
||||
void* scratch_buffer);
|
||||
AARU_EXPORT size_t AARU_CALL AARU_lzfse_decode_buffer(uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer,
|
||||
size_t src_size, void *scratch_buffer);
|
||||
|
||||
AARU_EXPORT size_t AARU_CALL AARU_lzfse_encode_buffer(uint8_t* dst_buffer,
|
||||
size_t dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
size_t src_size,
|
||||
void* scratch_buffer);
|
||||
AARU_EXPORT size_t AARU_CALL AARU_lzfse_encode_buffer(uint8_t *dst_buffer, size_t dst_size, const uint8_t *src_buffer,
|
||||
size_t src_size, void *scratch_buffer);
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_lzma_decode_buffer(uint8_t* dst_buffer,
|
||||
size_t* dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
size_t* src_size,
|
||||
const uint8_t* props,
|
||||
size_t propsSize);
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_lzma_decode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
|
||||
size_t *src_size, const uint8_t *props, size_t propsSize);
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_lzma_encode_buffer(uint8_t* dst_buffer,
|
||||
size_t* dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
size_t src_size,
|
||||
uint8_t* outProps,
|
||||
size_t* outPropsSize,
|
||||
int32_t level,
|
||||
uint32_t dictSize,
|
||||
int32_t lc,
|
||||
int32_t lp,
|
||||
int32_t pb,
|
||||
int32_t fb,
|
||||
int32_t numThreads);
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_lzma_encode_buffer(uint8_t *dst_buffer, size_t *dst_size, const uint8_t *src_buffer,
|
||||
size_t src_size, uint8_t *outProps, size_t *outPropsSize,
|
||||
int32_t level, uint32_t dictSize, int32_t lc, int32_t lp,
|
||||
int32_t pb, int32_t fb, int32_t numThreads);
|
||||
|
||||
AARU_EXPORT size_t AARU_CALL AARU_zstd_decode_buffer(void* dst_buffer,
|
||||
size_t dst_size,
|
||||
const void* src_buffer,
|
||||
size_t src_size);
|
||||
AARU_EXPORT size_t AARU_CALL AARU_zstd_decode_buffer(void *dst_buffer, size_t dst_size, const void *src_buffer,
|
||||
size_t src_size);
|
||||
|
||||
AARU_EXPORT size_t AARU_CALL AARU_zstd_encode_buffer(void* dst_buffer,
|
||||
size_t dst_size,
|
||||
const void* src_buffer,
|
||||
size_t src_size,
|
||||
int32_t compressionLevel);
|
||||
AARU_EXPORT size_t AARU_CALL AARU_zstd_encode_buffer(void *dst_buffer, size_t dst_size, const void *src_buffer,
|
||||
size_t src_size, int32_t compressionLevel);
|
||||
|
||||
AARU_EXPORT void AARU_CALL *CreateLZDContext(void);
|
||||
|
||||
AARU_EXPORT void AARU_CALL DestroyLZDContext(void *ctx);
|
||||
|
||||
AARU_EXPORT int AARU_CALL LZD_FeedNative(void *ctx, const unsigned char *data, size_t length);
|
||||
|
||||
AARU_EXPORT int AARU_CALL LZD_DrainNative(void *ctx, unsigned char *outBuf, size_t outBufLen, size_t *produced);
|
||||
|
||||
#define AARU_CHECKUMS_NATIVE_VERSION 0x06000089
|
||||
|
||||
AARU_EXPORT uint64_t AARU_CALL AARU_get_acn_version();
|
||||
|
||||
#endif // AARU_COMPRESSION_NATIVE_LIBRARY_H
|
||||
#endif // AARU_COMPRESSION_NATIVE_LIBRARY_H
|
||||
|
||||
21
lzip.c
21
lzip.c
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Aaru Data Preservation Suite.
|
||||
* Copyright (c) 2019-2023 Natalia Portillo.
|
||||
* Copyright (c) 2019-2025 Natalia Portillo.
|
||||
* Copyright © 2018-2019 David Ryskalczyk
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
@@ -23,13 +23,11 @@
|
||||
#include "library.h"
|
||||
#include "3rdparty/lzlib/lzlib.h"
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_lzip_decode_buffer(uint8_t* dst_buffer,
|
||||
int32_t dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
int32_t src_size)
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_lzip_decode_buffer(uint8_t *dst_buffer, int32_t dst_size, const uint8_t *src_buffer,
|
||||
int32_t src_size)
|
||||
{
|
||||
int max_in_size;
|
||||
void* ctx;
|
||||
void *ctx;
|
||||
enum LZ_Errno lz_err;
|
||||
int32_t in_pos = 0, out_pos = 0, in_size;
|
||||
int rd;
|
||||
@@ -83,15 +81,12 @@ AARU_EXPORT int32_t AARU_CALL AARU_lzip_decode_buffer(uint8_t* dst_buffer,
|
||||
return out_pos;
|
||||
}
|
||||
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_lzip_encode_buffer(uint8_t* dst_buffer,
|
||||
int32_t dst_size,
|
||||
const uint8_t* src_buffer,
|
||||
int32_t src_size,
|
||||
int32_t dictionary_size,
|
||||
int32_t match_len_limit)
|
||||
AARU_EXPORT int32_t AARU_CALL AARU_lzip_encode_buffer(uint8_t *dst_buffer, int32_t dst_size, const uint8_t *src_buffer,
|
||||
int32_t src_size, int32_t dictionary_size,
|
||||
int32_t match_len_limit)
|
||||
{
|
||||
int max_in_size;
|
||||
void* ctx;
|
||||
void *ctx;
|
||||
enum LZ_Errno lz_err;
|
||||
int32_t in_pos = 0, out_pos = 0, in_size;
|
||||
int rd;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
if("${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW" OR "${AARU_BUILD_PACKAGE}" MATCHES 1)
|
||||
return()
|
||||
return()
|
||||
endif()
|
||||
|
||||
# 'Google_test' is the subproject name
|
||||
@@ -39,7 +39,11 @@ file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/audio.bin
|
||||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/data.bin
|
||||
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/)
|
||||
|
||||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data/alice29.lzd
|
||||
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/)
|
||||
|
||||
# 'Google_Tests_run' is the target name
|
||||
# 'test1.cpp tests2.cpp' are source files with tests
|
||||
add_executable(tests_run apple_rle.cpp crc32.c crc32.h adc.cpp bzip2.cpp lzip.cpp lzfse.cpp zstd.cpp lzma.cpp flac.cpp)
|
||||
add_executable(tests_run apple_rle.cpp crc32.c crc32.h adc.cpp bzip2.cpp lzip.cpp lzfse.cpp zstd.cpp lzma.cpp flac.cpp
|
||||
zoo/lzd.cpp)
|
||||
target_link_libraries(tests_run gtest gtest_main "Aaru.Compression.Native")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Aaru Data Preservation Suite.
|
||||
* Copyright (c) 2019-2023 Natalia Portillo.
|
||||
* Copyright (c) 2019-2025 Natalia Portillo.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
@@ -20,25 +20,25 @@
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
#include "../adc.h"
|
||||
#include "../library.h"
|
||||
#include "../adc.h"
|
||||
#include "crc32.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#define EXPECTED_CRC32 0x5a5a7388
|
||||
|
||||
static const uint8_t* buffer;
|
||||
static const uint8_t *buffer;
|
||||
|
||||
class adcFixture : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
public:
|
||||
adcFixture()
|
||||
{
|
||||
// initialization;
|
||||
// can also be done in SetUp()
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void SetUp()
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
@@ -47,13 +47,13 @@ class adcFixture : public ::testing::Test
|
||||
getcwd(path, PATH_MAX);
|
||||
snprintf(filename, PATH_MAX, "%s/data/adc.bin", path);
|
||||
|
||||
FILE* file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t*)malloc(34367);
|
||||
fread((void*)buffer, 1, 34367, file);
|
||||
FILE *file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t *)malloc(34367);
|
||||
fread((void *)buffer, 1, 34367, file);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
void TearDown() { free((void*)buffer); }
|
||||
void TearDown() { free((void *)buffer); }
|
||||
|
||||
~adcFixture()
|
||||
{
|
||||
@@ -65,7 +65,7 @@ class adcFixture : public ::testing::Test
|
||||
|
||||
TEST_F(adcFixture, adc)
|
||||
{
|
||||
auto* outBuf = (uint8_t*)malloc(327680);
|
||||
auto *outBuf = (uint8_t *)malloc(327680);
|
||||
|
||||
auto decoded = AARU_adc_decode_buffer(outBuf, 327680, buffer, 34367);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Aaru Data Preservation Suite.
|
||||
* Copyright (c) 2019-2023 Natalia Portillo.
|
||||
* Copyright (c) 2019-2025 Natalia Portillo.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
@@ -20,25 +20,25 @@
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
#include "../apple_rle.h"
|
||||
#include "../library.h"
|
||||
#include "../apple_rle.h"
|
||||
#include "crc32.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#define EXPECTED_CRC32 0x3525ef06
|
||||
|
||||
static const uint8_t* buffer;
|
||||
static const uint8_t *buffer;
|
||||
|
||||
class apple_rleFixture : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
public:
|
||||
apple_rleFixture()
|
||||
{
|
||||
// initialization;
|
||||
// can also be done in SetUp()
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void SetUp()
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
@@ -47,13 +47,13 @@ class apple_rleFixture : public ::testing::Test
|
||||
getcwd(path, PATH_MAX);
|
||||
snprintf(filename, PATH_MAX, "%s/data/apple_rle.bin", path);
|
||||
|
||||
FILE* file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t*)malloc(1102);
|
||||
fread((void*)buffer, 1, 1102, file);
|
||||
FILE *file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t *)malloc(1102);
|
||||
fread((void *)buffer, 1, 1102, file);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
void TearDown() { free((void*)buffer); }
|
||||
void TearDown() { free((void *)buffer); }
|
||||
|
||||
~apple_rleFixture()
|
||||
{
|
||||
@@ -65,7 +65,7 @@ class apple_rleFixture : public ::testing::Test
|
||||
|
||||
TEST_F(apple_rleFixture, apple_rle)
|
||||
{
|
||||
auto* outBuf = (uint8_t*)malloc(32768);
|
||||
auto *outBuf = (uint8_t *)malloc(32768);
|
||||
|
||||
auto decoded = AARU_apple_rle_decode_buffer(outBuf, 32768, buffer, 1102);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Aaru Data Preservation Suite.
|
||||
* Copyright (c) 2019-2023 Natalia Portillo.
|
||||
* Copyright (c) 2019-2025 Natalia Portillo.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
@@ -26,18 +26,18 @@
|
||||
|
||||
#define EXPECTED_CRC32 0xc64059c0
|
||||
|
||||
static const uint8_t* buffer;
|
||||
static const uint8_t *buffer;
|
||||
|
||||
class bzip2Fixture : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
public:
|
||||
bzip2Fixture()
|
||||
{
|
||||
// initialization;
|
||||
// can also be done in SetUp()
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void SetUp()
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
@@ -46,13 +46,13 @@ class bzip2Fixture : public ::testing::Test
|
||||
getcwd(path, PATH_MAX);
|
||||
snprintf(filename, PATH_MAX, "%s/data/bzip2.bz2", path);
|
||||
|
||||
FILE* file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t*)malloc(1053934);
|
||||
fread((void*)buffer, 1, 1053934, file);
|
||||
FILE *file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t *)malloc(1053934);
|
||||
fread((void *)buffer, 1, 1053934, file);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
void TearDown() { free((void*)buffer); }
|
||||
void TearDown() { free((void *)buffer); }
|
||||
|
||||
~bzip2Fixture()
|
||||
{
|
||||
@@ -65,7 +65,7 @@ class bzip2Fixture : public ::testing::Test
|
||||
TEST_F(bzip2Fixture, bzip2)
|
||||
{
|
||||
uint real_size = 1048576;
|
||||
auto* outBuf = (uint8_t*)malloc(1048576);
|
||||
auto *outBuf = (uint8_t *)malloc(1048576);
|
||||
|
||||
auto bz_err = AARU_bzip2_decode_buffer(outBuf, &real_size, buffer, 1053934);
|
||||
|
||||
@@ -87,24 +87,24 @@ TEST_F(bzip2Fixture, bzip2Compress)
|
||||
uint decmp_len = original_len;
|
||||
char path[PATH_MAX];
|
||||
char filename[PATH_MAX * 2];
|
||||
FILE* file;
|
||||
FILE *file;
|
||||
uint32_t original_crc, decmp_crc;
|
||||
int bz_err;
|
||||
const uint8_t* original;
|
||||
uint8_t* cmp_buffer;
|
||||
uint8_t* decmp_buffer;
|
||||
const uint8_t *original;
|
||||
uint8_t *cmp_buffer;
|
||||
uint8_t *decmp_buffer;
|
||||
|
||||
// Allocate buffers
|
||||
original = (const uint8_t*)malloc(original_len);
|
||||
cmp_buffer = (uint8_t*)malloc(cmp_len);
|
||||
decmp_buffer = (uint8_t*)malloc(decmp_len);
|
||||
original = (const uint8_t *)malloc(original_len);
|
||||
cmp_buffer = (uint8_t *)malloc(cmp_len);
|
||||
decmp_buffer = (uint8_t *)malloc(decmp_len);
|
||||
|
||||
// Read the file
|
||||
getcwd(path, PATH_MAX);
|
||||
snprintf(filename, PATH_MAX, "%s/data/data.bin", path);
|
||||
|
||||
file = fopen(filename, "rb");
|
||||
fread((void*)original, 1, original_len, file);
|
||||
fread((void *)original, 1, original_len, file);
|
||||
fclose(file);
|
||||
|
||||
// Calculate the CRC
|
||||
@@ -125,7 +125,7 @@ TEST_F(bzip2Fixture, bzip2Compress)
|
||||
decmp_crc = crc32_data(decmp_buffer, decmp_len);
|
||||
|
||||
// Free buffers
|
||||
free((void*)original);
|
||||
free((void *)original);
|
||||
free(cmp_buffer);
|
||||
free(decmp_buffer);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Aaru Data Preservation Suite.
|
||||
* Copyright (c) 2019-2023 Natalia Portillo.
|
||||
* Copyright (c) 2019-2025 Natalia Portillo.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
@@ -19,37 +19,38 @@
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define CRC32_ISO_POLY 0xEDB88320
|
||||
#define CRC32_ISO_SEED 0xFFFFFFFF
|
||||
|
||||
uint32_t crc32_data(const uint8_t *data, uint32_t len)
|
||||
{
|
||||
uint32_t localHashInt = CRC32_ISO_SEED;
|
||||
uint32_t localTable[256];
|
||||
int i, j;
|
||||
|
||||
for(i = 0; i < 256; i++)
|
||||
uint32_t crc32_data(const uint8_t *data, uint32_t len)
|
||||
{
|
||||
uint32_t entry = (uint32_t)i;
|
||||
uint32_t localHashInt = CRC32_ISO_SEED;
|
||||
uint32_t localTable[256];
|
||||
int i, j;
|
||||
|
||||
for(j = 0; j < 8; j++)
|
||||
if((entry & 1) == 1)
|
||||
entry = (entry >> 1) ^ CRC32_ISO_POLY;
|
||||
else
|
||||
entry >>= 1;
|
||||
for(i = 0; i < 256; i++)
|
||||
{
|
||||
uint32_t entry = (uint32_t)i;
|
||||
|
||||
localTable[i] = entry;
|
||||
for(j = 0; j < 8; j++)
|
||||
if((entry & 1) == 1)
|
||||
entry = (entry >> 1) ^ CRC32_ISO_POLY;
|
||||
else
|
||||
entry >>= 1;
|
||||
|
||||
localTable[i] = entry;
|
||||
}
|
||||
|
||||
for(i = 0; i < len; i++) localHashInt = (localHashInt >> 8) ^ localTable[data[i] ^ (localHashInt & 0xff)];
|
||||
|
||||
localHashInt ^= CRC32_ISO_SEED;
|
||||
|
||||
return localHashInt;
|
||||
}
|
||||
|
||||
for(i = 0; i < len; i++)
|
||||
localHashInt = (localHashInt >> 8) ^ localTable[data[i] ^ (localHashInt & 0xff)];
|
||||
|
||||
localHashInt ^= CRC32_ISO_SEED;
|
||||
|
||||
return localHashInt;
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Aaru Data Preservation Suite.
|
||||
* Copyright (c) 2019-2023 Natalia Portillo.
|
||||
* Copyright (c) 2019-2025 Natalia Portillo.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
@@ -23,8 +23,9 @@ extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
uint32_t crc32_data(const uint8_t* data, uint32_t len);
|
||||
uint32_t crc32_data(const uint8_t *data, uint32_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // AARU_CHECKSUMS_NATIVE_TESTS_CRC32_H_
|
||||
#endif // AARU_CHECKSUMS_NATIVE_TESTS_CRC32_H_
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Aaru Data Preservation Suite.
|
||||
* Copyright (c) 2019-2023 Natalia Portillo.
|
||||
* Copyright (c) 2019-2025 Natalia Portillo.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
@@ -20,25 +20,25 @@
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "../flac.h"
|
||||
#include "../library.h"
|
||||
#include "../flac.h"
|
||||
#include "crc32.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#define EXPECTED_CRC32 0xdfbc99bb
|
||||
|
||||
static const uint8_t* buffer;
|
||||
static const uint8_t *buffer;
|
||||
|
||||
class flacFixture : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
public:
|
||||
flacFixture()
|
||||
{
|
||||
// initialization;
|
||||
// can also be done in SetUp()
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void SetUp()
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
@@ -47,13 +47,13 @@ class flacFixture : public ::testing::Test
|
||||
getcwd(path, PATH_MAX);
|
||||
snprintf(filename, PATH_MAX, "%s/data/flac.flac", path);
|
||||
|
||||
FILE* file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t*)malloc(6534197);
|
||||
fread((void*)buffer, 1, 6534197, file);
|
||||
FILE *file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t *)malloc(6534197);
|
||||
fread((void *)buffer, 1, 6534197, file);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
void TearDown() { free((void*)buffer); }
|
||||
void TearDown() { free((void *)buffer); }
|
||||
|
||||
~flacFixture()
|
||||
{
|
||||
@@ -65,7 +65,7 @@ class flacFixture : public ::testing::Test
|
||||
|
||||
TEST_F(flacFixture, flac)
|
||||
{
|
||||
auto* outBuf = (uint8_t*)malloc(9633792);
|
||||
auto *outBuf = (uint8_t *)malloc(9633792);
|
||||
|
||||
auto decoded = AARU_flac_decode_redbook_buffer(outBuf, 9633792, buffer, 6534197);
|
||||
|
||||
@@ -85,46 +85,33 @@ TEST_F(flacFixture, flacCompress)
|
||||
uint decmp_len = original_len;
|
||||
char path[PATH_MAX];
|
||||
char filename[PATH_MAX * 2];
|
||||
FILE* file;
|
||||
FILE *file;
|
||||
uint32_t original_crc, decmp_crc;
|
||||
const uint8_t* original;
|
||||
uint8_t* cmp_buffer;
|
||||
uint8_t* decmp_buffer;
|
||||
const uint8_t *original;
|
||||
uint8_t *cmp_buffer;
|
||||
uint8_t *decmp_buffer;
|
||||
size_t newSize;
|
||||
|
||||
// Allocate buffers
|
||||
original = (const uint8_t*)malloc(original_len);
|
||||
cmp_buffer = (uint8_t*)malloc(cmp_len);
|
||||
decmp_buffer = (uint8_t*)malloc(decmp_len);
|
||||
original = (const uint8_t *)malloc(original_len);
|
||||
cmp_buffer = (uint8_t *)malloc(cmp_len);
|
||||
decmp_buffer = (uint8_t *)malloc(decmp_len);
|
||||
|
||||
// Read the file
|
||||
getcwd(path, PATH_MAX);
|
||||
snprintf(filename, PATH_MAX, "%s/data/audio.bin", path);
|
||||
|
||||
file = fopen(filename, "rb");
|
||||
fread((void*)original, 1, original_len, file);
|
||||
fread((void *)original, 1, original_len, file);
|
||||
fclose(file);
|
||||
|
||||
// Calculate the CRC
|
||||
original_crc = crc32_data(original, original_len);
|
||||
|
||||
// Compress
|
||||
newSize = AARU_flac_encode_redbook_buffer(cmp_buffer,
|
||||
cmp_len,
|
||||
original,
|
||||
original_len,
|
||||
4608,
|
||||
1,
|
||||
0,
|
||||
"partial_tukey(0/1.0/1.0)",
|
||||
12,
|
||||
0,
|
||||
1,
|
||||
false,
|
||||
0,
|
||||
8,
|
||||
"Aaru.Compression.Native.Tests",
|
||||
strlen("Aaru.Compression.Native.Tests"));
|
||||
newSize = AARU_flac_encode_redbook_buffer(cmp_buffer, cmp_len, original, original_len, 4608, 1, 0,
|
||||
"partial_tukey(0/1.0/1.0)", 12, 0, 1, false, 0, 8,
|
||||
"Aaru.Compression.Native.Tests", strlen("Aaru.Compression.Native.Tests"));
|
||||
cmp_len = newSize;
|
||||
|
||||
// Decompress
|
||||
@@ -136,7 +123,7 @@ TEST_F(flacFixture, flacCompress)
|
||||
decmp_crc = crc32_data(decmp_buffer, decmp_len);
|
||||
|
||||
// Free buffers
|
||||
free((void*)original);
|
||||
free((void *)original);
|
||||
free(cmp_buffer);
|
||||
free(decmp_buffer);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Aaru Data Preservation Suite.
|
||||
* Copyright (c) 2019-2023 Natalia Portillo.
|
||||
* Copyright (c) 2019-2025 Natalia Portillo.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
@@ -26,18 +26,18 @@
|
||||
|
||||
#define EXPECTED_CRC32 0xc64059c0
|
||||
|
||||
static const uint8_t* buffer;
|
||||
static const uint8_t *buffer;
|
||||
|
||||
class lzfseFixture : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
public:
|
||||
lzfseFixture()
|
||||
{
|
||||
// initialization;
|
||||
// can also be done in SetUp()
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void SetUp()
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
@@ -46,13 +46,13 @@ class lzfseFixture : public ::testing::Test
|
||||
getcwd(path, PATH_MAX);
|
||||
snprintf(filename, PATH_MAX, "%s/data/lzfse.bin", path);
|
||||
|
||||
FILE* file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t*)malloc(1059299);
|
||||
fread((void*)buffer, 1, 1059299, file);
|
||||
FILE *file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t *)malloc(1059299);
|
||||
fread((void *)buffer, 1, 1059299, file);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
void TearDown() { free((void*)buffer); }
|
||||
void TearDown() { free((void *)buffer); }
|
||||
|
||||
~lzfseFixture()
|
||||
{
|
||||
@@ -64,7 +64,7 @@ class lzfseFixture : public ::testing::Test
|
||||
|
||||
TEST_F(lzfseFixture, lzfse)
|
||||
{
|
||||
auto* outBuf = (uint8_t*)malloc(1048576);
|
||||
auto *outBuf = (uint8_t *)malloc(1048576);
|
||||
|
||||
auto decoded = AARU_lzfse_decode_buffer(outBuf, 1048576, buffer, 1059299, nullptr);
|
||||
|
||||
@@ -84,24 +84,24 @@ TEST_F(lzfseFixture, lzfseCompress)
|
||||
uint decmp_len = original_len;
|
||||
char path[PATH_MAX];
|
||||
char filename[PATH_MAX * 2];
|
||||
FILE* file;
|
||||
FILE *file;
|
||||
uint32_t original_crc, decmp_crc;
|
||||
const uint8_t* original;
|
||||
uint8_t* cmp_buffer;
|
||||
uint8_t* decmp_buffer;
|
||||
const uint8_t *original;
|
||||
uint8_t *cmp_buffer;
|
||||
uint8_t *decmp_buffer;
|
||||
size_t newSize;
|
||||
|
||||
// Allocate buffers
|
||||
original = (const uint8_t*)malloc(original_len);
|
||||
cmp_buffer = (uint8_t*)malloc(cmp_len);
|
||||
decmp_buffer = (uint8_t*)malloc(decmp_len);
|
||||
original = (const uint8_t *)malloc(original_len);
|
||||
cmp_buffer = (uint8_t *)malloc(cmp_len);
|
||||
decmp_buffer = (uint8_t *)malloc(decmp_len);
|
||||
|
||||
// Read the file
|
||||
getcwd(path, PATH_MAX);
|
||||
snprintf(filename, PATH_MAX, "%s/data/data.bin", path);
|
||||
|
||||
file = fopen(filename, "rb");
|
||||
fread((void*)original, 1, original_len, file);
|
||||
fread((void *)original, 1, original_len, file);
|
||||
fclose(file);
|
||||
|
||||
// Calculate the CRC
|
||||
@@ -120,7 +120,7 @@ TEST_F(lzfseFixture, lzfseCompress)
|
||||
decmp_crc = crc32_data(decmp_buffer, decmp_len);
|
||||
|
||||
// Free buffers
|
||||
free((void*)original);
|
||||
free((void *)original);
|
||||
free(cmp_buffer);
|
||||
free(decmp_buffer);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Aaru Data Preservation Suite.
|
||||
* Copyright (c) 2019-2023 Natalia Portillo.
|
||||
* Copyright (c) 2019-2025 Natalia Portillo.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
@@ -26,18 +26,18 @@
|
||||
|
||||
#define EXPECTED_CRC32 0xc64059c0
|
||||
|
||||
static const uint8_t* buffer;
|
||||
static const uint8_t *buffer;
|
||||
|
||||
class lzipFixture : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
public:
|
||||
lzipFixture()
|
||||
{
|
||||
// initialization;
|
||||
// can also be done in SetUp()
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void SetUp()
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
@@ -46,13 +46,13 @@ class lzipFixture : public ::testing::Test
|
||||
getcwd(path, PATH_MAX);
|
||||
snprintf(filename, PATH_MAX, "%s/data/lzip.lz", path);
|
||||
|
||||
FILE* file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t*)malloc(1062874);
|
||||
fread((void*)buffer, 1, 1062874, file);
|
||||
FILE *file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t *)malloc(1062874);
|
||||
fread((void *)buffer, 1, 1062874, file);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
void TearDown() { free((void*)buffer); }
|
||||
void TearDown() { free((void *)buffer); }
|
||||
|
||||
~lzipFixture()
|
||||
{
|
||||
@@ -64,7 +64,7 @@ class lzipFixture : public ::testing::Test
|
||||
|
||||
TEST_F(lzipFixture, lzip)
|
||||
{
|
||||
auto* outBuf = (uint8_t*)malloc(1048576);
|
||||
auto *outBuf = (uint8_t *)malloc(1048576);
|
||||
|
||||
auto decoded = AARU_lzip_decode_buffer(outBuf, 1048576, buffer, 1062874);
|
||||
|
||||
@@ -84,24 +84,24 @@ TEST_F(lzipFixture, lzipCompress)
|
||||
int32_t decmp_len = original_len;
|
||||
char path[PATH_MAX];
|
||||
char filename[PATH_MAX * 2];
|
||||
FILE* file;
|
||||
FILE *file;
|
||||
uint32_t original_crc, decmp_crc;
|
||||
const uint8_t* original;
|
||||
uint8_t* cmp_buffer;
|
||||
uint8_t* decmp_buffer;
|
||||
const uint8_t *original;
|
||||
uint8_t *cmp_buffer;
|
||||
uint8_t *decmp_buffer;
|
||||
int32_t newSize;
|
||||
|
||||
// Allocate buffers
|
||||
original = (const uint8_t*)malloc(original_len);
|
||||
cmp_buffer = (uint8_t*)malloc(cmp_len);
|
||||
decmp_buffer = (uint8_t*)malloc(decmp_len);
|
||||
original = (const uint8_t *)malloc(original_len);
|
||||
cmp_buffer = (uint8_t *)malloc(cmp_len);
|
||||
decmp_buffer = (uint8_t *)malloc(decmp_len);
|
||||
|
||||
// Read the file
|
||||
getcwd(path, PATH_MAX);
|
||||
snprintf(filename, PATH_MAX, "%s/data/data.bin", path);
|
||||
|
||||
file = fopen(filename, "rb");
|
||||
fread((void*)original, 1, original_len, file);
|
||||
fread((void *)original, 1, original_len, file);
|
||||
fclose(file);
|
||||
|
||||
// Calculate the CRC
|
||||
@@ -120,7 +120,7 @@ TEST_F(lzipFixture, lzipCompress)
|
||||
decmp_crc = crc32_data(decmp_buffer, decmp_len);
|
||||
|
||||
// Free buffers
|
||||
free((void*)original);
|
||||
free((void *)original);
|
||||
free(cmp_buffer);
|
||||
free(decmp_buffer);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Aaru Data Preservation Suite.
|
||||
* Copyright (c) 2019-2023 Natalia Portillo.
|
||||
* Copyright (c) 2019-2025 Natalia Portillo.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
@@ -26,18 +26,18 @@
|
||||
|
||||
#define EXPECTED_CRC32 0x954bf76e
|
||||
|
||||
static const uint8_t* buffer;
|
||||
static const uint8_t *buffer;
|
||||
|
||||
class lzmaFixture : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
public:
|
||||
lzmaFixture()
|
||||
{
|
||||
// initialization;
|
||||
// can also be done in SetUp()
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void SetUp()
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
@@ -46,13 +46,13 @@ class lzmaFixture : public ::testing::Test
|
||||
getcwd(path, PATH_MAX);
|
||||
snprintf(filename, PATH_MAX, "%s/data/lzma.bin", path);
|
||||
|
||||
FILE* file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t*)malloc(1200275);
|
||||
fread((void*)buffer, 1, 1200275, file);
|
||||
FILE *file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t *)malloc(1200275);
|
||||
fread((void *)buffer, 1, 1200275, file);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
void TearDown() { free((void*)buffer); }
|
||||
void TearDown() { free((void *)buffer); }
|
||||
|
||||
~lzmaFixture()
|
||||
{
|
||||
@@ -67,7 +67,7 @@ TEST_F(lzmaFixture, lzma)
|
||||
uint8_t params[] = {0x5D, 0x00, 0x00, 0x00, 0x02};
|
||||
size_t destLen = 8388608;
|
||||
size_t srcLen = 1200275;
|
||||
auto* outBuf = (uint8_t*)malloc(8388608);
|
||||
auto *outBuf = (uint8_t *)malloc(8388608);
|
||||
|
||||
auto err = AARU_lzma_decode_buffer(outBuf, &destLen, buffer, &srcLen, params, 5);
|
||||
|
||||
@@ -88,34 +88,34 @@ TEST_F(lzmaFixture, lzmaCompress)
|
||||
size_t decmp_len = original_len;
|
||||
char path[PATH_MAX];
|
||||
char filename[PATH_MAX * 2];
|
||||
FILE* file;
|
||||
FILE *file;
|
||||
uint32_t original_crc, decmp_crc;
|
||||
const uint8_t* original;
|
||||
uint8_t* cmp_buffer;
|
||||
uint8_t* decmp_buffer;
|
||||
const uint8_t *original;
|
||||
uint8_t *cmp_buffer;
|
||||
uint8_t *decmp_buffer;
|
||||
int err;
|
||||
uint8_t props[5];
|
||||
size_t props_len = 5;
|
||||
|
||||
// Allocate buffers
|
||||
original = (const uint8_t*)malloc(original_len);
|
||||
cmp_buffer = (uint8_t*)malloc(cmp_len);
|
||||
decmp_buffer = (uint8_t*)malloc(decmp_len);
|
||||
original = (const uint8_t *)malloc(original_len);
|
||||
cmp_buffer = (uint8_t *)malloc(cmp_len);
|
||||
decmp_buffer = (uint8_t *)malloc(decmp_len);
|
||||
|
||||
// Read the file
|
||||
getcwd(path, PATH_MAX);
|
||||
snprintf(filename, PATH_MAX, "%s/data/data.bin", path);
|
||||
|
||||
file = fopen(filename, "rb");
|
||||
fread((void*)original, 1, original_len, file);
|
||||
fread((void *)original, 1, original_len, file);
|
||||
fclose(file);
|
||||
|
||||
// Calculate the CRC
|
||||
original_crc = crc32_data(original, original_len);
|
||||
|
||||
// Compress
|
||||
err = AARU_lzma_encode_buffer(
|
||||
cmp_buffer, &cmp_len, original, original_len, props, &props_len, 9, 1048576, 3, 0, 2, 273, 2);
|
||||
err = AARU_lzma_encode_buffer(cmp_buffer, &cmp_len, original, original_len, props, &props_len, 9, 1048576, 3, 0, 2,
|
||||
273, 2);
|
||||
EXPECT_EQ(err, 0);
|
||||
|
||||
// Decompress
|
||||
@@ -127,7 +127,7 @@ TEST_F(lzmaFixture, lzmaCompress)
|
||||
decmp_crc = crc32_data(decmp_buffer, decmp_len);
|
||||
|
||||
// Free buffers
|
||||
free((void*)original);
|
||||
free((void *)original);
|
||||
free(cmp_buffer);
|
||||
free(decmp_buffer);
|
||||
|
||||
|
||||
182
tests/zoo/lzd.cpp
Normal file
182
tests/zoo/lzd.cpp
Normal file
@@ -0,0 +1,182 @@
|
||||
/*
|
||||
* This file is part of the Aaru Data Preservation Suite.
|
||||
* Copyright (c) 2019-2025 Natalia Portillo.
|
||||
*
|
||||
* This library 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 2.1 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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 library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <climits>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "../library.h"
|
||||
#include "../crc32.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#define OUTPUT_CHUNK 8192
|
||||
#define EXPECTED_SIZE 152089
|
||||
#define EXPECTED_CRC32_VAL 0x66007dba
|
||||
|
||||
static long long filesize_of(const char* path)
|
||||
{
|
||||
struct stat st;
|
||||
if(stat(path, &st) == 0) return (long long)st.st_size;
|
||||
return -1;
|
||||
}
|
||||
|
||||
class lzdFixture : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
void SetUp() override
|
||||
{
|
||||
char cwd[PATH_MAX];
|
||||
char filename[PATH_MAX];
|
||||
|
||||
getcwd(cwd, PATH_MAX);
|
||||
snprintf(filename, PATH_MAX, "%s/data/alice29.lzd", cwd);
|
||||
|
||||
inFile = fopen(filename, "rb");
|
||||
ASSERT_NE(inFile, nullptr) << "Failed to open input file";
|
||||
|
||||
fileSize = filesize_of(filename);
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
if(inFile) fclose(inFile);
|
||||
}
|
||||
|
||||
FILE* inFile = nullptr;
|
||||
long long fileSize = 0;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
LZD_OK = 0,
|
||||
LZD_NEED_INPUT = 1,
|
||||
LZD_NEED_OUTPUT = 2,
|
||||
LZD_DONE = 3
|
||||
} LZDStatus;
|
||||
|
||||
TEST_F(lzdFixture, ZooMethod1)
|
||||
{
|
||||
unsigned char inbuf[OUTPUT_CHUNK];
|
||||
unsigned char outbuf[OUTPUT_CHUNK];
|
||||
|
||||
bool flushed = false;
|
||||
bool eof = false;
|
||||
size_t total_out = 0;
|
||||
size_t total_in = 0;
|
||||
size_t iter = 0;
|
||||
|
||||
fprintf(stderr, "INPUT FILE SIZE=%lld bytes\n", fileSize);
|
||||
|
||||
void* ctx = CreateLZDContext();
|
||||
ASSERT_NE(ctx, nullptr) << "Failed to create LZD context";
|
||||
|
||||
// allocate buffer for full output to CRC at the end
|
||||
uint8_t* full_out = (uint8_t*)malloc(EXPECTED_SIZE);
|
||||
ASSERT_NE(full_out, nullptr);
|
||||
size_t full_offset = 0;
|
||||
|
||||
while(!eof)
|
||||
{
|
||||
size_t nread = fread(inbuf, 1, sizeof inbuf, inFile);
|
||||
if(nread == 0)
|
||||
{
|
||||
fprintf(stderr, "[FEED] size=0 flushed=0 (final empty feed)\n");
|
||||
LZD_FeedNative(ctx, nullptr, 0);
|
||||
flushed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
total_in += nread;
|
||||
fprintf(stderr, "[FEED] size=%zu flushed=0 (real data) total_in=%zu\n",
|
||||
nread, total_in);
|
||||
LZD_FeedNative(ctx, inbuf, nread);
|
||||
}
|
||||
|
||||
size_t produced = 0;
|
||||
int st = LZD_OK;
|
||||
do
|
||||
{
|
||||
produced = 0;
|
||||
st = LZD_DrainNative(ctx, outbuf, sizeof outbuf, &produced);
|
||||
fprintf(stderr, "-- LOOP iter=%zu total_out=%zu --\n", iter++, total_out);
|
||||
fprintf(stderr, "[DRAIN] produced=%zu status=%d flushed=%d eof=%d\n",
|
||||
produced, st, flushed ? 1 : 0, eof ? 1 : 0);
|
||||
|
||||
if(produced > 0)
|
||||
{
|
||||
memcpy(full_out + full_offset, outbuf, produced);
|
||||
full_offset += produced;
|
||||
total_out += produced;
|
||||
}
|
||||
if(st == LZD_DONE)
|
||||
{
|
||||
fprintf(stderr, ">>> SET eof=1 (DONE from decoder)\n");
|
||||
eof = true;
|
||||
}
|
||||
} while(produced > 0);
|
||||
|
||||
if(flushed)
|
||||
{
|
||||
for(int spins = 0; spins < 8 && !eof; spins++)
|
||||
{
|
||||
size_t more = 0;
|
||||
int st2 = LZD_DrainNative(ctx, outbuf, sizeof outbuf, &more);
|
||||
fprintf(stderr, "-- LOOP iter=%zu total_out=%zu --\n", iter++, total_out);
|
||||
fprintf(stderr, "[DRAIN] produced=%zu status=%d flushed=1 eof=%d\n",
|
||||
more, st2, eof ? 1 : 0);
|
||||
if(more > 0)
|
||||
{
|
||||
memcpy(full_out + full_offset, outbuf, more);
|
||||
full_offset += more;
|
||||
total_out += more;
|
||||
}
|
||||
else if(st2 == LZD_DONE)
|
||||
{
|
||||
fprintf(stderr, ">>> SET eof=1 (DONE after flush)\n");
|
||||
eof = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!eof)
|
||||
{
|
||||
fprintf(stderr, ">>> SET eof=1 (no more data and already flushed)\n");
|
||||
eof = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "\nTOTAL IN=%zu bytes\n", total_in);
|
||||
fprintf(stderr, "TOTAL OUT=%zu bytes\n", total_out);
|
||||
|
||||
DestroyLZDContext(ctx);
|
||||
|
||||
// Now verify the decompressed size and CRC
|
||||
EXPECT_EQ(total_out, static_cast<size_t>(EXPECTED_SIZE));
|
||||
uint32_t crc = crc32_data(full_out, total_out);
|
||||
free(full_out);
|
||||
|
||||
EXPECT_EQ(crc, static_cast<uint32_t>(EXPECTED_CRC32_VAL));
|
||||
EXPECT_EQ(total_in, static_cast<size_t>(fileSize));
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* This file is part of the Aaru Data Preservation Suite.
|
||||
* Copyright (c) 2019-2023 Natalia Portillo.
|
||||
* Copyright (c) 2019-2025 Natalia Portillo.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as
|
||||
@@ -26,18 +26,18 @@
|
||||
|
||||
#define EXPECTED_CRC32 0xc64059c0
|
||||
|
||||
static const uint8_t* buffer;
|
||||
static const uint8_t *buffer;
|
||||
|
||||
class zstdFixture : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
public:
|
||||
zstdFixture()
|
||||
{
|
||||
// initialization;
|
||||
// can also be done in SetUp()
|
||||
}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
void SetUp()
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
@@ -46,13 +46,13 @@ class zstdFixture : public ::testing::Test
|
||||
getcwd(path, PATH_MAX);
|
||||
snprintf(filename, PATH_MAX, "%s/data/zstd.zst", path);
|
||||
|
||||
FILE* file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t*)malloc(1048613);
|
||||
fread((void*)buffer, 1, 1048613, file);
|
||||
FILE *file = fopen(filename, "rb");
|
||||
buffer = (const uint8_t *)malloc(1048613);
|
||||
fread((void *)buffer, 1, 1048613, file);
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
void TearDown() { free((void*)buffer); }
|
||||
void TearDown() { free((void *)buffer); }
|
||||
|
||||
~zstdFixture()
|
||||
{
|
||||
@@ -64,7 +64,7 @@ class zstdFixture : public ::testing::Test
|
||||
|
||||
TEST_F(zstdFixture, zstd)
|
||||
{
|
||||
auto* outBuf = (uint8_t*)malloc(1048576);
|
||||
auto *outBuf = (uint8_t *)malloc(1048576);
|
||||
|
||||
auto decoded = AARU_zstd_decode_buffer(outBuf, 1048576, buffer, 1048613);
|
||||
|
||||
@@ -84,24 +84,24 @@ TEST_F(zstdFixture, zstdCompress)
|
||||
uint decmp_len = original_len;
|
||||
char path[PATH_MAX];
|
||||
char filename[PATH_MAX * 2];
|
||||
FILE* file;
|
||||
FILE *file;
|
||||
uint32_t original_crc, decmp_crc;
|
||||
const uint8_t* original;
|
||||
uint8_t* cmp_buffer;
|
||||
uint8_t* decmp_buffer;
|
||||
const uint8_t *original;
|
||||
uint8_t *cmp_buffer;
|
||||
uint8_t *decmp_buffer;
|
||||
size_t newSize;
|
||||
|
||||
// Allocate buffers
|
||||
original = (const uint8_t*)malloc(original_len);
|
||||
cmp_buffer = (uint8_t*)malloc(cmp_len);
|
||||
decmp_buffer = (uint8_t*)malloc(decmp_len);
|
||||
original = (const uint8_t *)malloc(original_len);
|
||||
cmp_buffer = (uint8_t *)malloc(cmp_len);
|
||||
decmp_buffer = (uint8_t *)malloc(decmp_len);
|
||||
|
||||
// Read the file
|
||||
getcwd(path, PATH_MAX);
|
||||
snprintf(filename, PATH_MAX, "%s/data/data.bin", path);
|
||||
|
||||
file = fopen(filename, "rb");
|
||||
fread((void*)original, 1, original_len, file);
|
||||
fread((void *)original, 1, original_len, file);
|
||||
fclose(file);
|
||||
|
||||
// Calculate the CRC
|
||||
@@ -120,7 +120,7 @@ TEST_F(zstdFixture, zstdCompress)
|
||||
decmp_crc = crc32_data(decmp_buffer, decmp_len);
|
||||
|
||||
// Free buffers
|
||||
free((void*)original);
|
||||
free((void *)original);
|
||||
free(cmp_buffer);
|
||||
free(decmp_buffer);
|
||||
|
||||
|
||||
205
zoo/lzd.c
Normal file
205
zoo/lzd.c
Normal file
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
* This file is part of the Aaru Data Preservation Suite.
|
||||
* Copyright (c) 2019-2025 Natalia Portillo.
|
||||
*
|
||||
* This library 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 2.1 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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 library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Lempel-Ziv-Davis compression implementation based on the public domain code from
|
||||
// Rahul Dhesi from zoo
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include "lzd.h"
|
||||
#include "../library.h"
|
||||
|
||||
static void init_dict(LZDContext *ctx)
|
||||
{
|
||||
ctx->nbits = 9;
|
||||
ctx->max_code = 1u << 9;
|
||||
ctx->free_code = FIRST_FREE;
|
||||
ctx->have_old = 0;
|
||||
}
|
||||
|
||||
static int firstch(LZDContext *ctx, int code)
|
||||
{
|
||||
int steps = 0;
|
||||
while(code > 255)
|
||||
{
|
||||
if((unsigned)code > MAXMAX) return -1;
|
||||
if(++steps > (int)MAXMAX) return -1;
|
||||
code = ctx->head[code];
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int fill_bits(LZDContext *ctx)
|
||||
{
|
||||
while(ctx->bitcount < (int)ctx->nbits)
|
||||
{
|
||||
if(ctx->in_pos >= ctx->in_len) return -1;
|
||||
ctx->bitbuf |= (uint64_t)ctx->in_ptr[ctx->in_pos++] << ctx->bitcount;
|
||||
ctx->bitcount += 8;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int read_code(LZDContext *ctx)
|
||||
{
|
||||
if(fill_bits(ctx) < 0) return -1;
|
||||
int code = (int)(ctx->bitbuf & masks[ctx->nbits]);
|
||||
ctx->bitbuf >>= ctx->nbits;
|
||||
ctx->bitcount -= ctx->nbits;
|
||||
return code;
|
||||
}
|
||||
|
||||
LZDStatus LZD_Init(LZDContext *ctx)
|
||||
{
|
||||
memset(ctx, 0, sizeof *ctx);
|
||||
ctx->head = malloc((MAXMAX + 1) * sizeof *ctx->head);
|
||||
ctx->tail = malloc((MAXMAX + 1) * sizeof *ctx->tail);
|
||||
ctx->stack = malloc((MAXMAX + 1) * sizeof *ctx->stack);
|
||||
if(!ctx->head || !ctx->tail || !ctx->stack) return LZD_NEED_INPUT;
|
||||
|
||||
for(int i = 0; i < 256; i++)
|
||||
{
|
||||
ctx->head[i] = -1;
|
||||
ctx->tail[i] = (uint8_t)i;
|
||||
}
|
||||
ctx->stack_lim = ctx->stack + (MAXMAX + 1);
|
||||
ctx->stack_ptr = ctx->stack_lim;
|
||||
init_dict(ctx);
|
||||
ctx->bitbuf = 0;
|
||||
ctx->bitcount = 0;
|
||||
return LZD_OK;
|
||||
}
|
||||
|
||||
LZDStatus LZD_Feed(LZDContext *ctx, const unsigned char *in, size_t in_len)
|
||||
{
|
||||
ctx->in_ptr = in;
|
||||
ctx->in_len = in_len;
|
||||
ctx->in_pos = 0;
|
||||
return LZD_OK;
|
||||
}
|
||||
|
||||
LZDStatus LZD_Drain(LZDContext *ctx, unsigned char *out, size_t out_len, size_t *out_produced)
|
||||
{
|
||||
size_t outpos = 0;
|
||||
|
||||
while(outpos < out_len)
|
||||
{
|
||||
if(ctx->stack_ptr < ctx->stack_lim)
|
||||
{
|
||||
out[outpos++] = (uint8_t)*ctx->stack_ptr++;
|
||||
continue;
|
||||
}
|
||||
|
||||
int raw = read_code(ctx);
|
||||
if(raw < 0)
|
||||
{
|
||||
*out_produced = outpos;
|
||||
return outpos > 0 ? LZD_OK : LZD_NEED_INPUT;
|
||||
}
|
||||
unsigned code = (unsigned)raw;
|
||||
|
||||
if(code == CLEAR)
|
||||
{
|
||||
init_dict(ctx);
|
||||
int lit = read_code(ctx);
|
||||
if(lit < 0)
|
||||
{
|
||||
*out_produced = outpos;
|
||||
return outpos > 0 ? LZD_OK : LZD_NEED_INPUT;
|
||||
}
|
||||
ctx->old_code = (unsigned)lit;
|
||||
ctx->have_old = 1;
|
||||
out[outpos++] = (uint8_t)lit;
|
||||
continue;
|
||||
}
|
||||
if(code == Z_EOF)
|
||||
{
|
||||
*out_produced = outpos;
|
||||
return LZD_DONE;
|
||||
}
|
||||
|
||||
unsigned in_code = code;
|
||||
if(code >= ctx->free_code)
|
||||
{
|
||||
if(!ctx->have_old) return LZD_DONE;
|
||||
int fc = firstch(ctx, ctx->old_code);
|
||||
if(fc < 0) return LZD_DONE;
|
||||
*--ctx->stack_ptr = (char)fc;
|
||||
code = ctx->old_code;
|
||||
}
|
||||
|
||||
while(code > 255)
|
||||
{
|
||||
*--ctx->stack_ptr = (char)ctx->tail[code];
|
||||
code = ctx->head[code];
|
||||
}
|
||||
uint8_t first_byte = (uint8_t)code;
|
||||
*--ctx->stack_ptr = (char)first_byte;
|
||||
|
||||
if(ctx->have_old && ctx->free_code <= MAXMAX)
|
||||
{
|
||||
ctx->tail[ctx->free_code] = first_byte;
|
||||
ctx->head[ctx->free_code] = (int)ctx->old_code;
|
||||
ctx->free_code++;
|
||||
if(ctx->free_code >= ctx->max_code && ctx->nbits < MAXBITS)
|
||||
{
|
||||
ctx->nbits++;
|
||||
ctx->max_code <<= 1;
|
||||
}
|
||||
}
|
||||
ctx->old_code = in_code;
|
||||
ctx->have_old = 1;
|
||||
}
|
||||
|
||||
*out_produced = outpos;
|
||||
return LZD_OK;
|
||||
}
|
||||
|
||||
void LZD_Destroy(LZDContext *ctx)
|
||||
{
|
||||
if(!ctx) return;
|
||||
free(ctx->head);
|
||||
free(ctx->tail);
|
||||
free(ctx->stack);
|
||||
}
|
||||
|
||||
AARU_EXPORT void AARU_CALL *CreateLZDContext(void)
|
||||
{
|
||||
LZDContext *c = malloc(sizeof *c);
|
||||
return c && LZD_Init(c) == LZD_OK ? c : (free(c), NULL);
|
||||
}
|
||||
|
||||
AARU_EXPORT void AARU_CALL DestroyLZDContext(void *ctx)
|
||||
{
|
||||
if(ctx)
|
||||
{
|
||||
LZD_Destroy(ctx);
|
||||
free(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
AARU_EXPORT int AARU_CALL LZD_FeedNative(void *ctx, const unsigned char *data, size_t length)
|
||||
{
|
||||
return (int)LZD_Feed(ctx, data, length);
|
||||
}
|
||||
|
||||
AARU_EXPORT int AARU_CALL LZD_DrainNative(void *ctx, unsigned char *outBuf, size_t outBufLen, size_t *produced)
|
||||
{
|
||||
return (int)LZD_Drain(ctx, outBuf, outBufLen, produced);
|
||||
}
|
||||
86
zoo/lzd.h
Normal file
86
zoo/lzd.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* This file is part of the Aaru Data Preservation Suite.
|
||||
* Copyright (c) 2019-2025 Natalia Portillo.
|
||||
*
|
||||
* This library 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 2.1 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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 library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef LZD_H
|
||||
#define LZD_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define MAXBITS 13
|
||||
#define MAXMAX ((1U << MAXBITS) - 1) // 8191
|
||||
#define FIRST_FREE 258 // first free code after CLEAR+EOF
|
||||
#define CLEAR 256
|
||||
#define Z_EOF 257
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LZD_OK = 0,
|
||||
LZD_NEED_INPUT = 1,
|
||||
LZD_NEED_OUTPUT = 2,
|
||||
LZD_DONE = 3
|
||||
} LZDStatus;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int * head;
|
||||
uint8_t *tail;
|
||||
unsigned nbits;
|
||||
unsigned max_code;
|
||||
unsigned free_code;
|
||||
unsigned old_code;
|
||||
int have_old;
|
||||
|
||||
char *stack;
|
||||
char *stack_lim;
|
||||
char *stack_ptr;
|
||||
|
||||
uint64_t bitbuf;
|
||||
int bitcount;
|
||||
|
||||
const unsigned char *in_ptr;
|
||||
size_t in_len;
|
||||
size_t in_pos;
|
||||
} LZDContext;
|
||||
|
||||
static const unsigned masks[MAXBITS + 1] = {
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
(1u << 9) - 1,
|
||||
(1u << 10) - 1,
|
||||
(1u << 11) - 1,
|
||||
(1u << 12) - 1,
|
||||
(1u << 13) - 1
|
||||
};
|
||||
|
||||
LZDStatus LZD_Init(LZDContext *ctx);
|
||||
|
||||
LZDStatus LZD_Feed(LZDContext *ctx, const unsigned char *in, size_t in_len);
|
||||
|
||||
LZDStatus LZD_Drain(LZDContext *ctx, unsigned char *out, size_t out_len, size_t *out_produced);
|
||||
|
||||
void LZD_Destroy(LZDContext *ctx);
|
||||
|
||||
#endif // LZD_H
|
||||
Reference in New Issue
Block a user