Compare commits

...

1 Commits

Author SHA1 Message Date
Phuntsok Drak-pa
7775fec68e test nouvelles fonctions 2018-06-17 04:09:25 +02:00
8 changed files with 976 additions and 150 deletions

View File

@ -7,7 +7,7 @@ set(TGT "projet_lzw")
set(${TGT}_VERSION_MAJOR 0)
set(${TGT}_VERSION_MINOR 1)
set(CXX_COVERAGE_COMPILE_FLAGS "-pedantic -Wall -Wextra -Wold-style-cast -Woverloaded-virtual -Wfloat-equal -Wwrite-strings -Wpointer-arith -Wcast-qual -Wcast-align -Wconversion -Wsign-conversion -Wshadow -Weffc++ -Wredundant-decls -Wdouble-promotion -Winit-self -Wswitch-default -Wswitch-enum -Wundef -Winline -Wunused -Wnon-virtual-dtor -pthread")
set(CXX_COVERAGE_COMPILE_FLAGS "-pedantic -Wall -Wextra -Wold-style-cast -Woverloaded-virtual -Wfloat-equal -Wwrite-strings -Wpointer-arith -Wcast-qual -Wcast-align -Wshadow -Weffc++ -Wredundant-decls -Wdouble-promotion -Winit-self -Wswitch-default -Wswitch-enum -Wundef -Winline -Wunused -Wnon-virtual-dtor -Wno-conversion -pthread")
set(CMAKE_CXX_FLAGS_DEBUG "${CXX_COVERAGE_COMPILE_FLAGS} -DDebug -g -pg")
set(CMAKE_CXX_FLAGS_RELEASE "${CXX_COVERAGE_COMPILE_FLAGS} -O3")

File diff suppressed because it is too large Load Diff

View File

@ -10,27 +10,86 @@
#include <string>
#include <vector>
/// \brief Bat-packs the input dynamically
///////////////////////////////////////////////////////////////////////////////
// packing //
///////////////////////////////////////////////////////////////////////////////
std::vector<unsigned char> pack(const std::vector<std::uint16_t> &);
/// \brief Packs std::uint16_t of n bits into unsigned char
std::vector<unsigned char>
pack_n(const std::vector<std::uint16_t>::const_iterator,
const std::vector<std::uint16_t>::const_iterator, const int);
std::vector<unsigned char> pack_9(std::vector<std::uint16_t>::const_iterator,
std::vector<std::uint16_t>::const_iterator);
/// \brief Specialization of \ref pack_n for 16bits
std::vector<unsigned char>
pack_16(const std::vector<std::uint16_t>::const_iterator,
const std::vector<std::uint16_t>::const_iterator);
std::vector<unsigned char> pack_10(std::vector<std::uint16_t>::const_iterator,
std::vector<std::uint16_t>::const_iterator,
std::vector<unsigned char> &);
std::vector<unsigned char> pack_11(std::vector<std::uint16_t>::const_iterator,
std::vector<std::uint16_t>::const_iterator,
std::vector<unsigned char> &);
std::vector<unsigned char> pack_12(std::vector<std::uint16_t>::const_iterator,
std::vector<std::uint16_t>::const_iterator,
std::vector<unsigned char> &);
std::vector<unsigned char> pack_13(std::vector<std::uint16_t>::const_iterator,
std::vector<std::uint16_t>::const_iterator,
std::vector<unsigned char> &);
std::vector<unsigned char> pack_14(std::vector<std::uint16_t>::const_iterator,
std::vector<std::uint16_t>::const_iterator,
std::vector<unsigned char> &);
std::vector<unsigned char> pack_15(std::vector<std::uint16_t>::const_iterator,
std::vector<std::uint16_t>::const_iterator,
std::vector<unsigned char> &);
std::vector<unsigned char> pack_16(std::vector<std::uint16_t>::const_iterator,
std::vector<std::uint16_t>::const_iterator,
std::vector<unsigned char> &);
///////////////////////////////////////////////////////////////////////////////
// unpack //
///////////////////////////////////////////////////////////////////////////////
std::vector<std::uint16_t> unpack(std::basic_string<unsigned char> &&);
std::vector<std::uint16_t>
unpack_n(const std::basic_string<unsigned char>::const_iterator,
const std::basic_string<unsigned char>::const_iterator, const int t_n);
unpack_9(std::basic_string<unsigned char>::const_iterator,
std::basic_string<unsigned char>::const_iterator);
std::vector<std::uint16_t>
unpack_16(const std::basic_string<unsigned char>::const_iterator,
const std::basic_string<unsigned char>::const_iterator);
unpack_10(std::basic_string<unsigned char>::const_iterator,
std::basic_string<unsigned char>::const_iterator,
std::vector<std::uint16_t> &);
std::vector<std::uint16_t>
unpack_11(std::basic_string<unsigned char>::const_iterator,
std::basic_string<unsigned char>::const_iterator,
std::vector<std::uint16_t> &);
std::vector<std::uint16_t>
unpack_12(std::basic_string<unsigned char>::const_iterator,
std::basic_string<unsigned char>::const_iterator,
std::vector<std::uint16_t> &);
std::vector<std::uint16_t>
unpack_13(std::basic_string<unsigned char>::const_iterator,
std::basic_string<unsigned char>::const_iterator,
std::vector<std::uint16_t> &);
std::vector<std::uint16_t>
unpack_14(std::basic_string<unsigned char>::const_iterator,
std::basic_string<unsigned char>::const_iterator,
std::vector<std::uint16_t> &);
std::vector<std::uint16_t>
unpack_15(std::basic_string<unsigned char>::const_iterator,
std::basic_string<unsigned char>::const_iterator,
std::vector<std::uint16_t> &);
std::vector<std::uint16_t>
unpack_16(std::basic_string<unsigned char>::const_iterator,
std::basic_string<unsigned char>::const_iterator,
std::vector<std::uint16_t> &);
#endif /* LZW_SRC_BITPACK_H_ */

View File

@ -15,10 +15,10 @@ int ipow(int, int);
/// \brief Recherche ou ajout de chaine dans le dictionnaire
std::pair<bool, std::uint16_t>
dico(std::map<std::pair<std::uint16_t, std::uint8_t>, std::uint16_t> &,
const std::uint16_t, const std::uint8_t);
std::uint16_t, std::uint8_t);
std::basic_string<unsigned char>
dico_uncompress(std::map<std::uint16_t, std::basic_string<unsigned char>> &,
const std::uint16_t, const std::uint16_t);
std::uint16_t, std::uint16_t);
#endif /* LZW_SRC_COMMON_H_ */

View File

@ -74,12 +74,7 @@ void compress(const std::string &t_in_file, const char *t_out_file) {
assert(input_file);
FILE *const out = (t_out_file != nullptr) ? fopen(t_out_file, "wb")
: fopen("output.lzw", "wb");
if (out == nullptr) {
std::cerr << "Error at " << __FILE__ << ":" << __LINE__ - 4
<< ": could not open output file. Aborting...\n";
std::fclose(input_file);
exit(1);
}
assert(out);
std::fseek(input_file, 0L, SEEK_END);
const auto file_size = static_cast<size_t>(ftell(input_file));

View File

@ -7,9 +7,9 @@
#define LZW_SRC_COMPRESS_H_
#include "common.hh"
#include <vector>
#include <iostream>
#include <thread>
#include <vector>
/// \brief Compression d'une chaine de caractères
std::vector<std::vector<std::uint16_t>>

View File

@ -6,8 +6,8 @@
#ifndef LZW_SRC_IO_H_
#define LZW_SRC_IO_H_
#include <cstdio>
#include <cstdint>
#include <cstdio>
#include <iostream>
#include <vector>
@ -19,17 +19,17 @@
*
* Un chunk se compose ainsi :
* nb_char_chunk : nombre de caractères du chunk (2B)
* text* : caractères de taille char_size (ceil((char_size * nb_char_chunk) / 8))
* text* : caractères de taille char_size (ceil((char_size * nb_char_chunk) /
* 8))
*
* Si le dernier caractère ne termine pas le dernier octet du chunk, les
* derniers bits sont mit à zéro
*/
/// \brief Écrit dans le fichier le texte compressé
void write_file(FILE *const, const std::vector<std::vector<std::uint16_t>> &);
void write_file(FILE *, const std::vector<std::vector<std::uint16_t>> &);
/// \brief Écrit un chunk dans le fichier de sortie
void write_chunk(FILE *const, const std::vector<std::uint16_t> &);
void write_chunk(FILE *, const std::vector<std::uint16_t> &);
#endif /* LZW_SRC_IO_H_ */

View File

@ -5,9 +5,8 @@
#include <string>
#include <vector>
std::basic_string<unsigned char>
lzw_uncompress(std::vector<std::uint16_t> &&);
std::basic_string<unsigned char> lzw_uncompress(std::vector<std::uint16_t> &&);
void uncompress(const std::string &, const char*);
void uncompress(const std::string &, const char *);
#endif /* LZW_SRC_UNCOMPRESS_H_ */