+===========================================================+ | Introduction to the losslessy compression schemes | | Description of the codec source codes | +-----------------------------------------------------------+ | From David Bourgin (E-mail: david.bourgin@ufrima.imag.fr) | | Date: 22/9/94 | +===========================================================+ ------ BE CARE ------ This file (compress.txt) is copyrighted. (c) David Bourgin - 1994 Permission to use this documentation for any purpose other than its incorporation into a commercial product is hereby granted without fee. Permission to copy and distribute this documentation only for non-commercial use is also granted without fee, provided, however, that the above copyright notice appears in all copies, that both that copyright notice and this permission notice appear in supporting documentation. The author makes no representations about the suitability of this documentation for any purpose. It is provided "as is" without express or implied warranty. The source codes you obtain with this file are *NOT* covered by the same copyright, because you can include them for both commercial and non-commercial use. See below for more infos. The source code files (codrl1.c, dcodrl1.c, codrle2.c, dcodrle2.c, codrle3.c, dcodrle3.c, codrle4.c, dcodrle4.c, codhuff.c, dcodhuff.c) are copyrighted. They have been uploaded on ftp in turing.imag.fr (129.88.31.7):/pub/compression on 22/5/94 and have been modified on 22/9/94. (c) David Bourgin - 1994 The source codes I provide have no buggs (!) but being that I make them available for free I have some notes to make. They can change at any time without notice. I assume no responsability or liability for any errors or inaccurracies, make no warranty of any kind (express, implied or statutory) with respect to this publication and expressly disclaim any and all warranties of merchantability, fitness for particular purposes. Of course, if you have some problems to use the information presented here, I will try to help you if I can. If you include the source codes in your application, here are the conditions: - You have to put my name in the header of your source file (not in the excutable program if you don't want) (this item is a must) - I would like to see your resulting application, if possible (this item is not a must, because some applications must remain secret) - Whenever you gain money with your application, I would like to receive a very little part in order to be encouraged to update my source codes and to develop new schemes (this item is not a must) --------------------- There are several means to compress data. Here, we are only going to deal with the losslessy schemes. These schemes are also called non-destructive because you always recover the initial data you had, and this, as soon as you need them. With losslessy schemes, you won't never lose any informations (except perhaps when you store or transmit your data but this is another problem...). In this introduction, we are going to see: - The RLE scheme (with different possible algorithms) - The Huffman schemes (dynamical scheme) - And the LZW scheme For the novice, a compresser is a program able to read several data (e.g. bytes) in input and to write several data in output. The data you obtain from the output (also called compressed data) will - of course - take less space than the the input data. This is true in most of cases, if the compresser works and if the type of the data is correct to be compressed with the given scheme. The codec (coder-decoder) enables you to save space on your hard disk and/or to save the communication costs because you always store/transmit the compressed data. You'll use the decompresser as soon as you need to recover your initial useful data. Note that the compressed data are useless if you have not the decoder... You are doubtless asking "How can I reduce the data size without losing some informations?". It's easy to answer to this question. I'll only take an example. I'm sure you have heard about the morse. This system established in the 19th century use a scheme very close to the huffman one. In the morse you encode the letters to transmit with two kinds of signs. If you encode these two sign possibilities in one bit, the symbol 'e' is transmitted in a single bit and the symbols 'y' and 'z' need four bits. Look at the symbols in the text you are reading, you'll fast understand the compression ratio... Important: The source codes associated to the algorithms I present are completely adaptative on what you need to compress. They all use basical macros on the top of the file. Usually the macros to change are: - beginning_of_data - end_of_data - read_byte - read_block - write_byte - write_block These allow the programmer to modify only a little part of the header of the source codes in order to compress as well memory as files. beginning_of_data(): Macro used to set the program so that the next read_byte() call will read the first byte to compress. end_of_data(): Returns a boolean to know whether there is no more bytes to read from the input stream. Return 0 if there is no more byte to compress, another non-zero value otherwise. read_byte(): Returns a byte read from the input stream if available. write_byte(x): Writes the byte 'x' to the output stream. read_block(...) and write_block(...): Same use as read_byte and write_byte(x) but these macros work on blocks of bytes and not only on a single byte. If you want to compress *from* the memory, before entering in a xxxcoding procedure ('xxx' is the actual extension to replace with a given codec), you have to add a pointer set up to the beginning of the zone to compress. Note that the following pointer 'source_memory_base' is not to add, it is just given here to specify a name to the address of the memory zone you are going to encode or decode. That is the same about source_memory_end which can be either a pointer to create or an existing pointer. unsigned char *source_memory_base, /* Base of the source memory */ *source_memory_end, /* Last address to read. source_memory_end=source_memory_base+source_zone_length-1 */ *source_ptr; /* Used in the xxxcoding procedure */ void pre_start() { source_ptr=source_memory_base; xxxcoding(); } end_of_data() and read_byte() are also to modify to compress *from* memory: #define end_of_data() (source_ptr>source_memory_end) #define read_byte() (*(source_ptr++)) If you want to compress *to* memory, before entering in a xxxcoding p * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ #ifndef NVGPU_PMGR_PWRDEV_H #define NVGPU_PMGR_PWRDEV_H #include "boardobj/boardobj.h" #include <nvgpu/pmuif/nvgpu_gpmu_cmdif.h> #include "ctrl/ctrlpmgr.h" #define PWRDEV_I2CDEV_DEVICE_INDEX_NONE (0xFF) #define PWR_DEVICE_PROV_NUM_DEFAULT 1 struct pwr_device { struct boardobj super; u8 power_rail; u8 i2c_dev_idx; bool bIs_inforom_config; u32 power_corr_factor; }; struct pwr_devices { struct boardobjgrp_e32 super; }; struct pwr_device_ina3221 { struct pwr_device super; struct ctrl_pmgr_pwr_device_info_rshunt r_shuntm_ohm[NV_PMU_PMGR_PWR_DEVICE_INA3221_CH_NUM]; u16 configuration; u16 mask_enable; u8 gpio_function; u16 curr_correct_m; s16 curr_correct_b; } ; int pmgr_device_sw_setup(struct gk20a *g); #endif /* NVGPU_PMGR_PWRDEV_H */