You've already forked ultrasm64-2
mirror of
https://github.com/HackerN64/ultrasm64-2.git
synced 2026-01-21 10:38:08 -08:00
Add aglab2 lz4t
This commit is contained in:
2
Makefile
2
Makefile
@@ -315,7 +315,7 @@ export LANG := C
|
|||||||
#==============================================================================#
|
#==============================================================================#
|
||||||
|
|
||||||
# N64 tools
|
# N64 tools
|
||||||
MIO0TOOL := $(TOOLS_DIR)/sm64tools/mio0
|
MIO0TOOL := $(TOOLS_DIR)/lz4tpack
|
||||||
N64CKSUM := $(TOOLS_DIR)/sm64tools/n64cksum
|
N64CKSUM := $(TOOLS_DIR)/sm64tools/n64cksum
|
||||||
N64GRAPHICS := $(TOOLS_DIR)/sm64tools/n64graphics
|
N64GRAPHICS := $(TOOLS_DIR)/sm64tools/n64graphics
|
||||||
N64GRAPHICS_CI := $(TOOLS_DIR)/sm64tools/n64graphics_ci
|
N64GRAPHICS_CI := $(TOOLS_DIR)/sm64tools/n64graphics_ci
|
||||||
|
|||||||
306
asm/decompress.s
306
asm/decompress.s
@@ -1,104 +1,216 @@
|
|||||||
// assembler directives
|
##############################################
|
||||||
.set noat // allow manual use of $at
|
# LZ4T - Fast decompressor in assembly
|
||||||
.set noreorder // don't insert nops after branches
|
# Written by aglab2 inspired by Rasky LZ4 and devwizard YAZ0
|
||||||
|
##############################################
|
||||||
|
|
||||||
#include "macros.inc"
|
# NOTE: to optimize for speed, this decompressor can write up to 8 bytes
|
||||||
|
# after the end of the output buffer. The outut buffer must have been sized
|
||||||
|
# accordingly to accomodate for this.
|
||||||
|
|
||||||
|
#define MINMATCH 4
|
||||||
|
|
||||||
.section .text, "ax"
|
#define inbuf $s0
|
||||||
|
#define nibbles $s1
|
||||||
|
#define outbuf $s2
|
||||||
|
#define match_combo_mask $s3
|
||||||
|
#define len $s4
|
||||||
|
#define match_lim $s5
|
||||||
|
#define match_min $s6
|
||||||
|
#define v0_st $s7
|
||||||
|
|
||||||
// This file is handwritten.
|
#define dma_ctx $s8
|
||||||
|
#define dma_ptr $v0
|
||||||
|
|
||||||
glabel decompress
|
#define shift $t9
|
||||||
#if !defined(VERSION_JP) && !defined(VERSION_US)
|
#define len_add $t8
|
||||||
lw $a3, 8($a0)
|
#define match_len $t7
|
||||||
lw $t9, 0xc($a0)
|
#define match_off $t6
|
||||||
lw $t8, 4($a0)
|
#define match_combo $t5
|
||||||
add $a3, $a3, $a0
|
#define off_nibble $t4
|
||||||
add $t9, $t9, $a0
|
|
||||||
or $a2, $zero, $zero
|
.section .text.lz4t_unpack_fast
|
||||||
addi $a0, $a0, 0x10
|
.p2align 5
|
||||||
add $t8, $t8, $a1
|
.globl lz4t_unpack_fast
|
||||||
.L8026ED80:
|
.func lz4t_unpack_fast
|
||||||
bnezl $a2, .L8026ED98
|
.set at
|
||||||
slt $t1, $t0, $zero
|
.set noreorder
|
||||||
lw $t0, ($a0)
|
|
||||||
li $a2, 32
|
lz4t_unpack_fast:
|
||||||
addi $a0, $a0, 4
|
addiu $sp, $sp, -0x40
|
||||||
slt $t1, $t0, $zero
|
sw $ra, 0x14($sp)
|
||||||
.L8026ED98:
|
sw $s0, 0x18($sp)
|
||||||
beql $t1, $zero, .L8026EDB8
|
sw $s1, 0x1c($sp)
|
||||||
lhu $t2, ($a3)
|
sw $s2, 0x20($sp)
|
||||||
lb $t2, ($t9)
|
sw $s3, 0x24($sp)
|
||||||
addi $t9, $t9, 1
|
sw $s4, 0x28($sp)
|
||||||
addi $a1, $a1, 1
|
sw $s5, 0x2C($sp)
|
||||||
b .L8026EDE4
|
sw $s6, 0x30($sp)
|
||||||
sb $t2, -1($a1)
|
sw $s7, 0x34($sp)
|
||||||
lhu $t2, ($a3)
|
sw $s8, 0x38($sp)
|
||||||
.L8026EDB8:
|
|
||||||
addi $a3, $a3, 2
|
move $s0, $a0
|
||||||
srl $t3, $t2, 0xc
|
lw $s1, 12($a0)
|
||||||
andi $t2, $t2, 0xfff
|
move $s2, $a1
|
||||||
sub $t1, $a1, $t2
|
move dma_ctx, $a2
|
||||||
addi $t3, $t3, 3
|
lbu match_combo_mask, 8($a0)
|
||||||
.L8026EDCC:
|
sll match_combo_mask, 28
|
||||||
lb $t2, -1($t1)
|
lbu match_min, 9($a0)
|
||||||
addi $t3, $t3, -1
|
|
||||||
addi $t1, $t1, 1
|
move dma_ptr, $a0
|
||||||
addi $a1, $a1, 1
|
addiu $s0, 16
|
||||||
bnez $t3, .L8026EDCC
|
|
||||||
sb $t2, -1($a1)
|
.Lloop:
|
||||||
.L8026EDE4:
|
sub $t0, inbuf, dma_ptr # check if we need to wait for dma
|
||||||
sll $t0, $t0, 1
|
bgezal $t0, dma_async_ctx_read # if inbuf >= dma_ptr, wait for dma
|
||||||
bne $a1, $t8, .L8026ED80
|
move $a0, dma_ctx
|
||||||
addi $a2, $a2, -1
|
|
||||||
jr $ra
|
bnez nibbles, .Lprocess_nibbles
|
||||||
|
li match_lim, 7
|
||||||
|
|
||||||
|
.Lload_nibbles:
|
||||||
|
lwl nibbles, 0(inbuf)
|
||||||
|
lwr nibbles, 3(inbuf)
|
||||||
|
beqz nibbles, .Lend
|
||||||
|
add inbuf, 4
|
||||||
|
|
||||||
|
.Lprocess_nibbles:
|
||||||
|
bgez nibbles, .Lmatches
|
||||||
|
srl len, nibbles, 28
|
||||||
|
|
||||||
|
.Lliterals:
|
||||||
|
andi len, 7
|
||||||
|
beqz len, .Llarge_literals
|
||||||
nop
|
nop
|
||||||
#else
|
|
||||||
lw $t8, 4($a0)
|
.Lsmall_literal:
|
||||||
lw $a3, 8($a0)
|
ldl $t0, 0(inbuf)
|
||||||
lw $t9, 0xc($a0)
|
ldr $t0, 7(inbuf)
|
||||||
move $a2, $zero
|
add inbuf, len
|
||||||
add $t8, $t8, $a1
|
sdl $t0, 0(outbuf)
|
||||||
add $a3, $a3, $a0
|
sdr $t0, 7(outbuf)
|
||||||
add $t9, $t9, $a0
|
sll nibbles, 4
|
||||||
addi $a0, $a0, 0x10
|
beq len, match_lim, .Lloop
|
||||||
.L8027EF50:
|
add outbuf, len
|
||||||
bnez $a2, .L8027EF64
|
|
||||||
|
.Lmatches_ex:
|
||||||
|
sub $t0, inbuf, dma_ptr # check if we need to wait for dma
|
||||||
|
bgezal $t0, dma_async_ctx_read # if inbuf >= dma_ptr, wait for dma
|
||||||
|
move $a0, dma_ctx
|
||||||
|
|
||||||
|
bnez nibbles, .Lprocess_ex_match_nibble
|
||||||
|
li match_lim, 15
|
||||||
|
|
||||||
|
.Lload_nibbles2:
|
||||||
|
lwl nibbles, 0(inbuf)
|
||||||
|
lwr nibbles, 3(inbuf)
|
||||||
|
beqz nibbles, .Lend
|
||||||
|
add inbuf, 4
|
||||||
|
|
||||||
|
.Lprocess_ex_match_nibble:
|
||||||
|
srl len, nibbles, 28
|
||||||
|
|
||||||
|
.Lmatches:
|
||||||
|
lwl match_combo, 0(inbuf)
|
||||||
|
lwr match_combo, 3(inbuf)
|
||||||
|
addiu inbuf, 2
|
||||||
|
srl match_off, match_combo, 16
|
||||||
|
|
||||||
|
beqz match_combo_mask, .Lfull_offset
|
||||||
|
sll nibbles, 4
|
||||||
|
srl nibbles, 4
|
||||||
|
and off_nibble, match_combo, match_combo_mask
|
||||||
|
or nibbles, off_nibble
|
||||||
|
andi match_off, 0xfff
|
||||||
|
.Lfull_offset:
|
||||||
|
|
||||||
|
bne len, match_lim, .Lmatch
|
||||||
|
addu match_len, len, match_min
|
||||||
|
|
||||||
|
# len is sign extended match_combo[8:15]
|
||||||
|
sll match_combo, 16
|
||||||
|
sra len, match_combo, 24
|
||||||
|
add inbuf, 1
|
||||||
|
bltzal len, .Lread_large_amount
|
||||||
|
andi len, 0x7f
|
||||||
|
|
||||||
|
add match_len, len
|
||||||
|
|
||||||
|
.Lmatch:
|
||||||
|
ble match_off, match_len, .Lmatch1_loop # check if we can do 8-byte copy
|
||||||
|
sub v0_st, outbuf, match_off # calculate start of match
|
||||||
|
.Lmatch8_loop: # 8-byte copy loop
|
||||||
|
ldl $t0, -1(v0_st) # load 8 bytes
|
||||||
|
ldr $t0, 6(v0_st)
|
||||||
|
addiu v0_st, 8
|
||||||
|
sdl $t0, 0(outbuf) # store 8 bytes
|
||||||
|
sdr $t0, 7(outbuf)
|
||||||
|
addiu match_len, -8
|
||||||
|
bgtz match_len, .Lmatch8_loop # check we went past match_len
|
||||||
|
addiu outbuf, 8
|
||||||
|
b .Lloop # jump to main loop
|
||||||
|
addu outbuf, match_len # adjust pointer remove extra bytes
|
||||||
|
|
||||||
|
.Lmatch1_loop: # 1-byte copy loop
|
||||||
|
lbu $t0, -1(v0_st) # load 1 byte
|
||||||
|
addiu v0_st, 1
|
||||||
|
sb $t0, 0(outbuf) # store 1 byte
|
||||||
|
addiu match_len, -1
|
||||||
|
bgtz match_len, .Lmatch1_loop # check we went past match_len
|
||||||
|
addiu outbuf, 1
|
||||||
|
b .Lloop # jump to main loop
|
||||||
nop
|
nop
|
||||||
lw $t0, ($a0)
|
|
||||||
li $a2, 32
|
.Llarge_literals:
|
||||||
addi $a0, $a0, 4
|
lb len, 0(inbuf)
|
||||||
.L8027EF64:
|
add inbuf, 1
|
||||||
slt $t1, $t0, $zero
|
bltzal len, .Lread_large_amount
|
||||||
beqz $t1, .L8027EF88
|
andi len, 0x7f
|
||||||
nop
|
|
||||||
lb $t2, ($t9)
|
move v0_st, inbuf # store start of literals into v0_st
|
||||||
addi $t9, $t9, 1
|
addiu len, 22
|
||||||
sb $t2, ($a1)
|
add inbuf, len # advance inbuf to end of literals
|
||||||
addi $a1, $a1, 1
|
.Lcopy_lit:
|
||||||
b .L8027EFBC
|
sub $t0, v0_st, dma_ptr # check if all the literals have been DMA'd
|
||||||
nop
|
bgezal $t0, dma_async_ctx_read # if not, wait for DMA
|
||||||
.L8027EF88:
|
move $a0, dma_ctx
|
||||||
lhu $t2, ($a3)
|
ldl $t0, 0(v0_st) # load 8 bytes of literals
|
||||||
addi $a3, $a3, 2
|
ldr $t0, 7(v0_st)
|
||||||
srl $t3, $t2, 0xc
|
addiu v0_st, 8
|
||||||
andi $t2, $t2, 0xfff
|
sdl $t0, 0(outbuf) # store 8 bytes of literals
|
||||||
sub $t1, $a1, $t2
|
sdr $t0, 7(outbuf)
|
||||||
addi $t3, $t3, 3
|
addiu len, -8
|
||||||
.L8027EFA0:
|
bgez len, .Lcopy_lit # check if we went past the end of literals
|
||||||
lb $t2, -1($t1)
|
addiu outbuf, 8
|
||||||
addi $t3, $t3, -1
|
addu outbuf, len # adjust outbuf to roll back extra copied bytes
|
||||||
addi $t1, $t1, 1
|
|
||||||
sb $t2, ($a1)
|
b .Lmatches_ex
|
||||||
addi $a1, $a1, 1
|
sll nibbles, 4
|
||||||
bnez $t3, .L8027EFA0
|
|
||||||
nop
|
.Lend:
|
||||||
.L8027EFBC:
|
lw $ra, 0x14($sp)
|
||||||
sll $t0, $t0, 1
|
lw $s0, 0x18($sp)
|
||||||
addi $a2, $a2, -1
|
lw $s1, 0x1c($sp)
|
||||||
bne $a1, $t8, .L8027EF50
|
lw $s2, 0x20($sp)
|
||||||
nop
|
lw $s3, 0x24($sp)
|
||||||
jr $ra
|
lw $s4, 0x28($sp)
|
||||||
nop
|
lw $s5, 0x2C($sp)
|
||||||
#endif
|
lw $s6, 0x30($sp)
|
||||||
|
lw $s7, 0x34($sp)
|
||||||
|
lw $s8, 0x38($sp)
|
||||||
|
jr $ra
|
||||||
|
addiu $sp, $sp, 0x40
|
||||||
|
|
||||||
|
.Lread_large_amount:
|
||||||
|
li shift, 7
|
||||||
|
.Lread_large_amount_loop:
|
||||||
|
lb $t0, 0(inbuf)
|
||||||
|
add inbuf, 1
|
||||||
|
andi $t1, $t0, 0x7f
|
||||||
|
sllv $t1, $t1, shift
|
||||||
|
or len, $t1
|
||||||
|
bltz $t0, .Lread_large_amount_loop
|
||||||
|
add shift, 7
|
||||||
|
jr $ra
|
||||||
|
nop
|
||||||
|
|
||||||
|
.endfunc
|
||||||
|
|||||||
5
sm64.ld
5
sm64.ld
@@ -46,7 +46,8 @@ SECTIONS
|
|||||||
BEGIN_SEG(main, .)
|
BEGIN_SEG(main, .)
|
||||||
{
|
{
|
||||||
BUILD_DIR/asm/entry.o(.text);
|
BUILD_DIR/asm/entry.o(.text);
|
||||||
BUILD_DIR/asm/decompress.o(.text);
|
BUILD_DIR/asm/decompress.o(.text*);
|
||||||
|
BUILD_DIR/src/game/dma_async.o(.text);
|
||||||
BUILD_DIR/src/game*.o(.text);
|
BUILD_DIR/src/game*.o(.text);
|
||||||
AUDIO_DIR*.o(.text);
|
AUDIO_DIR*.o(.text);
|
||||||
ULTRA_BUILD_DIR/libgultra_rom.a:*.o(.text);
|
ULTRA_BUILD_DIR/libgultra_rom.a:*.o(.text);
|
||||||
@@ -55,6 +56,7 @@ SECTIONS
|
|||||||
|
|
||||||
BUILD_DIR/asm/entry.o(.data*);
|
BUILD_DIR/asm/entry.o(.data*);
|
||||||
BUILD_DIR/asm/decompress.o(.data*);
|
BUILD_DIR/asm/decompress.o(.data*);
|
||||||
|
BUILD_DIR/src/game/dma_async.o(.data);
|
||||||
BUILD_DIR/src/game*.o(.data*);
|
BUILD_DIR/src/game*.o(.data*);
|
||||||
AUDIO_DIR*.o(.data*);
|
AUDIO_DIR*.o(.data*);
|
||||||
ULTRA_BUILD_DIR/libgultra_rom.a:*.o(.data*);
|
ULTRA_BUILD_DIR/libgultra_rom.a:*.o(.data*);
|
||||||
@@ -63,6 +65,7 @@ SECTIONS
|
|||||||
|
|
||||||
BUILD_DIR/asm/entry.o(.rodata*);
|
BUILD_DIR/asm/entry.o(.rodata*);
|
||||||
BUILD_DIR/asm/decompress.o(.rodata*);
|
BUILD_DIR/asm/decompress.o(.rodata*);
|
||||||
|
BUILD_DIR/src/game/dma_async.o(.rodata);
|
||||||
BUILD_DIR/src/game*.o(.rodata*);
|
BUILD_DIR/src/game*.o(.rodata*);
|
||||||
AUDIO_DIR*.o(.rodata*);
|
AUDIO_DIR*.o(.rodata*);
|
||||||
ULTRA_BUILD_DIR/libgultra_rom.a:*.o(.rodata*);
|
ULTRA_BUILD_DIR/libgultra_rom.a:*.o(.rodata*);
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
#include "buffers.h"
|
#include "buffers.h"
|
||||||
|
|
||||||
ALIGNED8 u8 gDecompressionHeap[0xD000];
|
|
||||||
|
|
||||||
#if defined(VERSION_EU)
|
#if defined(VERSION_EU)
|
||||||
ALIGNED16 u8 gAudioHeap[DOUBLE_SIZE_ON_64_BIT(0x31200) - 0x3800];
|
ALIGNED16 u8 gAudioHeap[DOUBLE_SIZE_ON_64_BIT(0x31200) - 0x3800];
|
||||||
#elif defined(VERSION_SH)
|
#elif defined(VERSION_SH)
|
||||||
|
|||||||
@@ -7,8 +7,6 @@
|
|||||||
#include "engine/game_init.h"
|
#include "engine/game_init.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
extern u8 gDecompressionHeap[];
|
|
||||||
|
|
||||||
extern u8 gAudioHeap[];
|
extern u8 gAudioHeap[];
|
||||||
|
|
||||||
extern u8 gAudioSPTaskYieldBuffer[];
|
extern u8 gAudioSPTaskYieldBuffer[];
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ static void level_cmd_load_mario_head(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void level_cmd_load_mio0_texture(void) {
|
static void level_cmd_load_mio0_texture(void) {
|
||||||
load_segment_decompress_heap(CMD_GET(s16, 2), CMD_GET(void *, 4), CMD_GET(void *, 8));
|
load_segment_decompress(CMD_GET(s16, 2), CMD_GET(void *, 4), CMD_GET(void *, 8));
|
||||||
sCurrentCmd = CMD_NEXT;
|
sCurrentCmd = CMD_NEXT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#ifndef DECOMPRESS_H
|
#ifndef DECOMPRESS_H
|
||||||
#define DECOMPRESS_H
|
#define DECOMPRESS_H
|
||||||
|
|
||||||
void decompress(void *mio0, void *dest);
|
void lz4t_unpack_fast(const uint8_t* restrict inbuf, uint8_t* restrict dst, DMAAsyncCtx *ctx);
|
||||||
|
#define DMA_ASYNC_HEADER_SIZE 16
|
||||||
|
|
||||||
#endif // DECOMPRESS_H
|
#endif // DECOMPRESS_H
|
||||||
|
|||||||
42
src/game/dma_async.c
Normal file
42
src/game/dma_async.c
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
#include "dma_async.h"
|
||||||
|
#include "game/main.h"
|
||||||
|
|
||||||
|
#define ALIGN16(val) (((val) + 0xF) & ~0xF)
|
||||||
|
|
||||||
|
void dma_async_ctx_init(DMAAsyncCtx* ctx, u8 *dest, u8 *srcStart, u8 *srcEnd) {
|
||||||
|
u32 size = ALIGN16(srcEnd - srcStart);
|
||||||
|
osInvalDCache(dest, size);
|
||||||
|
|
||||||
|
u32 copySize = (size >= 0x1000) ? 0x1000 : size;
|
||||||
|
|
||||||
|
osPiStartDma(&gDmaIoMesg, OS_MESG_PRI_NORMAL, OS_READ, (uintptr_t) srcStart, dest, copySize, &gDmaMesgQueue);
|
||||||
|
|
||||||
|
dest += copySize;
|
||||||
|
srcStart += copySize;
|
||||||
|
size -= copySize;
|
||||||
|
|
||||||
|
ctx->srcStart = srcStart;
|
||||||
|
ctx->dest = dest;
|
||||||
|
ctx->size = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* dma_async_ctx_read(DMAAsyncCtx* ctx) {
|
||||||
|
// wait for the previous DMA issued
|
||||||
|
osRecvMesg(&gDmaMesgQueue, &gMainReceivedMesg, OS_MESG_BLOCK);
|
||||||
|
|
||||||
|
// start the new DMA transfer
|
||||||
|
u32 copySize = (ctx->size >= 0x1000) ? 0x1000 : ctx->size;
|
||||||
|
if (copySize == 0) {
|
||||||
|
// we are done, return a dummy address that is so gigantic that we will never be called again
|
||||||
|
return (void*) 0x80800000;
|
||||||
|
}
|
||||||
|
osPiStartDma(&gDmaIoMesg, OS_MESG_PRI_NORMAL, OS_READ, (uintptr_t) ctx->srcStart, ctx->dest, copySize, &gDmaMesgQueue);
|
||||||
|
|
||||||
|
const u32 margin = 16;
|
||||||
|
void* ret = ctx->dest - margin;
|
||||||
|
ctx->dest += copySize;
|
||||||
|
ctx->srcStart += copySize;
|
||||||
|
ctx->size -= copySize;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
15
src/game/dma_async.h
Normal file
15
src/game/dma_async.h
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
u8* srcStart;
|
||||||
|
u8* dest;
|
||||||
|
u32 size;
|
||||||
|
} DMAAsyncCtx;
|
||||||
|
|
||||||
|
// Starts to DMA the first block
|
||||||
|
void dma_async_ctx_init(DMAAsyncCtx* ctx, u8 *dest, u8 *srcStart, u8 *srcEnd);
|
||||||
|
|
||||||
|
// Starts to DMA the next block and waits for the previous block
|
||||||
|
void* dma_async_ctx_read(DMAAsyncCtx* ctx);
|
||||||
@@ -183,6 +183,35 @@ int __ucmpdi2(unsigned long long a, unsigned long long b) {
|
|||||||
return (a < b) ? 0 : 2;
|
return (a < b) ? 0 : 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Taken from LLVM
|
||||||
|
|
||||||
|
typedef union {
|
||||||
|
u64 all;
|
||||||
|
struct {
|
||||||
|
u32 high;
|
||||||
|
u32 low;
|
||||||
|
} s;
|
||||||
|
} UdWords;
|
||||||
|
|
||||||
|
s64 __lshrdi3(s64 a, s32 b) {
|
||||||
|
const s32 bits_in_word = (s32)(sizeof(s32) * 8);
|
||||||
|
UdWords input;
|
||||||
|
UdWords result;
|
||||||
|
input.all = a;
|
||||||
|
if (b & bits_in_word) /* bits_in_word <= b < bits_in_dword */ {
|
||||||
|
result.s.high = 0;
|
||||||
|
result.s.low = input.s.high >> (b - bits_in_word);
|
||||||
|
} else /* 0 <= b < bits_in_word */ {
|
||||||
|
if (b == 0) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.s.high = input.s.high >> b;
|
||||||
|
result.s.low = (input.s.high << (bits_in_word - b)) | (input.s.low >> b);
|
||||||
|
}
|
||||||
|
return result.all;
|
||||||
|
}
|
||||||
|
|
||||||
// Compute division and modulo of 64-bit signed and unsigned integers
|
// Compute division and modulo of 64-bit signed and unsigned integers
|
||||||
|
|
||||||
__asm__(" \n\
|
__asm__(" \n\
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "buffers/zbuffer.h"
|
#include "buffers/zbuffer.h"
|
||||||
#include "buffers/buffers.h"
|
#include "buffers/buffers.h"
|
||||||
|
#include "dma_async.h"
|
||||||
#include "decompress.h"
|
#include "decompress.h"
|
||||||
#include "engine/game_init.h"
|
#include "engine/game_init.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
@@ -342,7 +343,10 @@ void *load_segment_decompress(s32 segment, u8 *srcStart, u8 *srcEnd) {
|
|||||||
dest = main_pool_alloc(*size, MEMORY_POOL_LEFT);
|
dest = main_pool_alloc(*size, MEMORY_POOL_LEFT);
|
||||||
if (dest != NULL) {
|
if (dest != NULL) {
|
||||||
CN_DEBUG_PRINTF(("start decompress\n"));
|
CN_DEBUG_PRINTF(("start decompress\n"));
|
||||||
decompress(compressed, dest);
|
dma_read(compressed, srcStart, srcStart + DMA_ASYNC_HEADER_SIZE);
|
||||||
|
DMAAsyncCtx asyncCtx;
|
||||||
|
dma_async_ctx_init(&asyncCtx, compressed + DMA_ASYNC_HEADER_SIZE, srcStart + DMA_ASYNC_HEADER_SIZE, srcEnd);
|
||||||
|
lz4t_unpack_fast(compressed, dest, &asyncCtx);
|
||||||
CN_DEBUG_PRINTF(("end decompress\n"));
|
CN_DEBUG_PRINTF(("end decompress\n"));
|
||||||
|
|
||||||
set_segment_base_addr(segment, dest);
|
set_segment_base_addr(segment, dest);
|
||||||
@@ -354,22 +358,6 @@ void *load_segment_decompress(s32 segment, u8 *srcStart, u8 *srcEnd) {
|
|||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *load_segment_decompress_heap(u32 segment, u8 *srcStart, u8 *srcEnd) {
|
|
||||||
UNUSED void *dest = NULL;
|
|
||||||
u32 compSize = ALIGN16(srcEnd - srcStart);
|
|
||||||
u8 *compressed = main_pool_alloc(compSize, MEMORY_POOL_RIGHT);
|
|
||||||
UNUSED u32 *pUncSize = (u32 *) (compressed + 4);
|
|
||||||
|
|
||||||
if (compressed != NULL) {
|
|
||||||
dma_read(compressed, srcStart, srcEnd);
|
|
||||||
decompress(compressed, gDecompressionHeap);
|
|
||||||
set_segment_base_addr(segment, gDecompressionHeap);
|
|
||||||
main_pool_free(compressed);
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
return gDecompressionHeap;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef LIBDRAGON_IPL3
|
#ifndef LIBDRAGON_IPL3
|
||||||
void load_engine_code_segment(void) {
|
void load_engine_code_segment(void) {
|
||||||
void *startAddr = (void *) _engineSegmentStart;
|
void *startAddr = (void *) _engineSegmentStart;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ CC := gcc
|
|||||||
CXX := g++
|
CXX := g++
|
||||||
CFLAGS := -I . -I sm64tools -Wall -Wextra -Wno-unused-parameter -pedantic -O2 -s
|
CFLAGS := -I . -I sm64tools -Wall -Wextra -Wno-unused-parameter -pedantic -O2 -s
|
||||||
LDFLAGS := -lm
|
LDFLAGS := -lm
|
||||||
ALL_PROGRAMS := armips textconv patch_elf_32bit aifc_decode aiff_extract_codebook vadpcm_enc tabledesign extract_data_for_mio skyconv
|
ALL_PROGRAMS := armips textconv patch_elf_32bit aifc_decode aiff_extract_codebook vadpcm_enc tabledesign extract_data_for_mio skyconv lz4tpack
|
||||||
LIBAUDIOFILE := audiofile/libaudiofile.a
|
LIBAUDIOFILE := audiofile/libaudiofile.a
|
||||||
|
|
||||||
# Only build armips from tools if it is not found on the system
|
# Only build armips from tools if it is not found on the system
|
||||||
@@ -19,6 +19,9 @@ endif
|
|||||||
|
|
||||||
default: all
|
default: all
|
||||||
|
|
||||||
|
lz4tpack_SOURCES := lz4tpack.c
|
||||||
|
lz4tpack_CFLAGS := -DLZ4T -flto -O3 -fwhole-program
|
||||||
|
|
||||||
textconv_SOURCES := textconv.c utf8.c hashtable.c
|
textconv_SOURCES := textconv.c utf8.c hashtable.c
|
||||||
|
|
||||||
patch_elf_32bit_SOURCES := patch_elf_32bit.c
|
patch_elf_32bit_SOURCES := patch_elf_32bit.c
|
||||||
|
|||||||
2839
tools/lz4.c
Normal file
2839
tools/lz4.c
Normal file
File diff suppressed because it is too large
Load Diff
884
tools/lz4.h
Normal file
884
tools/lz4.h
Normal file
File diff suppressed because it is too large
Load Diff
2075
tools/lz4hc.c
Normal file
2075
tools/lz4hc.c
Normal file
File diff suppressed because it is too large
Load Diff
413
tools/lz4hc.h
Normal file
413
tools/lz4hc.h
Normal file
@@ -0,0 +1,413 @@
|
|||||||
|
/*
|
||||||
|
LZ4 HC - High Compression Mode of LZ4
|
||||||
|
Header File
|
||||||
|
Copyright (C) 2011-2020, Yann Collet.
|
||||||
|
BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
|
in the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
You can contact the author at :
|
||||||
|
- LZ4 source repository : https://github.com/lz4/lz4
|
||||||
|
- LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c
|
||||||
|
*/
|
||||||
|
#ifndef LZ4_HC_H_19834876238432
|
||||||
|
#define LZ4_HC_H_19834876238432
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* --- Dependency --- */
|
||||||
|
/* note : lz4hc requires lz4.h/lz4.c for compilation */
|
||||||
|
#include "lz4.h" /* stddef, LZ4LIB_API, LZ4_DEPRECATED */
|
||||||
|
|
||||||
|
|
||||||
|
/* --- Useful constants --- */
|
||||||
|
#define LZ4HC_CLEVEL_MIN 2
|
||||||
|
#define LZ4HC_CLEVEL_DEFAULT 9
|
||||||
|
#define LZ4HC_CLEVEL_OPT_MIN 10
|
||||||
|
#define LZ4HC_CLEVEL_MAX 12
|
||||||
|
|
||||||
|
|
||||||
|
/*-************************************
|
||||||
|
* Block Compression
|
||||||
|
**************************************/
|
||||||
|
/*! LZ4_compress_HC() :
|
||||||
|
* Compress data from `src` into `dst`, using the powerful but slower "HC" algorithm.
|
||||||
|
* `dst` must be already allocated.
|
||||||
|
* Compression is guaranteed to succeed if `dstCapacity >= LZ4_compressBound(srcSize)` (see "lz4.h")
|
||||||
|
* Max supported `srcSize` value is LZ4_MAX_INPUT_SIZE (see "lz4.h")
|
||||||
|
* `compressionLevel` : any value between 1 and LZ4HC_CLEVEL_MAX will work.
|
||||||
|
* Values > LZ4HC_CLEVEL_MAX behave the same as LZ4HC_CLEVEL_MAX.
|
||||||
|
* @return : the number of bytes written into 'dst'
|
||||||
|
* or 0 if compression fails.
|
||||||
|
*/
|
||||||
|
LZ4LIB_API int LZ4_compress_HC (const char* src, char* dst, int srcSize, int dstCapacity, int compressionLevel);
|
||||||
|
|
||||||
|
|
||||||
|
/* Note :
|
||||||
|
* Decompression functions are provided within "lz4.h" (BSD license)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*! LZ4_compress_HC_extStateHC() :
|
||||||
|
* Same as LZ4_compress_HC(), but using an externally allocated memory segment for `state`.
|
||||||
|
* `state` size is provided by LZ4_sizeofStateHC().
|
||||||
|
* Memory segment must be aligned on 8-bytes boundaries (which a normal malloc() should do properly).
|
||||||
|
*/
|
||||||
|
LZ4LIB_API int LZ4_sizeofStateHC(void);
|
||||||
|
LZ4LIB_API int LZ4_compress_HC_extStateHC(void* stateHC, const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel);
|
||||||
|
|
||||||
|
|
||||||
|
/*! LZ4_compress_HC_destSize() : v1.9.0+
|
||||||
|
* Will compress as much data as possible from `src`
|
||||||
|
* to fit into `targetDstSize` budget.
|
||||||
|
* Result is provided in 2 parts :
|
||||||
|
* @return : the number of bytes written into 'dst' (necessarily <= targetDstSize)
|
||||||
|
* or 0 if compression fails.
|
||||||
|
* `srcSizePtr` : on success, *srcSizePtr is updated to indicate how much bytes were read from `src`
|
||||||
|
*/
|
||||||
|
LZ4LIB_API int LZ4_compress_HC_destSize(void* stateHC,
|
||||||
|
const char* src, char* dst,
|
||||||
|
int* srcSizePtr, int targetDstSize,
|
||||||
|
int compressionLevel);
|
||||||
|
|
||||||
|
|
||||||
|
/*-************************************
|
||||||
|
* Streaming Compression
|
||||||
|
* Bufferless synchronous API
|
||||||
|
**************************************/
|
||||||
|
typedef union LZ4_streamHC_u LZ4_streamHC_t; /* incomplete type (defined later) */
|
||||||
|
|
||||||
|
/*! LZ4_createStreamHC() and LZ4_freeStreamHC() :
|
||||||
|
* These functions create and release memory for LZ4 HC streaming state.
|
||||||
|
* Newly created states are automatically initialized.
|
||||||
|
* A same state can be used multiple times consecutively,
|
||||||
|
* starting with LZ4_resetStreamHC_fast() to start a new stream of blocks.
|
||||||
|
*/
|
||||||
|
LZ4LIB_API LZ4_streamHC_t* LZ4_createStreamHC(void);
|
||||||
|
LZ4LIB_API int LZ4_freeStreamHC (LZ4_streamHC_t* streamHCPtr);
|
||||||
|
|
||||||
|
/*
|
||||||
|
These functions compress data in successive blocks of any size,
|
||||||
|
using previous blocks as dictionary, to improve compression ratio.
|
||||||
|
One key assumption is that previous blocks (up to 64 KB) remain read-accessible while compressing next blocks.
|
||||||
|
There is an exception for ring buffers, which can be smaller than 64 KB.
|
||||||
|
Ring-buffer scenario is automatically detected and handled within LZ4_compress_HC_continue().
|
||||||
|
|
||||||
|
Before starting compression, state must be allocated and properly initialized.
|
||||||
|
LZ4_createStreamHC() does both, though compression level is set to LZ4HC_CLEVEL_DEFAULT.
|
||||||
|
|
||||||
|
Selecting the compression level can be done with LZ4_resetStreamHC_fast() (starts a new stream)
|
||||||
|
or LZ4_setCompressionLevel() (anytime, between blocks in the same stream) (experimental).
|
||||||
|
LZ4_resetStreamHC_fast() only works on states which have been properly initialized at least once,
|
||||||
|
which is automatically the case when state is created using LZ4_createStreamHC().
|
||||||
|
|
||||||
|
After reset, a first "fictional block" can be designated as initial dictionary,
|
||||||
|
using LZ4_loadDictHC() (Optional).
|
||||||
|
|
||||||
|
Invoke LZ4_compress_HC_continue() to compress each successive block.
|
||||||
|
The number of blocks is unlimited.
|
||||||
|
Previous input blocks, including initial dictionary when present,
|
||||||
|
must remain accessible and unmodified during compression.
|
||||||
|
|
||||||
|
It's allowed to update compression level anytime between blocks,
|
||||||
|
using LZ4_setCompressionLevel() (experimental).
|
||||||
|
|
||||||
|
'dst' buffer should be sized to handle worst case scenarios
|
||||||
|
(see LZ4_compressBound(), it ensures compression success).
|
||||||
|
In case of failure, the API does not guarantee recovery,
|
||||||
|
so the state _must_ be reset.
|
||||||
|
To ensure compression success
|
||||||
|
whenever `dst` buffer size cannot be made >= LZ4_compressBound(),
|
||||||
|
consider using LZ4_compress_HC_continue_destSize().
|
||||||
|
|
||||||
|
Whenever previous input blocks can't be preserved unmodified in-place during compression of next blocks,
|
||||||
|
it's possible to copy the last blocks into a more stable memory space, using LZ4_saveDictHC().
|
||||||
|
Return value of LZ4_saveDictHC() is the size of dictionary effectively saved into 'safeBuffer' (<= 64 KB)
|
||||||
|
|
||||||
|
After completing a streaming compression,
|
||||||
|
it's possible to start a new stream of blocks, using the same LZ4_streamHC_t state,
|
||||||
|
just by resetting it, using LZ4_resetStreamHC_fast().
|
||||||
|
*/
|
||||||
|
|
||||||
|
LZ4LIB_API void LZ4_resetStreamHC_fast(LZ4_streamHC_t* streamHCPtr, int compressionLevel); /* v1.9.0+ */
|
||||||
|
LZ4LIB_API int LZ4_loadDictHC (LZ4_streamHC_t* streamHCPtr, const char* dictionary, int dictSize);
|
||||||
|
|
||||||
|
LZ4LIB_API int LZ4_compress_HC_continue (LZ4_streamHC_t* streamHCPtr,
|
||||||
|
const char* src, char* dst,
|
||||||
|
int srcSize, int maxDstSize);
|
||||||
|
|
||||||
|
/*! LZ4_compress_HC_continue_destSize() : v1.9.0+
|
||||||
|
* Similar to LZ4_compress_HC_continue(),
|
||||||
|
* but will read as much data as possible from `src`
|
||||||
|
* to fit into `targetDstSize` budget.
|
||||||
|
* Result is provided into 2 parts :
|
||||||
|
* @return : the number of bytes written into 'dst' (necessarily <= targetDstSize)
|
||||||
|
* or 0 if compression fails.
|
||||||
|
* `srcSizePtr` : on success, *srcSizePtr will be updated to indicate how much bytes were read from `src`.
|
||||||
|
* Note that this function may not consume the entire input.
|
||||||
|
*/
|
||||||
|
LZ4LIB_API int LZ4_compress_HC_continue_destSize(LZ4_streamHC_t* LZ4_streamHCPtr,
|
||||||
|
const char* src, char* dst,
|
||||||
|
int* srcSizePtr, int targetDstSize);
|
||||||
|
|
||||||
|
LZ4LIB_API int LZ4_saveDictHC (LZ4_streamHC_t* streamHCPtr, char* safeBuffer, int maxDictSize);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*^**********************************************
|
||||||
|
* !!!!!! STATIC LINKING ONLY !!!!!!
|
||||||
|
***********************************************/
|
||||||
|
|
||||||
|
/*-******************************************************************
|
||||||
|
* PRIVATE DEFINITIONS :
|
||||||
|
* Do not use these definitions directly.
|
||||||
|
* They are merely exposed to allow static allocation of `LZ4_streamHC_t`.
|
||||||
|
* Declare an `LZ4_streamHC_t` directly, rather than any type below.
|
||||||
|
* Even then, only do so in the context of static linking, as definitions may change between versions.
|
||||||
|
********************************************************************/
|
||||||
|
|
||||||
|
#define LZ4HC_DICTIONARY_LOGSIZE 16
|
||||||
|
#define LZ4HC_MAXD (1<<LZ4HC_DICTIONARY_LOGSIZE)
|
||||||
|
#define LZ4HC_MAXD_MASK (LZ4HC_MAXD - 1)
|
||||||
|
|
||||||
|
#define LZ4HC_HASH_LOG 15
|
||||||
|
#define LZ4HC_HASHTABLESIZE (1 << LZ4HC_HASH_LOG)
|
||||||
|
#define LZ4HC_HASH_MASK (LZ4HC_HASHTABLESIZE - 1)
|
||||||
|
|
||||||
|
|
||||||
|
/* Never ever use these definitions directly !
|
||||||
|
* Declare or allocate an LZ4_streamHC_t instead.
|
||||||
|
**/
|
||||||
|
typedef struct LZ4HC_CCtx_internal LZ4HC_CCtx_internal;
|
||||||
|
struct LZ4HC_CCtx_internal
|
||||||
|
{
|
||||||
|
LZ4_u32 hashTable[LZ4HC_HASHTABLESIZE];
|
||||||
|
LZ4_u16 chainTable[LZ4HC_MAXD];
|
||||||
|
const LZ4_byte* end; /* next block here to continue on current prefix */
|
||||||
|
const LZ4_byte* prefixStart; /* Indexes relative to this position */
|
||||||
|
const LZ4_byte* dictStart; /* alternate reference for extDict */
|
||||||
|
LZ4_u32 dictLimit; /* below that point, need extDict */
|
||||||
|
LZ4_u32 lowLimit; /* below that point, no more dict */
|
||||||
|
LZ4_u32 nextToUpdate; /* index from which to continue dictionary update */
|
||||||
|
short compressionLevel;
|
||||||
|
LZ4_i8 favorDecSpeed; /* favor decompression speed if this flag set,
|
||||||
|
otherwise, favor compression ratio */
|
||||||
|
LZ4_i8 dirty; /* stream has to be fully reset if this flag is set */
|
||||||
|
const LZ4HC_CCtx_internal* dictCtx;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define LZ4_STREAMHC_MINSIZE 262200 /* static size, for inter-version compatibility */
|
||||||
|
union LZ4_streamHC_u {
|
||||||
|
char minStateSize[LZ4_STREAMHC_MINSIZE];
|
||||||
|
LZ4HC_CCtx_internal internal_donotuse;
|
||||||
|
}; /* previously typedef'd to LZ4_streamHC_t */
|
||||||
|
|
||||||
|
/* LZ4_streamHC_t :
|
||||||
|
* This structure allows static allocation of LZ4 HC streaming state.
|
||||||
|
* This can be used to allocate statically on stack, or as part of a larger structure.
|
||||||
|
*
|
||||||
|
* Such state **must** be initialized using LZ4_initStreamHC() before first use.
|
||||||
|
*
|
||||||
|
* Note that invoking LZ4_initStreamHC() is not required when
|
||||||
|
* the state was created using LZ4_createStreamHC() (which is recommended).
|
||||||
|
* Using the normal builder, a newly created state is automatically initialized.
|
||||||
|
*
|
||||||
|
* Static allocation shall only be used in combination with static linking.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* LZ4_initStreamHC() : v1.9.0+
|
||||||
|
* Required before first use of a statically allocated LZ4_streamHC_t.
|
||||||
|
* Before v1.9.0 : use LZ4_resetStreamHC() instead
|
||||||
|
*/
|
||||||
|
LZ4LIB_API LZ4_streamHC_t* LZ4_initStreamHC(void* buffer, size_t size);
|
||||||
|
|
||||||
|
|
||||||
|
/*-************************************
|
||||||
|
* Deprecated Functions
|
||||||
|
**************************************/
|
||||||
|
/* see lz4.h LZ4_DISABLE_DEPRECATE_WARNINGS to turn off deprecation warnings */
|
||||||
|
|
||||||
|
/* deprecated compression functions */
|
||||||
|
LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC (const char* source, char* dest, int inputSize);
|
||||||
|
LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||||
|
LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC2 (const char* source, char* dest, int inputSize, int compressionLevel);
|
||||||
|
LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC2_limitedOutput(const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
|
||||||
|
LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC_withStateHC (void* state, const char* source, char* dest, int inputSize);
|
||||||
|
LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC_limitedOutput_withStateHC (void* state, const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||||
|
LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC2_withStateHC (void* state, const char* source, char* dest, int inputSize, int compressionLevel);
|
||||||
|
LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC2_limitedOutput_withStateHC(void* state, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
|
||||||
|
LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize);
|
||||||
|
LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC_limitedOutput_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize, int maxOutputSize);
|
||||||
|
|
||||||
|
/* Obsolete streaming functions; degraded functionality; do not use!
|
||||||
|
*
|
||||||
|
* In order to perform streaming compression, these functions depended on data
|
||||||
|
* that is no longer tracked in the state. They have been preserved as well as
|
||||||
|
* possible: using them will still produce a correct output. However, use of
|
||||||
|
* LZ4_slideInputBufferHC() will truncate the history of the stream, rather
|
||||||
|
* than preserve a window-sized chunk of history.
|
||||||
|
*/
|
||||||
|
#if !defined(LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION)
|
||||||
|
LZ4_DEPRECATED("use LZ4_createStreamHC() instead") LZ4LIB_API void* LZ4_createHC (const char* inputBuffer);
|
||||||
|
LZ4_DEPRECATED("use LZ4_freeStreamHC() instead") LZ4LIB_API int LZ4_freeHC (void* LZ4HC_Data);
|
||||||
|
#endif
|
||||||
|
LZ4_DEPRECATED("use LZ4_saveDictHC() instead") LZ4LIB_API char* LZ4_slideInputBufferHC (void* LZ4HC_Data);
|
||||||
|
LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC2_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int compressionLevel);
|
||||||
|
LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC2_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel);
|
||||||
|
LZ4_DEPRECATED("use LZ4_createStreamHC() instead") LZ4LIB_API int LZ4_sizeofStreamStateHC(void);
|
||||||
|
LZ4_DEPRECATED("use LZ4_initStreamHC() instead") LZ4LIB_API int LZ4_resetStreamStateHC(void* state, char* inputBuffer);
|
||||||
|
|
||||||
|
|
||||||
|
/* LZ4_resetStreamHC() is now replaced by LZ4_initStreamHC().
|
||||||
|
* The intention is to emphasize the difference with LZ4_resetStreamHC_fast(),
|
||||||
|
* which is now the recommended function to start a new stream of blocks,
|
||||||
|
* but cannot be used to initialize a memory segment containing arbitrary garbage data.
|
||||||
|
*
|
||||||
|
* It is recommended to switch to LZ4_initStreamHC().
|
||||||
|
* LZ4_resetStreamHC() will generate deprecation warnings in a future version.
|
||||||
|
*/
|
||||||
|
LZ4LIB_API void LZ4_resetStreamHC (LZ4_streamHC_t* streamHCPtr, int compressionLevel);
|
||||||
|
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LZ4_HC_H_19834876238432 */
|
||||||
|
|
||||||
|
|
||||||
|
/*-**************************************************
|
||||||
|
* !!!!! STATIC LINKING ONLY !!!!!
|
||||||
|
* Following definitions are considered experimental.
|
||||||
|
* They should not be linked from DLL,
|
||||||
|
* as there is no guarantee of API stability yet.
|
||||||
|
* Prototypes will be promoted to "stable" status
|
||||||
|
* after successful usage in real-life scenarios.
|
||||||
|
***************************************************/
|
||||||
|
#ifdef LZ4_HC_STATIC_LINKING_ONLY /* protection macro */
|
||||||
|
#ifndef LZ4_HC_SLO_098092834
|
||||||
|
#define LZ4_HC_SLO_098092834
|
||||||
|
|
||||||
|
#define LZ4_STATIC_LINKING_ONLY /* LZ4LIB_STATIC_API */
|
||||||
|
#include "lz4.h"
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*! LZ4_setCompressionLevel() : v1.8.0+ (experimental)
|
||||||
|
* It's possible to change compression level
|
||||||
|
* between successive invocations of LZ4_compress_HC_continue*()
|
||||||
|
* for dynamic adaptation.
|
||||||
|
*/
|
||||||
|
LZ4LIB_STATIC_API void LZ4_setCompressionLevel(
|
||||||
|
LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLevel);
|
||||||
|
|
||||||
|
/*! LZ4_favorDecompressionSpeed() : v1.8.2+ (experimental)
|
||||||
|
* Opt. Parser will favor decompression speed over compression ratio.
|
||||||
|
* Only applicable to levels >= LZ4HC_CLEVEL_OPT_MIN.
|
||||||
|
*/
|
||||||
|
LZ4LIB_STATIC_API void LZ4_favorDecompressionSpeed(
|
||||||
|
LZ4_streamHC_t* LZ4_streamHCPtr, int favor);
|
||||||
|
|
||||||
|
/*! LZ4_resetStreamHC_fast() : v1.9.0+
|
||||||
|
* When an LZ4_streamHC_t is known to be in a internally coherent state,
|
||||||
|
* it can often be prepared for a new compression with almost no work, only
|
||||||
|
* sometimes falling back to the full, expensive reset that is always required
|
||||||
|
* when the stream is in an indeterminate state (i.e., the reset performed by
|
||||||
|
* LZ4_resetStreamHC()).
|
||||||
|
*
|
||||||
|
* LZ4_streamHCs are guaranteed to be in a valid state when:
|
||||||
|
* - returned from LZ4_createStreamHC()
|
||||||
|
* - reset by LZ4_resetStreamHC()
|
||||||
|
* - memset(stream, 0, sizeof(LZ4_streamHC_t))
|
||||||
|
* - the stream was in a valid state and was reset by LZ4_resetStreamHC_fast()
|
||||||
|
* - the stream was in a valid state and was then used in any compression call
|
||||||
|
* that returned success
|
||||||
|
* - the stream was in an indeterminate state and was used in a compression
|
||||||
|
* call that fully reset the state (LZ4_compress_HC_extStateHC()) and that
|
||||||
|
* returned success
|
||||||
|
*
|
||||||
|
* Note:
|
||||||
|
* A stream that was last used in a compression call that returned an error
|
||||||
|
* may be passed to this function. However, it will be fully reset, which will
|
||||||
|
* clear any existing history and settings from the context.
|
||||||
|
*/
|
||||||
|
LZ4LIB_STATIC_API void LZ4_resetStreamHC_fast(
|
||||||
|
LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLevel);
|
||||||
|
|
||||||
|
/*! LZ4_compress_HC_extStateHC_fastReset() :
|
||||||
|
* A variant of LZ4_compress_HC_extStateHC().
|
||||||
|
*
|
||||||
|
* Using this variant avoids an expensive initialization step. It is only safe
|
||||||
|
* to call if the state buffer is known to be correctly initialized already
|
||||||
|
* (see above comment on LZ4_resetStreamHC_fast() for a definition of
|
||||||
|
* "correctly initialized"). From a high level, the difference is that this
|
||||||
|
* function initializes the provided state with a call to
|
||||||
|
* LZ4_resetStreamHC_fast() while LZ4_compress_HC_extStateHC() starts with a
|
||||||
|
* call to LZ4_resetStreamHC().
|
||||||
|
*/
|
||||||
|
LZ4LIB_STATIC_API int LZ4_compress_HC_extStateHC_fastReset (
|
||||||
|
void* state,
|
||||||
|
const char* src, char* dst,
|
||||||
|
int srcSize, int dstCapacity,
|
||||||
|
int compressionLevel);
|
||||||
|
|
||||||
|
/*! LZ4_attach_HC_dictionary() :
|
||||||
|
* This is an experimental API that allows for the efficient use of a
|
||||||
|
* static dictionary many times.
|
||||||
|
*
|
||||||
|
* Rather than re-loading the dictionary buffer into a working context before
|
||||||
|
* each compression, or copying a pre-loaded dictionary's LZ4_streamHC_t into a
|
||||||
|
* working LZ4_streamHC_t, this function introduces a no-copy setup mechanism,
|
||||||
|
* in which the working stream references the dictionary stream in-place.
|
||||||
|
*
|
||||||
|
* Several assumptions are made about the state of the dictionary stream.
|
||||||
|
* Currently, only streams which have been prepared by LZ4_loadDictHC() should
|
||||||
|
* be expected to work.
|
||||||
|
*
|
||||||
|
* Alternatively, the provided dictionary stream pointer may be NULL, in which
|
||||||
|
* case any existing dictionary stream is unset.
|
||||||
|
*
|
||||||
|
* A dictionary should only be attached to a stream without any history (i.e.,
|
||||||
|
* a stream that has just been reset).
|
||||||
|
*
|
||||||
|
* The dictionary will remain attached to the working stream only for the
|
||||||
|
* current stream session. Calls to LZ4_resetStreamHC(_fast) will remove the
|
||||||
|
* dictionary context association from the working stream. The dictionary
|
||||||
|
* stream (and source buffer) must remain in-place / accessible / unchanged
|
||||||
|
* through the lifetime of the stream session.
|
||||||
|
*/
|
||||||
|
LZ4LIB_STATIC_API void LZ4_attach_HC_dictionary(
|
||||||
|
LZ4_streamHC_t *working_stream,
|
||||||
|
const LZ4_streamHC_t *dictionary_stream);
|
||||||
|
|
||||||
|
#if defined (__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* LZ4_HC_SLO_098092834 */
|
||||||
|
#endif /* LZ4_HC_STATIC_LINKING_ONLY */
|
||||||
BIN
tools/lz4tpack
Executable file
BIN
tools/lz4tpack
Executable file
Binary file not shown.
780
tools/lz4tpack.c
Normal file
780
tools/lz4tpack.c
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user