mirror of
https://github.com/aaru-dps/Aaru.Compression.Native.git
synced 2026-04-23 06:22:15 +00:00
- Implemented range coder in `rangecoder.c` and `rangecoder.h` for efficient encoding/decoding. - Added RLE90 decoding in `rle90.c` for handling StuffIt method 1. - Introduced `stuffit.h` and `stuffit_internal.h` to define compression methods and internal structures. - Implemented x86 address transformation in `x86.c` for StuffIt X preprocessing. - Updated CMakeLists to include new test data files for various StuffIt methods. - Created comprehensive tests in `stuffit.cpp` for validating decompression of multiple StuffIt formats. - Added binary test data for StuffIt methods including compress, method 13, arsenic, and StuffIt X variants.
48 lines
1.8 KiB
C
48 lines
1.8 KiB
C
/*
|
|
* This file is part of the Aaru Data Preservation Suite.
|
|
* Copyright (c) 2019-2026 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 AARU_STUFFIT_RANGECODER_H
|
|
#define AARU_STUFFIT_RANGECODER_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
typedef struct StuffitRangeCoder
|
|
{
|
|
const uint8_t *data;
|
|
size_t data_len;
|
|
size_t pos;
|
|
uint32_t low, code, range, bottom;
|
|
bool use_low;
|
|
} StuffitRangeCoder;
|
|
|
|
void stuffit_rc_init(StuffitRangeCoder *self, const uint8_t *data, size_t data_len, size_t *pos, bool use_low,
|
|
uint32_t bottom);
|
|
|
|
uint32_t stuffit_rc_current_count(StuffitRangeCoder *self, uint32_t scale);
|
|
void stuffit_rc_remove_subrange(StuffitRangeCoder *self, uint32_t lowcount, uint32_t highcount);
|
|
void stuffit_rc_normalize(StuffitRangeCoder *self);
|
|
|
|
int stuffit_rc_next_symbol(StuffitRangeCoder *self, uint32_t *freqtable, int numfreq);
|
|
int stuffit_rc_next_bit(StuffitRangeCoder *self);
|
|
int stuffit_rc_next_weighted_bit(StuffitRangeCoder *self, int weight, int size);
|
|
int stuffit_rc_next_weighted_bit2(StuffitRangeCoder *self, int weight, int shift);
|
|
|
|
#endif /* AARU_STUFFIT_RANGECODER_H */
|