Added missing function as for #10
This commit is contained in:
parent
c4ce35e1ce
commit
1d37307b9e
|
@ -18,3 +18,5 @@ Thumbs.db
|
|||
# Files that might appear on external disks
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
|
||||
.clang-format
|
||||
|
|
|
@ -15,7 +15,7 @@ void trigger_error(int code, bool is_critical, ...) {
|
|||
va_list args;
|
||||
va_start(args, is_critical);
|
||||
|
||||
fprintf(stderr, "%s %d: ",
|
||||
fprintf(stderr, "%s - %d: ",
|
||||
parse_error_level(is_critical),
|
||||
code);
|
||||
|
||||
|
|
33
src/jpeg.c
33
src/jpeg.c
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "jpeg.h"
|
||||
#include "utils.h"
|
||||
#include "error.h"
|
||||
|
||||
//TODO Error handling
|
||||
|
||||
|
@ -231,3 +232,35 @@ unsigned char* cclt_jpeg_decompress(char* fileName, cclt_jpeg_parameters* pars)
|
|||
|
||||
return temp;
|
||||
}
|
||||
|
||||
void jcopy_markers_execute (j_decompress_ptr srcinfo, j_compress_ptr dstinfo) {
|
||||
jpeg_saved_marker_ptr marker;
|
||||
|
||||
/* In the current implementation, we don't actually need to examine the
|
||||
* option flag here; we just copy everything that got saved.
|
||||
* But to avoid confusion, we do not output JFIF and Adobe APP14 markers
|
||||
* if the encoder library already wrote one.
|
||||
*/
|
||||
for (marker = srcinfo->marker_list; marker != NULL; marker = marker->next) {
|
||||
if (dstinfo->write_JFIF_header &&
|
||||
marker->marker == JPEG_APP0 &&
|
||||
marker->data_length >= 5 &&
|
||||
GETJOCTET(marker->data[0]) == 0x4A &&
|
||||
GETJOCTET(marker->data[1]) == 0x46 &&
|
||||
GETJOCTET(marker->data[2]) == 0x49 &&
|
||||
GETJOCTET(marker->data[3]) == 0x46 &&
|
||||
GETJOCTET(marker->data[4]) == 0)
|
||||
continue; /* reject duplicate JFIF */
|
||||
if (dstinfo->write_Adobe_marker &&
|
||||
marker->marker == JPEG_APP0+14 &&
|
||||
marker->data_length >= 5 &&
|
||||
GETJOCTET(marker->data[0]) == 0x41 &&
|
||||
GETJOCTET(marker->data[1]) == 0x64 &&
|
||||
GETJOCTET(marker->data[2]) == 0x6F &&
|
||||
GETJOCTET(marker->data[3]) == 0x62 &&
|
||||
GETJOCTET(marker->data[4]) == 0x65)
|
||||
continue; /* reject duplicate Adobe */
|
||||
jpeg_write_marker(dstinfo, marker->marker,
|
||||
marker->data, marker->data_length);
|
||||
}
|
||||
}
|
||||
|
|
16
src/main.c
16
src/main.c
|
@ -24,15 +24,13 @@
|
|||
-S keep folder structure
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//TODO If the output is INSIDE the folder we are passing as input, ignore it or we're gonna go in a infinite loop
|
||||
// TODO If the output is INSIDE the folder we are passing as input, ignore it or
|
||||
// we're gonna go in a infinite loop
|
||||
// TODO Trigger a warning if you are overwriting files
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
errno = 0;
|
||||
off_t i_t_size = 0, o_t_size = 0;
|
||||
|
||||
// Parse arguments
|
||||
cclt_parameters pars = parse_arguments(argc, argv);
|
||||
|
||||
|
@ -44,12 +42,10 @@ int main (int argc, char *argv[]) {
|
|||
diff = clock() - start;
|
||||
long msec = diff * 1000 / CLOCKS_PER_SEC;
|
||||
|
||||
fprintf(stdout, "-------------------------------\nCompression completed in %lum%lus%lums\n%s -> %s [%.2f%% | %s]\n",
|
||||
msec / 1000 / 60,
|
||||
msec / 1000 % 60,
|
||||
msec % 1000,
|
||||
get_human_size((long) i_t_size),
|
||||
get_human_size((long) o_t_size),
|
||||
fprintf(stdout, "-------------------------------\nCompression completed in "
|
||||
"%lum%lus%lums\n%s -> %s [%.2f%% | %s]\n",
|
||||
msec / 1000 / 60, msec / 1000 % 60, msec % 1000,
|
||||
get_human_size((long)i_t_size), get_human_size((long)o_t_size),
|
||||
((float)o_t_size - i_t_size) * 100 / i_t_size,
|
||||
get_human_size(((long)o_t_size - i_t_size)));
|
||||
|
||||
|
|
Loading…
Reference in New Issue