Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix allocator, @sandsmark #1

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,22 @@ SAVE_ASM=0
WINDOWS=0

# VARIABLES
PNAME=jpeg2png
CFLAGS+=-std=c11 -pedantic
CFLAGS+=-msse2 -mfpmath=sse
CFLAGS+=-g
WARN_FLAGS+=-Wall -Wextra -Winline -Wshadow
NO_WARN_FLAGS+=-w
SRCS=src
RM=rm -f
ifeq ($(CC),)
CC=$(HOST)gcc
endif
ifeq ($(WINDRES),)
WINDRES=$(HOST)windres
endif
LIBS+=-ljpeg -lpng -lm -lz
OBJS+=jpeg2png.o utils.o jpeg.o png.o box.o compute.o logger.o progressbar.o fp_exceptions.o gopt/gopt.o ooura/dct.o
OBJS+=$(SRCS)/jpeg2png.o $(SRCS)/utils.o $(SRCS)/jpeg.o $(SRCS)/png.o $(SRCS)/box.o $(SRCS)/compute.o $(SRCS)/logger.o $(SRCS)/progressbar.o $(SRCS)/fp_exceptions.o $(SRCS)/gopt/gopt.o $(SRCS)/ooura/dct.o
HOST=
EXE=

Expand Down Expand Up @@ -68,6 +71,8 @@ EXE=.exe
LDFLAGS+=-static -s
CFLAGS+=-mstackrealign # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48659
RES+=icon.rc.o
else
CFLAGS+=-D_POSIX_C_SOURCE=200112
endif

ifeq ($(SAVE_ASM),1)
Expand All @@ -81,21 +86,22 @@ LDFLAGS+=$(BFLAGS)
.PHONY: clean all install uninstall
all: jpeg2png$(EXE)

jpeg2png$(EXE): $(OBJS) $(RES) Makefile
$(PNAME)$(EXE): $(OBJS) $(RES)
$(CC) $(OBJS) $(RES) -o $@ $(LDFLAGS) $(LIBS)

-include $(OBJS:.o=.d)

gopt/gopt.o: gopt/gopt.c gopt/gopt.h Makefile
$(SRCS)/gopt/gopt.o: $(SRCS)/gopt/gopt.c $(SRCS)/gopt/gopt.h
$(CC) $< -c -o $@ $(CFLAGS) $(NO_WARN_FLAGS)

%.o: %.c Makefile
$(SRCS)/%.o: $(SRCS)/%.c
$(CC) -MP -MMD $< -c -o $@ $(CFLAGS) $(WARN_FLAGS)

%.rc.o: %.rc Makefile
$(WINDRES) $< $@

clean:
$(RM) $(OBJS) $(PNAME)$(EXE)
git clean -Xf

install: all
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ This is the source for the DCT deviations model. Uniform distribution for the er

## Links

[qjpegrest](http://viric.name/soft/qjpegrest/) is a tool that lets you try many different JPEG restoration methods (TV based, band-pass based and Huber MRF based). I learned from the code. See notes/qjpegrest.txt for installation help.
* [qjpegrest](http://viric.name/soft/qjpegrest/) is a tool that lets you try many different JPEG restoration methods (TV based, band-pass based and Huber MRF based). I learned from the code. See notes/qjpegrest.txt for installation help.
* [jpeg-quantsmooth](https://github.com/ilyakurdyukov/jpeg-quantsmooth) is program tries to recreate lost precision of DCT coefficients based on quantization table from jpeg image.

## License

Expand Down
Empty file modified icon.ico
100755 → 100644
Empty file.
62 changes: 62 additions & 0 deletions man/man1/jpeg2png.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.TH "Jpeg2Png User Manual" 1 "1 Jul 2015" "Jpeg2Png documentation"

.SH NAME
jpeg2png

.SH DESCRIPTION
Silky smooth JPEG decoding

.SH SYNOPSIS
jpeg2png picture.jpg ... [-o picture.png] ... [flags...]

.SH OPTIONS
.TP
-o|--output picture.png
picture.png is the file name of the output filethe output file will be overwritten if this flag is used must be specified either zero times or once for every input file default value: original file name with the extension .png
.TP
-f|--force
overwrite output files even when not given explicit file names
.TP
-w|--second-order-weight weight[,weight_cb,weight_cr]
weight is a floating point number for TGV weight alpha_1 higher values give smoother transitions with less staircasing a value of 1.0 means equivalent weight to the first order weight a value of 0.0 means plain Total Variation, and gives a speed boost weights for the chroma components always default to 0. default value: 0.3
.TP
-p|--probability-weight pweight[,pweight_cb,pweight_cr]
pweight is a floating point number for DCT coefficient distance weight higher values make the result more similar to the source JPEG a value of 1.0 means about equivalent weight to the first order weight a value of 0.0 means to ignore this and gives a speed boost weights for the chroma components default to the luma weight, default value: 0.001
.TP
-i|--iterations iterations[,iterations_cb,iterations_cr]
iterations is an integer for the number of optimization steps higher values give better results but take more time iterations for the chroma components default to the luma iterations, default value: 50
.TP
-q|--quiet
don't show the progress bar
.TP
-s|--separate-components
separately optimize components this is faster and makes multithreading more effective however the edges of different components can be different
.TP
-t|--threads threads
threads is a positive integer for the maximum number of threads used equivalent to setting the environment variable OMP_NUM_THREADS, default: number of CPUs
.TP
-1|--16-bits-png
output PNG with 16 bits color depth instead of the usual 8 bits you should use a high number of iterations when using this option
.TP
-c|--csv_log csv_log
csv_log is a file name for the optimization log, default: none
.TP
-h|--help
display this help text and exit
.TP
-V|--version
display version information and exit

.SH EXAMPLE
jpeg2png -o sample.png sample.jpg

.SH COPYRIGHT
Copyright 2015 victorvde.
All rights reserved.

.SH SEE ALSO
imagemagick(1)

.SH CONTACTS
Website: https://github.com/victorvde/jpeg2png
Autors: victorvde <[email protected]>
File renamed without changes.
File renamed without changes.
5 changes: 4 additions & 1 deletion compute.c → src/compute.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@

#include "ooura/dct.h"

static_assert(FLT_EVAL_METHOD == 0, "to preserve identical output please disable excess precision");
#if defined __USE_ISOC11
static_assert(FLT_EVAL_METHOD == 0, "to preserve identical output please disable excess precision");
#endif

#ifdef PRAGMA_FP_CONTRACT
#pragma STDC FP_CONTRACT OFF
#endif
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 4 additions & 1 deletion utils.h → src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ static inline void *alloc_simd(size_t n) {
#if defined(_WIN32)
void *p = _aligned_malloc(n, 16);
#else
void *p = aligned_alloc(16, n);
void *p = NULL;
if (posix_memalign(&p, 16, n) != 0) {
die("aligned allocation error");
}
#endif
if(!p) { die("allocation error"); }
ASSUME_ALIGNED(p);
Expand Down