mirror of
https://github.com/webmproject/libwebp.git
synced 2024-11-20 04:18:26 +01:00
Merge "remove WEBP_EXPERIMENTAL_FEATURES"
This commit is contained in:
commit
f69dcd692a
@ -123,7 +123,6 @@ enc_srcs := \
|
|||||||
src/enc/backward_references_enc.c \
|
src/enc/backward_references_enc.c \
|
||||||
src/enc/config_enc.c \
|
src/enc/config_enc.c \
|
||||||
src/enc/cost_enc.c \
|
src/enc/cost_enc.c \
|
||||||
src/enc/delta_palettization_enc.c \
|
|
||||||
src/enc/filter_enc.c \
|
src/enc/filter_enc.c \
|
||||||
src/enc/frame_enc.c \
|
src/enc/frame_enc.c \
|
||||||
src/enc/histogram_enc.c \
|
src/enc/histogram_enc.c \
|
||||||
|
@ -11,7 +11,6 @@ option(WEBP_BUILD_IMG2WEBP "Build the img2webp animation tool." OFF)
|
|||||||
option(WEBP_BUILD_WEBPINFO "Build the webpinfo command line tool." OFF)
|
option(WEBP_BUILD_WEBPINFO "Build the webpinfo command line tool." OFF)
|
||||||
option(WEBP_BUILD_WEBP_JS "Emscripten build of webp.js." OFF)
|
option(WEBP_BUILD_WEBP_JS "Emscripten build of webp.js." OFF)
|
||||||
option(WEBP_ENABLE_NEAR_LOSSLESS "Enable near-lossless encoding" ON)
|
option(WEBP_ENABLE_NEAR_LOSSLESS "Enable near-lossless encoding" ON)
|
||||||
option(WEBP_EXPERIMENTAL_FEATURES "Build with experimental features." OFF)
|
|
||||||
option(WEBP_ENABLE_SWAP_16BIT_CSP "Enable byte swap for 16 bit colorspaces." OFF)
|
option(WEBP_ENABLE_SWAP_16BIT_CSP "Enable byte swap for 16 bit colorspaces." OFF)
|
||||||
|
|
||||||
if(WEBP_BUILD_WEBP_JS)
|
if(WEBP_BUILD_WEBP_JS)
|
||||||
|
@ -287,7 +287,6 @@ ENC_OBJS = \
|
|||||||
$(DIROBJ)\enc\backward_references_enc.obj \
|
$(DIROBJ)\enc\backward_references_enc.obj \
|
||||||
$(DIROBJ)\enc\config_enc.obj \
|
$(DIROBJ)\enc\config_enc.obj \
|
||||||
$(DIROBJ)\enc\cost_enc.obj \
|
$(DIROBJ)\enc\cost_enc.obj \
|
||||||
$(DIROBJ)\enc\delta_palettization_enc.obj \
|
|
||||||
$(DIROBJ)\enc\filter_enc.obj \
|
$(DIROBJ)\enc\filter_enc.obj \
|
||||||
$(DIROBJ)\enc\frame_enc.obj \
|
$(DIROBJ)\enc\frame_enc.obj \
|
||||||
$(DIROBJ)\enc\histogram_enc.obj \
|
$(DIROBJ)\enc\histogram_enc.obj \
|
||||||
@ -399,11 +398,6 @@ $(EX_UTIL_OBJS) $(IMAGEIO_UTIL_OBJS): $(OUTPUT_DIRS)
|
|||||||
$(IMAGEIO_DEC_OBJS) $(IMAGEIO_ENC_OBJS) $(EXTRAS_OBJS): $(OUTPUT_DIRS)
|
$(IMAGEIO_DEC_OBJS) $(IMAGEIO_ENC_OBJS) $(EXTRAS_OBJS): $(OUTPUT_DIRS)
|
||||||
!ENDIF # ARCH == ARM
|
!ENDIF # ARCH == ARM
|
||||||
|
|
||||||
experimental:
|
|
||||||
$(MAKE) /f Makefile.vc \
|
|
||||||
CFG=$(CFG) \
|
|
||||||
CFLAGS="$(CFLAGS) /DWEBP_EXPERIMENTAL_FEATURES" /$(MAKEFLAGS)
|
|
||||||
|
|
||||||
$(LIBWEBPDECODER): $(LIBWEBPDECODER_OBJS)
|
$(LIBWEBPDECODER): $(LIBWEBPDECODER_OBJS)
|
||||||
$(LIBWEBP): $(LIBWEBP_OBJS)
|
$(LIBWEBP): $(LIBWEBP_OBJS)
|
||||||
$(LIBWEBPMUX): $(LIBWEBPMUX_OBJS)
|
$(LIBWEBPMUX): $(LIBWEBPMUX_OBJS)
|
||||||
|
@ -198,7 +198,6 @@ model {
|
|||||||
include "backward_references_enc.c"
|
include "backward_references_enc.c"
|
||||||
include "config_enc.c"
|
include "config_enc.c"
|
||||||
include "cost_enc.c"
|
include "cost_enc.c"
|
||||||
include "delta_palettization_enc.c"
|
|
||||||
include "filter_enc.c"
|
include "filter_enc.c"
|
||||||
include "frame_enc.c"
|
include "frame_enc.c"
|
||||||
include "histogram_enc.c"
|
include "histogram_enc.c"
|
||||||
|
@ -103,9 +103,6 @@
|
|||||||
/* Version number of package */
|
/* Version number of package */
|
||||||
#cmakedefine VERSION "@VERSION@"
|
#cmakedefine VERSION "@VERSION@"
|
||||||
|
|
||||||
/* Enable experimental code */
|
|
||||||
#cmakedefine WEBP_EXPERIMENTAL_FEATURES 1
|
|
||||||
|
|
||||||
/* Set to 1 if AVX2 is supported */
|
/* Set to 1 if AVX2 is supported */
|
||||||
#cmakedefine WEBP_HAVE_AVX2 1
|
#cmakedefine WEBP_HAVE_AVX2 1
|
||||||
|
|
||||||
|
13
configure.ac
13
configure.ac
@ -676,19 +676,6 @@ fi
|
|||||||
AC_MSG_RESULT(${enable_swap_16bit_csp-no})
|
AC_MSG_RESULT(${enable_swap_16bit_csp-no})
|
||||||
AC_SUBST(USE_SWAP_16BIT_CSP)
|
AC_SUBST(USE_SWAP_16BIT_CSP)
|
||||||
|
|
||||||
dnl === If --enable-experimental is defined, add -DWEBP_EXPERIMENTAL_FEATURES
|
|
||||||
|
|
||||||
USE_EXPERIMENTAL_CODE=""
|
|
||||||
AC_MSG_CHECKING(if --enable-experimental option is specified)
|
|
||||||
AC_ARG_ENABLE([experimental], AS_HELP_STRING([--enable-experimental],
|
|
||||||
[Activate experimental features]))
|
|
||||||
if test "$enable_experimental" = "yes"; then
|
|
||||||
AC_DEFINE(WEBP_EXPERIMENTAL_FEATURES, [1], [Enable experimental code])
|
|
||||||
USE_EXPERIMENTAL_CODE="-DWEBP_EXPERIMENTAL_FEATURES"
|
|
||||||
fi
|
|
||||||
AC_MSG_RESULT(${enable_experimental-no})
|
|
||||||
AC_SUBST(USE_EXPERIMENTAL_CODE)
|
|
||||||
|
|
||||||
dnl === If --disable-near-lossless is defined, add -DWEBP_NEAR_LOSSLESS=0
|
dnl === If --disable-near-lossless is defined, add -DWEBP_NEAR_LOSSLESS=0
|
||||||
|
|
||||||
AC_DEFINE(WEBP_NEAR_LOSSLESS, [1], [Enable near lossless encoding])
|
AC_DEFINE(WEBP_NEAR_LOSSLESS, [1], [Enable near lossless encoding])
|
||||||
|
@ -26,7 +26,7 @@ libexample_util_la_SOURCES = example_util.c example_util.h
|
|||||||
libexample_util_la_LIBADD = ../src/libwebp.la
|
libexample_util_la_LIBADD = ../src/libwebp.la
|
||||||
|
|
||||||
anim_diff_SOURCES = anim_diff.c anim_util.c anim_util.h
|
anim_diff_SOURCES = anim_diff.c anim_util.c anim_util.h
|
||||||
anim_diff_CPPFLAGS = $(AM_CPPFLAGS) $(USE_EXPERIMENTAL_CODE) $(GIF_INCLUDES)
|
anim_diff_CPPFLAGS = $(AM_CPPFLAGS) $(GIF_INCLUDES)
|
||||||
anim_diff_LDADD =
|
anim_diff_LDADD =
|
||||||
anim_diff_LDADD += ../src/demux/libwebpdemux.la
|
anim_diff_LDADD += ../src/demux/libwebpdemux.la
|
||||||
anim_diff_LDADD += libexample_util.la
|
anim_diff_LDADD += libexample_util.la
|
||||||
@ -34,7 +34,7 @@ anim_diff_LDADD += ../imageio/libimageio_util.la
|
|||||||
anim_diff_LDADD += $(GIF_LIBS) -lm
|
anim_diff_LDADD += $(GIF_LIBS) -lm
|
||||||
|
|
||||||
anim_dump_SOURCES = anim_dump.c anim_util.c anim_util.h
|
anim_dump_SOURCES = anim_dump.c anim_util.c anim_util.h
|
||||||
anim_dump_CPPFLAGS = $(AM_CPPFLAGS) $(USE_EXPERIMENTAL_CODE) $(PNG_INCLUDES)
|
anim_dump_CPPFLAGS = $(AM_CPPFLAGS) $(PNG_INCLUDES)
|
||||||
anim_dump_CPPFLAGS += $(GIF_INCLUDES)
|
anim_dump_CPPFLAGS += $(GIF_INCLUDES)
|
||||||
anim_dump_LDADD =
|
anim_dump_LDADD =
|
||||||
anim_dump_LDADD += ../src/demux/libwebpdemux.la
|
anim_dump_LDADD += ../src/demux/libwebpdemux.la
|
||||||
@ -44,7 +44,7 @@ anim_dump_LDADD += ../imageio/libimageenc.la
|
|||||||
anim_dump_LDADD += $(PNG_LIBS) $(GIF_LIBS) $(TIFF_LIBS) -lm
|
anim_dump_LDADD += $(PNG_LIBS) $(GIF_LIBS) $(TIFF_LIBS) -lm
|
||||||
|
|
||||||
cwebp_SOURCES = cwebp.c stopwatch.h
|
cwebp_SOURCES = cwebp.c stopwatch.h
|
||||||
cwebp_CPPFLAGS = $(AM_CPPFLAGS) $(USE_EXPERIMENTAL_CODE)
|
cwebp_CPPFLAGS = $(AM_CPPFLAGS)
|
||||||
cwebp_LDADD =
|
cwebp_LDADD =
|
||||||
cwebp_LDADD += libexample_util.la
|
cwebp_LDADD += libexample_util.la
|
||||||
cwebp_LDADD += ../imageio/libimageio_util.la
|
cwebp_LDADD += ../imageio/libimageio_util.la
|
||||||
@ -53,7 +53,7 @@ cwebp_LDADD += ../src/libwebp.la
|
|||||||
cwebp_LDADD += $(JPEG_LIBS) $(PNG_LIBS) $(TIFF_LIBS)
|
cwebp_LDADD += $(JPEG_LIBS) $(PNG_LIBS) $(TIFF_LIBS)
|
||||||
|
|
||||||
dwebp_SOURCES = dwebp.c stopwatch.h
|
dwebp_SOURCES = dwebp.c stopwatch.h
|
||||||
dwebp_CPPFLAGS = $(AM_CPPFLAGS) $(USE_EXPERIMENTAL_CODE)
|
dwebp_CPPFLAGS = $(AM_CPPFLAGS)
|
||||||
dwebp_CPPFLAGS += $(JPEG_INCLUDES) $(PNG_INCLUDES)
|
dwebp_CPPFLAGS += $(JPEG_INCLUDES) $(PNG_INCLUDES)
|
||||||
dwebp_LDADD =
|
dwebp_LDADD =
|
||||||
dwebp_LDADD += libexample_util.la
|
dwebp_LDADD += libexample_util.la
|
||||||
@ -64,7 +64,7 @@ dwebp_LDADD += ../src/libwebp.la
|
|||||||
dwebp_LDADD +=$(PNG_LIBS) $(JPEG_LIBS)
|
dwebp_LDADD +=$(PNG_LIBS) $(JPEG_LIBS)
|
||||||
|
|
||||||
gif2webp_SOURCES = gif2webp.c gifdec.c gifdec.h
|
gif2webp_SOURCES = gif2webp.c gifdec.c gifdec.h
|
||||||
gif2webp_CPPFLAGS = $(AM_CPPFLAGS) $(USE_EXPERIMENTAL_CODE) $(GIF_INCLUDES)
|
gif2webp_CPPFLAGS = $(AM_CPPFLAGS) $(GIF_INCLUDES)
|
||||||
gif2webp_LDADD =
|
gif2webp_LDADD =
|
||||||
gif2webp_LDADD += libexample_util.la
|
gif2webp_LDADD += libexample_util.la
|
||||||
gif2webp_LDADD += ../imageio/libimageio_util.la
|
gif2webp_LDADD += ../imageio/libimageio_util.la
|
||||||
@ -73,7 +73,7 @@ gif2webp_LDADD += ../src/libwebp.la
|
|||||||
gif2webp_LDADD += $(GIF_LIBS)
|
gif2webp_LDADD += $(GIF_LIBS)
|
||||||
|
|
||||||
vwebp_SOURCES = vwebp.c
|
vwebp_SOURCES = vwebp.c
|
||||||
vwebp_CPPFLAGS = $(AM_CPPFLAGS) $(USE_EXPERIMENTAL_CODE) $(GL_INCLUDES)
|
vwebp_CPPFLAGS = $(AM_CPPFLAGS) $(GL_INCLUDES)
|
||||||
vwebp_LDADD =
|
vwebp_LDADD =
|
||||||
vwebp_LDADD += libexample_util.la
|
vwebp_LDADD += libexample_util.la
|
||||||
vwebp_LDADD += ../imageio/libimageio_util.la
|
vwebp_LDADD += ../imageio/libimageio_util.la
|
||||||
@ -81,7 +81,7 @@ vwebp_LDADD += ../src/demux/libwebpdemux.la
|
|||||||
vwebp_LDADD += $(GL_LIBS)
|
vwebp_LDADD += $(GL_LIBS)
|
||||||
|
|
||||||
webpmux_SOURCES = webpmux.c
|
webpmux_SOURCES = webpmux.c
|
||||||
webpmux_CPPFLAGS = $(AM_CPPFLAGS) $(USE_EXPERIMENTAL_CODE)
|
webpmux_CPPFLAGS = $(AM_CPPFLAGS)
|
||||||
webpmux_LDADD =
|
webpmux_LDADD =
|
||||||
webpmux_LDADD += libexample_util.la
|
webpmux_LDADD += libexample_util.la
|
||||||
webpmux_LDADD += ../imageio/libimageio_util.la
|
webpmux_LDADD += ../imageio/libimageio_util.la
|
||||||
@ -89,7 +89,7 @@ webpmux_LDADD += ../src/mux/libwebpmux.la
|
|||||||
webpmux_LDADD += ../src/libwebp.la
|
webpmux_LDADD += ../src/libwebp.la
|
||||||
|
|
||||||
img2webp_SOURCES = img2webp.c
|
img2webp_SOURCES = img2webp.c
|
||||||
img2webp_CPPFLAGS = $(AM_CPPFLAGS) $(USE_EXPERIMENTAL_CODE)
|
img2webp_CPPFLAGS = $(AM_CPPFLAGS)
|
||||||
img2webp_LDADD =
|
img2webp_LDADD =
|
||||||
img2webp_LDADD += libexample_util.la
|
img2webp_LDADD += libexample_util.la
|
||||||
img2webp_LDADD += ../imageio/libimageio_util.la
|
img2webp_LDADD += ../imageio/libimageio_util.la
|
||||||
@ -99,7 +99,7 @@ img2webp_LDADD += ../src/libwebp.la
|
|||||||
img2webp_LDADD += $(PNG_LIBS) $(JPEG_LIBS) $(TIFF_LIBS)
|
img2webp_LDADD += $(PNG_LIBS) $(JPEG_LIBS) $(TIFF_LIBS)
|
||||||
|
|
||||||
webpinfo_SOURCES = webpinfo.c
|
webpinfo_SOURCES = webpinfo.c
|
||||||
webpinfo_CPPFLAGS = $(AM_CPPFLAGS) $(USE_EXPERIMENTAL_CODE)
|
webpinfo_CPPFLAGS = $(AM_CPPFLAGS)
|
||||||
webpinfo_LDADD =
|
webpinfo_LDADD =
|
||||||
webpinfo_LDADD += libexample_util.la
|
webpinfo_LDADD += libexample_util.la
|
||||||
webpinfo_LDADD += ../imageio/libimageio_util.la
|
webpinfo_LDADD += ../imageio/libimageio_util.la
|
||||||
|
@ -582,9 +582,6 @@ static void HelpLong(void) {
|
|||||||
printf(" -near_lossless <int> ... use near-lossless image\n"
|
printf(" -near_lossless <int> ... use near-lossless image\n"
|
||||||
" preprocessing (0..100=off), "
|
" preprocessing (0..100=off), "
|
||||||
"default=100\n");
|
"default=100\n");
|
||||||
#ifdef WEBP_EXPERIMENTAL_FEATURES /* not documented yet */
|
|
||||||
printf(" -delta_palette ......... use delta palettization\n");
|
|
||||||
#endif // WEBP_EXPERIMENTAL_FEATURES
|
|
||||||
printf(" -hint <string> ......... specify image characteristics hint,\n");
|
printf(" -hint <string> ......... specify image characteristics hint,\n");
|
||||||
printf(" one of: photo, picture or graph\n");
|
printf(" one of: photo, picture or graph\n");
|
||||||
|
|
||||||
@ -753,11 +750,6 @@ int main(int argc, const char *argv[]) {
|
|||||||
} else if (!strcmp(argv[c], "-near_lossless") && c < argc - 1) {
|
} else if (!strcmp(argv[c], "-near_lossless") && c < argc - 1) {
|
||||||
config.near_lossless = ExUtilGetInt(argv[++c], 0, &parse_error);
|
config.near_lossless = ExUtilGetInt(argv[++c], 0, &parse_error);
|
||||||
config.lossless = 1; // use near-lossless only with lossless
|
config.lossless = 1; // use near-lossless only with lossless
|
||||||
#ifdef WEBP_EXPERIMENTAL_FEATURES
|
|
||||||
} else if (!strcmp(argv[c], "-delta_palette")) {
|
|
||||||
config.use_delta_palette = 1;
|
|
||||||
config.lossless = 1; // delta-palette is for lossless only
|
|
||||||
#endif // WEBP_EXPERIMENTAL_FEATURES
|
|
||||||
} else if (!strcmp(argv[c], "-hint") && c < argc - 1) {
|
} else if (!strcmp(argv[c], "-hint") && c < argc - 1) {
|
||||||
++c;
|
++c;
|
||||||
if (!strcmp(argv[c], "photo")) {
|
if (!strcmp(argv[c], "photo")) {
|
||||||
|
@ -27,7 +27,7 @@ get_disto_LDADD += ../src/libwebp.la
|
|||||||
get_disto_LDADD += $(PNG_LIBS) $(JPEG_LIBS) $(TIFF_LIBS)
|
get_disto_LDADD += $(PNG_LIBS) $(JPEG_LIBS) $(TIFF_LIBS)
|
||||||
|
|
||||||
webp_quality_SOURCES = webp_quality.c
|
webp_quality_SOURCES = webp_quality.c
|
||||||
webp_quality_CPPFLAGS = $(AM_CPPFLAGS) $(USE_EXPERIMENTAL_CODE)
|
webp_quality_CPPFLAGS = $(AM_CPPFLAGS)
|
||||||
webp_quality_LDADD =
|
webp_quality_LDADD =
|
||||||
webp_quality_LDADD += ../imageio/libimageio_util.la
|
webp_quality_LDADD += ../imageio/libimageio_util.la
|
||||||
webp_quality_LDADD += libwebpextras.la
|
webp_quality_LDADD += libwebpextras.la
|
||||||
|
@ -21,9 +21,9 @@ libimagedec_la_SOURCES += tiffdec.c tiffdec.h
|
|||||||
libimagedec_la_SOURCES += webpdec.c webpdec.h
|
libimagedec_la_SOURCES += webpdec.c webpdec.h
|
||||||
libimagedec_la_SOURCES += wicdec.c wicdec.h
|
libimagedec_la_SOURCES += wicdec.c wicdec.h
|
||||||
libimagedec_la_CPPFLAGS = $(JPEG_INCLUDES) $(PNG_INCLUDES) $(TIFF_INCLUDES)
|
libimagedec_la_CPPFLAGS = $(JPEG_INCLUDES) $(PNG_INCLUDES) $(TIFF_INCLUDES)
|
||||||
libimagedec_la_CPPFLAGS += $(AM_CPPFLAGS) $(USE_EXPERIMENTAL_CODE)
|
libimagedec_la_CPPFLAGS += $(AM_CPPFLAGS)
|
||||||
|
|
||||||
libimageenc_la_SOURCES =
|
libimageenc_la_SOURCES =
|
||||||
libimageenc_la_SOURCES += image_enc.c image_enc.h
|
libimageenc_la_SOURCES += image_enc.c image_enc.h
|
||||||
libimageenc_la_CPPFLAGS = $(JPEG_INCLUDES) $(PNG_INCLUDES) $(TIFF_INCLUDES)
|
libimageenc_la_CPPFLAGS = $(JPEG_INCLUDES) $(PNG_INCLUDES) $(TIFF_INCLUDES)
|
||||||
libimageenc_la_CPPFLAGS += $(AM_CPPFLAGS) $(USE_EXPERIMENTAL_CODE)
|
libimageenc_la_CPPFLAGS += $(AM_CPPFLAGS)
|
||||||
|
@ -91,19 +91,7 @@ VP8StatusCode DecodeWebPIncremental(
|
|||||||
fprintf(stderr, "Failed during WebPINewDecoder().\n");
|
fprintf(stderr, "Failed during WebPINewDecoder().\n");
|
||||||
return VP8_STATUS_OUT_OF_MEMORY;
|
return VP8_STATUS_OUT_OF_MEMORY;
|
||||||
} else {
|
} else {
|
||||||
#ifdef WEBP_EXPERIMENTAL_FEATURES
|
|
||||||
size_t size = 0;
|
|
||||||
const size_t incr = 2 + (data_size / 20);
|
|
||||||
while (size < data_size) {
|
|
||||||
size_t next_size = size + (rand() % incr);
|
|
||||||
if (next_size > data_size) next_size = data_size;
|
|
||||||
status = WebPIUpdate(idec, data, next_size);
|
|
||||||
if (status != VP8_STATUS_OK && status != VP8_STATUS_SUSPENDED) break;
|
|
||||||
size = next_size;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
status = WebPIUpdate(idec, data, data_size);
|
status = WebPIUpdate(idec, data, data_size);
|
||||||
#endif
|
|
||||||
WebPIDelete(idec);
|
WebPIDelete(idec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,9 +63,6 @@ endif
|
|||||||
# 'make -f makefile.unix EXTRA_FLAGS=-m32' to that effect.
|
# 'make -f makefile.unix EXTRA_FLAGS=-m32' to that effect.
|
||||||
# EXTRA_FLAGS += -m32
|
# EXTRA_FLAGS += -m32
|
||||||
|
|
||||||
# Extra flags to enable experimental features and code
|
|
||||||
# EXTRA_FLAGS += -DWEBP_EXPERIMENTAL_FEATURES
|
|
||||||
|
|
||||||
# Extra flags to enable byte swap for 16 bit colorspaces.
|
# Extra flags to enable byte swap for 16 bit colorspaces.
|
||||||
# EXTRA_FLAGS += -DWEBP_SWAP_16BIT_CSP=1
|
# EXTRA_FLAGS += -DWEBP_SWAP_16BIT_CSP=1
|
||||||
|
|
||||||
@ -214,7 +211,6 @@ ENC_OBJS = \
|
|||||||
src/enc/backward_references_enc.o \
|
src/enc/backward_references_enc.o \
|
||||||
src/enc/config_enc.o \
|
src/enc/config_enc.o \
|
||||||
src/enc/cost_enc.o \
|
src/enc/cost_enc.o \
|
||||||
src/enc/delta_palettization_enc.o \
|
|
||||||
src/enc/filter_enc.o \
|
src/enc/filter_enc.o \
|
||||||
src/enc/frame_enc.o \
|
src/enc/frame_enc.o \
|
||||||
src/enc/histogram_enc.o \
|
src/enc/histogram_enc.o \
|
||||||
@ -312,7 +308,6 @@ HDRS = \
|
|||||||
src/dsp/yuv.h \
|
src/dsp/yuv.h \
|
||||||
src/enc/backward_references_enc.h \
|
src/enc/backward_references_enc.h \
|
||||||
src/enc/cost_enc.h \
|
src/enc/cost_enc.h \
|
||||||
src/enc/delta_palettization_enc.h \
|
|
||||||
src/enc/histogram_enc.h \
|
src/enc/histogram_enc.h \
|
||||||
src/enc/vp8i_enc.h \
|
src/enc/vp8i_enc.h \
|
||||||
src/enc/vp8li_enc.h \
|
src/enc/vp8li_enc.h \
|
||||||
|
@ -25,5 +25,5 @@ libwebpdecodeinclude_HEADERS += ../webp/types.h
|
|||||||
noinst_HEADERS =
|
noinst_HEADERS =
|
||||||
noinst_HEADERS += ../webp/format_constants.h
|
noinst_HEADERS += ../webp/format_constants.h
|
||||||
|
|
||||||
libwebpdecode_la_CPPFLAGS = $(AM_CPPFLAGS) $(USE_EXPERIMENTAL_CODE)
|
libwebpdecode_la_CPPFLAGS = $(AM_CPPFLAGS)
|
||||||
libwebpdecodeincludedir = $(includedir)/webp
|
libwebpdecodeincludedir = $(includedir)/webp
|
||||||
|
@ -141,7 +141,7 @@ noinst_HEADERS += ../webp/decode.h
|
|||||||
|
|
||||||
libwebpdsp_la_CPPFLAGS =
|
libwebpdsp_la_CPPFLAGS =
|
||||||
libwebpdsp_la_CPPFLAGS += $(AM_CPPFLAGS)
|
libwebpdsp_la_CPPFLAGS += $(AM_CPPFLAGS)
|
||||||
libwebpdsp_la_CPPFLAGS += $(USE_EXPERIMENTAL_CODE) $(USE_SWAP_16BIT_CSP)
|
libwebpdsp_la_CPPFLAGS += $(USE_SWAP_16BIT_CSP)
|
||||||
libwebpdsp_la_LDFLAGS = -lm
|
libwebpdsp_la_LDFLAGS = -lm
|
||||||
libwebpdsp_la_LIBADD =
|
libwebpdsp_la_LIBADD =
|
||||||
libwebpdsp_la_LIBADD += libwebpdsp_avx2.la
|
libwebpdsp_la_LIBADD += libwebpdsp_avx2.la
|
||||||
|
@ -25,10 +25,6 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WEBP_EXPERIMENTAL_FEATURES
|
|
||||||
#include "src/enc/delta_palettization_enc.h"
|
|
||||||
#endif // WEBP_EXPERIMENTAL_FEATURES
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// Decoding
|
// Decoding
|
||||||
|
|
||||||
|
@ -10,8 +10,6 @@ libwebpencode_la_SOURCES += backward_references_enc.h
|
|||||||
libwebpencode_la_SOURCES += config_enc.c
|
libwebpencode_la_SOURCES += config_enc.c
|
||||||
libwebpencode_la_SOURCES += cost_enc.c
|
libwebpencode_la_SOURCES += cost_enc.c
|
||||||
libwebpencode_la_SOURCES += cost_enc.h
|
libwebpencode_la_SOURCES += cost_enc.h
|
||||||
libwebpencode_la_SOURCES += delta_palettization_enc.c
|
|
||||||
libwebpencode_la_SOURCES += delta_palettization_enc.h
|
|
||||||
libwebpencode_la_SOURCES += filter_enc.c
|
libwebpencode_la_SOURCES += filter_enc.c
|
||||||
libwebpencode_la_SOURCES += frame_enc.c
|
libwebpencode_la_SOURCES += frame_enc.c
|
||||||
libwebpencode_la_SOURCES += histogram_enc.c
|
libwebpencode_la_SOURCES += histogram_enc.c
|
||||||
@ -40,5 +38,5 @@ noinst_HEADERS =
|
|||||||
noinst_HEADERS += ../webp/format_constants.h
|
noinst_HEADERS += ../webp/format_constants.h
|
||||||
|
|
||||||
libwebpencode_la_LDFLAGS = -lm
|
libwebpencode_la_LDFLAGS = -lm
|
||||||
libwebpencode_la_CPPFLAGS = $(AM_CPPFLAGS) $(USE_EXPERIMENTAL_CODE)
|
libwebpencode_la_CPPFLAGS = $(AM_CPPFLAGS)
|
||||||
libwebpencodeincludedir = $(includedir)/webp
|
libwebpencodeincludedir = $(includedir)/webp
|
||||||
|
@ -1,455 +0,0 @@
|
|||||||
// Copyright 2015 Google Inc. All Rights Reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style license
|
|
||||||
// that can be found in the COPYING file in the root of the source
|
|
||||||
// tree. An additional intellectual property rights grant can be found
|
|
||||||
// in the file PATENTS. All contributing project authors may
|
|
||||||
// be found in the AUTHORS file in the root of the source tree.
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Author: Mislav Bradac (mislavm@google.com)
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "src/enc/delta_palettization_enc.h"
|
|
||||||
|
|
||||||
#ifdef WEBP_EXPERIMENTAL_FEATURES
|
|
||||||
#include "src/webp/types.h"
|
|
||||||
#include "src/dsp/lossless.h"
|
|
||||||
|
|
||||||
#define MK_COL(r, g, b) (((r) << 16) + ((g) << 8) + (b))
|
|
||||||
|
|
||||||
// Format allows palette up to 256 entries, but more palette entries produce
|
|
||||||
// bigger entropy. In the future it will probably be useful to add more entries
|
|
||||||
// that are far from the origin of the palette or choose remaining entries
|
|
||||||
// dynamically.
|
|
||||||
#define DELTA_PALETTE_SIZE 226
|
|
||||||
|
|
||||||
// Palette used for delta_palettization. Entries are roughly sorted by distance
|
|
||||||
// of their signed equivalents from the origin.
|
|
||||||
static const uint32_t kDeltaPalette[DELTA_PALETTE_SIZE] = {
|
|
||||||
MK_COL(0u, 0u, 0u),
|
|
||||||
MK_COL(255u, 255u, 255u),
|
|
||||||
MK_COL(1u, 1u, 1u),
|
|
||||||
MK_COL(254u, 254u, 254u),
|
|
||||||
MK_COL(2u, 2u, 2u),
|
|
||||||
MK_COL(4u, 4u, 4u),
|
|
||||||
MK_COL(252u, 252u, 252u),
|
|
||||||
MK_COL(250u, 0u, 0u),
|
|
||||||
MK_COL(0u, 250u, 0u),
|
|
||||||
MK_COL(0u, 0u, 250u),
|
|
||||||
MK_COL(6u, 0u, 0u),
|
|
||||||
MK_COL(0u, 6u, 0u),
|
|
||||||
MK_COL(0u, 0u, 6u),
|
|
||||||
MK_COL(0u, 0u, 248u),
|
|
||||||
MK_COL(0u, 0u, 8u),
|
|
||||||
MK_COL(0u, 248u, 0u),
|
|
||||||
MK_COL(0u, 248u, 248u),
|
|
||||||
MK_COL(0u, 248u, 8u),
|
|
||||||
MK_COL(0u, 8u, 0u),
|
|
||||||
MK_COL(0u, 8u, 248u),
|
|
||||||
MK_COL(0u, 8u, 8u),
|
|
||||||
MK_COL(8u, 8u, 8u),
|
|
||||||
MK_COL(248u, 0u, 0u),
|
|
||||||
MK_COL(248u, 0u, 248u),
|
|
||||||
MK_COL(248u, 0u, 8u),
|
|
||||||
MK_COL(248u, 248u, 0u),
|
|
||||||
MK_COL(248u, 8u, 0u),
|
|
||||||
MK_COL(8u, 0u, 0u),
|
|
||||||
MK_COL(8u, 0u, 248u),
|
|
||||||
MK_COL(8u, 0u, 8u),
|
|
||||||
MK_COL(8u, 248u, 0u),
|
|
||||||
MK_COL(8u, 8u, 0u),
|
|
||||||
MK_COL(23u, 23u, 23u),
|
|
||||||
MK_COL(13u, 13u, 13u),
|
|
||||||
MK_COL(232u, 232u, 232u),
|
|
||||||
MK_COL(244u, 244u, 244u),
|
|
||||||
MK_COL(245u, 245u, 250u),
|
|
||||||
MK_COL(50u, 50u, 50u),
|
|
||||||
MK_COL(204u, 204u, 204u),
|
|
||||||
MK_COL(236u, 236u, 236u),
|
|
||||||
MK_COL(16u, 16u, 16u),
|
|
||||||
MK_COL(240u, 16u, 16u),
|
|
||||||
MK_COL(16u, 240u, 16u),
|
|
||||||
MK_COL(240u, 240u, 16u),
|
|
||||||
MK_COL(16u, 16u, 240u),
|
|
||||||
MK_COL(240u, 16u, 240u),
|
|
||||||
MK_COL(16u, 240u, 240u),
|
|
||||||
MK_COL(240u, 240u, 240u),
|
|
||||||
MK_COL(0u, 0u, 232u),
|
|
||||||
MK_COL(0u, 232u, 0u),
|
|
||||||
MK_COL(232u, 0u, 0u),
|
|
||||||
MK_COL(0u, 0u, 24u),
|
|
||||||
MK_COL(0u, 24u, 0u),
|
|
||||||
MK_COL(24u, 0u, 0u),
|
|
||||||
MK_COL(32u, 32u, 32u),
|
|
||||||
MK_COL(224u, 32u, 32u),
|
|
||||||
MK_COL(32u, 224u, 32u),
|
|
||||||
MK_COL(224u, 224u, 32u),
|
|
||||||
MK_COL(32u, 32u, 224u),
|
|
||||||
MK_COL(224u, 32u, 224u),
|
|
||||||
MK_COL(32u, 224u, 224u),
|
|
||||||
MK_COL(224u, 224u, 224u),
|
|
||||||
MK_COL(0u, 0u, 176u),
|
|
||||||
MK_COL(0u, 0u, 80u),
|
|
||||||
MK_COL(0u, 176u, 0u),
|
|
||||||
MK_COL(0u, 176u, 176u),
|
|
||||||
MK_COL(0u, 176u, 80u),
|
|
||||||
MK_COL(0u, 80u, 0u),
|
|
||||||
MK_COL(0u, 80u, 176u),
|
|
||||||
MK_COL(0u, 80u, 80u),
|
|
||||||
MK_COL(176u, 0u, 0u),
|
|
||||||
MK_COL(176u, 0u, 176u),
|
|
||||||
MK_COL(176u, 0u, 80u),
|
|
||||||
MK_COL(176u, 176u, 0u),
|
|
||||||
MK_COL(176u, 80u, 0u),
|
|
||||||
MK_COL(80u, 0u, 0u),
|
|
||||||
MK_COL(80u, 0u, 176u),
|
|
||||||
MK_COL(80u, 0u, 80u),
|
|
||||||
MK_COL(80u, 176u, 0u),
|
|
||||||
MK_COL(80u, 80u, 0u),
|
|
||||||
MK_COL(0u, 0u, 152u),
|
|
||||||
MK_COL(0u, 0u, 104u),
|
|
||||||
MK_COL(0u, 152u, 0u),
|
|
||||||
MK_COL(0u, 152u, 152u),
|
|
||||||
MK_COL(0u, 152u, 104u),
|
|
||||||
MK_COL(0u, 104u, 0u),
|
|
||||||
MK_COL(0u, 104u, 152u),
|
|
||||||
MK_COL(0u, 104u, 104u),
|
|
||||||
MK_COL(152u, 0u, 0u),
|
|
||||||
MK_COL(152u, 0u, 152u),
|
|
||||||
MK_COL(152u, 0u, 104u),
|
|
||||||
MK_COL(152u, 152u, 0u),
|
|
||||||
MK_COL(152u, 104u, 0u),
|
|
||||||
MK_COL(104u, 0u, 0u),
|
|
||||||
MK_COL(104u, 0u, 152u),
|
|
||||||
MK_COL(104u, 0u, 104u),
|
|
||||||
MK_COL(104u, 152u, 0u),
|
|
||||||
MK_COL(104u, 104u, 0u),
|
|
||||||
MK_COL(216u, 216u, 216u),
|
|
||||||
MK_COL(216u, 216u, 40u),
|
|
||||||
MK_COL(216u, 216u, 176u),
|
|
||||||
MK_COL(216u, 216u, 80u),
|
|
||||||
MK_COL(216u, 40u, 216u),
|
|
||||||
MK_COL(216u, 40u, 40u),
|
|
||||||
MK_COL(216u, 40u, 176u),
|
|
||||||
MK_COL(216u, 40u, 80u),
|
|
||||||
MK_COL(216u, 176u, 216u),
|
|
||||||
MK_COL(216u, 176u, 40u),
|
|
||||||
MK_COL(216u, 176u, 176u),
|
|
||||||
MK_COL(216u, 176u, 80u),
|
|
||||||
MK_COL(216u, 80u, 216u),
|
|
||||||
MK_COL(216u, 80u, 40u),
|
|
||||||
MK_COL(216u, 80u, 176u),
|
|
||||||
MK_COL(216u, 80u, 80u),
|
|
||||||
MK_COL(40u, 216u, 216u),
|
|
||||||
MK_COL(40u, 216u, 40u),
|
|
||||||
MK_COL(40u, 216u, 176u),
|
|
||||||
MK_COL(40u, 216u, 80u),
|
|
||||||
MK_COL(40u, 40u, 216u),
|
|
||||||
MK_COL(40u, 40u, 40u),
|
|
||||||
MK_COL(40u, 40u, 176u),
|
|
||||||
MK_COL(40u, 40u, 80u),
|
|
||||||
MK_COL(40u, 176u, 216u),
|
|
||||||
MK_COL(40u, 176u, 40u),
|
|
||||||
MK_COL(40u, 176u, 176u),
|
|
||||||
MK_COL(40u, 176u, 80u),
|
|
||||||
MK_COL(40u, 80u, 216u),
|
|
||||||
MK_COL(40u, 80u, 40u),
|
|
||||||
MK_COL(40u, 80u, 176u),
|
|
||||||
MK_COL(40u, 80u, 80u),
|
|
||||||
MK_COL(80u, 216u, 216u),
|
|
||||||
MK_COL(80u, 216u, 40u),
|
|
||||||
MK_COL(80u, 216u, 176u),
|
|
||||||
MK_COL(80u, 216u, 80u),
|
|
||||||
MK_COL(80u, 40u, 216u),
|
|
||||||
MK_COL(80u, 40u, 40u),
|
|
||||||
MK_COL(80u, 40u, 176u),
|
|
||||||
MK_COL(80u, 40u, 80u),
|
|
||||||
MK_COL(80u, 176u, 216u),
|
|
||||||
MK_COL(80u, 176u, 40u),
|
|
||||||
MK_COL(80u, 176u, 176u),
|
|
||||||
MK_COL(80u, 176u, 80u),
|
|
||||||
MK_COL(80u, 80u, 216u),
|
|
||||||
MK_COL(80u, 80u, 40u),
|
|
||||||
MK_COL(80u, 80u, 176u),
|
|
||||||
MK_COL(80u, 80u, 80u),
|
|
||||||
MK_COL(0u, 0u, 192u),
|
|
||||||
MK_COL(0u, 0u, 64u),
|
|
||||||
MK_COL(0u, 0u, 128u),
|
|
||||||
MK_COL(0u, 192u, 0u),
|
|
||||||
MK_COL(0u, 192u, 192u),
|
|
||||||
MK_COL(0u, 192u, 64u),
|
|
||||||
MK_COL(0u, 192u, 128u),
|
|
||||||
MK_COL(0u, 64u, 0u),
|
|
||||||
MK_COL(0u, 64u, 192u),
|
|
||||||
MK_COL(0u, 64u, 64u),
|
|
||||||
MK_COL(0u, 64u, 128u),
|
|
||||||
MK_COL(0u, 128u, 0u),
|
|
||||||
MK_COL(0u, 128u, 192u),
|
|
||||||
MK_COL(0u, 128u, 64u),
|
|
||||||
MK_COL(0u, 128u, 128u),
|
|
||||||
MK_COL(176u, 216u, 216u),
|
|
||||||
MK_COL(176u, 216u, 40u),
|
|
||||||
MK_COL(176u, 216u, 176u),
|
|
||||||
MK_COL(176u, 216u, 80u),
|
|
||||||
MK_COL(176u, 40u, 216u),
|
|
||||||
MK_COL(176u, 40u, 40u),
|
|
||||||
MK_COL(176u, 40u, 176u),
|
|
||||||
MK_COL(176u, 40u, 80u),
|
|
||||||
MK_COL(176u, 176u, 216u),
|
|
||||||
MK_COL(176u, 176u, 40u),
|
|
||||||
MK_COL(176u, 176u, 176u),
|
|
||||||
MK_COL(176u, 176u, 80u),
|
|
||||||
MK_COL(176u, 80u, 216u),
|
|
||||||
MK_COL(176u, 80u, 40u),
|
|
||||||
MK_COL(176u, 80u, 176u),
|
|
||||||
MK_COL(176u, 80u, 80u),
|
|
||||||
MK_COL(192u, 0u, 0u),
|
|
||||||
MK_COL(192u, 0u, 192u),
|
|
||||||
MK_COL(192u, 0u, 64u),
|
|
||||||
MK_COL(192u, 0u, 128u),
|
|
||||||
MK_COL(192u, 192u, 0u),
|
|
||||||
MK_COL(192u, 192u, 192u),
|
|
||||||
MK_COL(192u, 192u, 64u),
|
|
||||||
MK_COL(192u, 192u, 128u),
|
|
||||||
MK_COL(192u, 64u, 0u),
|
|
||||||
MK_COL(192u, 64u, 192u),
|
|
||||||
MK_COL(192u, 64u, 64u),
|
|
||||||
MK_COL(192u, 64u, 128u),
|
|
||||||
MK_COL(192u, 128u, 0u),
|
|
||||||
MK_COL(192u, 128u, 192u),
|
|
||||||
MK_COL(192u, 128u, 64u),
|
|
||||||
MK_COL(192u, 128u, 128u),
|
|
||||||
MK_COL(64u, 0u, 0u),
|
|
||||||
MK_COL(64u, 0u, 192u),
|
|
||||||
MK_COL(64u, 0u, 64u),
|
|
||||||
MK_COL(64u, 0u, 128u),
|
|
||||||
MK_COL(64u, 192u, 0u),
|
|
||||||
MK_COL(64u, 192u, 192u),
|
|
||||||
MK_COL(64u, 192u, 64u),
|
|
||||||
MK_COL(64u, 192u, 128u),
|
|
||||||
MK_COL(64u, 64u, 0u),
|
|
||||||
MK_COL(64u, 64u, 192u),
|
|
||||||
MK_COL(64u, 64u, 64u),
|
|
||||||
MK_COL(64u, 64u, 128u),
|
|
||||||
MK_COL(64u, 128u, 0u),
|
|
||||||
MK_COL(64u, 128u, 192u),
|
|
||||||
MK_COL(64u, 128u, 64u),
|
|
||||||
MK_COL(64u, 128u, 128u),
|
|
||||||
MK_COL(128u, 0u, 0u),
|
|
||||||
MK_COL(128u, 0u, 192u),
|
|
||||||
MK_COL(128u, 0u, 64u),
|
|
||||||
MK_COL(128u, 0u, 128u),
|
|
||||||
MK_COL(128u, 192u, 0u),
|
|
||||||
MK_COL(128u, 192u, 192u),
|
|
||||||
MK_COL(128u, 192u, 64u),
|
|
||||||
MK_COL(128u, 192u, 128u),
|
|
||||||
MK_COL(128u, 64u, 0u),
|
|
||||||
MK_COL(128u, 64u, 192u),
|
|
||||||
MK_COL(128u, 64u, 64u),
|
|
||||||
MK_COL(128u, 64u, 128u),
|
|
||||||
MK_COL(128u, 128u, 0u),
|
|
||||||
MK_COL(128u, 128u, 192u),
|
|
||||||
MK_COL(128u, 128u, 64u),
|
|
||||||
MK_COL(128u, 128u, 128u),
|
|
||||||
};
|
|
||||||
|
|
||||||
#undef MK_COL
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// TODO(skal): move the functions to dsp/lossless.c when the correct
|
|
||||||
// granularity is found. For now, we'll just copy-paste some useful bits
|
|
||||||
// here instead.
|
|
||||||
|
|
||||||
// In-place sum of each component with mod 256.
|
|
||||||
static WEBP_INLINE void AddPixelsEq(uint32_t* a, uint32_t b) {
|
|
||||||
const uint32_t alpha_and_green = (*a & 0xff00ff00u) + (b & 0xff00ff00u);
|
|
||||||
const uint32_t red_and_blue = (*a & 0x00ff00ffu) + (b & 0x00ff00ffu);
|
|
||||||
*a = (alpha_and_green & 0xff00ff00u) | (red_and_blue & 0x00ff00ffu);
|
|
||||||
}
|
|
||||||
|
|
||||||
static WEBP_INLINE uint32_t Clip255(uint32_t a) {
|
|
||||||
if (a < 256) {
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
// return 0, when a is a negative integer.
|
|
||||||
// return 255, when a is positive.
|
|
||||||
return ~a >> 24;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delta palettization functions.
|
|
||||||
static WEBP_INLINE int Square(int x) {
|
|
||||||
return x * x;
|
|
||||||
}
|
|
||||||
|
|
||||||
static WEBP_INLINE uint32_t Intensity(uint32_t a) {
|
|
||||||
return
|
|
||||||
30 * ((a >> 16) & 0xff) +
|
|
||||||
59 * ((a >> 8) & 0xff) +
|
|
||||||
11 * ((a >> 0) & 0xff);
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint32_t CalcDist(uint32_t predicted_value, uint32_t actual_value,
|
|
||||||
uint32_t palette_entry) {
|
|
||||||
int i;
|
|
||||||
uint32_t distance = 0;
|
|
||||||
AddPixelsEq(&predicted_value, palette_entry);
|
|
||||||
for (i = 0; i < 32; i += 8) {
|
|
||||||
const int32_t av = (actual_value >> i) & 0xff;
|
|
||||||
const int32_t pv = (predicted_value >> i) & 0xff;
|
|
||||||
distance += Square(pv - av);
|
|
||||||
}
|
|
||||||
// We sum square of intensity difference with factor 10, but because Intensity
|
|
||||||
// returns 100 times real intensity we need to multiply differences of colors
|
|
||||||
// by 1000.
|
|
||||||
distance *= 1000u;
|
|
||||||
distance += Square(Intensity(predicted_value)
|
|
||||||
- Intensity(actual_value));
|
|
||||||
return distance;
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint32_t Predict(int x, int y, uint32_t* image) {
|
|
||||||
const uint32_t t = (y == 0) ? ARGB_BLACK : image[x];
|
|
||||||
const uint32_t l = (x == 0) ? ARGB_BLACK : image[x - 1];
|
|
||||||
const uint32_t p =
|
|
||||||
(((((t >> 24) & 0xff) + ((l >> 24) & 0xff)) / 2) << 24) +
|
|
||||||
(((((t >> 16) & 0xff) + ((l >> 16) & 0xff)) / 2) << 16) +
|
|
||||||
(((((t >> 8) & 0xff) + ((l >> 8) & 0xff)) / 2) << 8) +
|
|
||||||
(((((t >> 0) & 0xff) + ((l >> 0) & 0xff)) / 2) << 0);
|
|
||||||
if (x == 0 && y == 0) return ARGB_BLACK;
|
|
||||||
if (x == 0) return t;
|
|
||||||
if (y == 0) return l;
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
static WEBP_INLINE int AddSubtractComponentFullWithCoefficient(
|
|
||||||
int a, int b, int c) {
|
|
||||||
return Clip255(a + ((b - c) >> 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
static WEBP_INLINE uint32_t ClampedAddSubtractFullWithCoefficient(
|
|
||||||
uint32_t c0, uint32_t c1, uint32_t c2) {
|
|
||||||
const int a = AddSubtractComponentFullWithCoefficient(
|
|
||||||
c0 >> 24, c1 >> 24, c2 >> 24);
|
|
||||||
const int r = AddSubtractComponentFullWithCoefficient((c0 >> 16) & 0xff,
|
|
||||||
(c1 >> 16) & 0xff,
|
|
||||||
(c2 >> 16) & 0xff);
|
|
||||||
const int g = AddSubtractComponentFullWithCoefficient((c0 >> 8) & 0xff,
|
|
||||||
(c1 >> 8) & 0xff,
|
|
||||||
(c2 >> 8) & 0xff);
|
|
||||||
const int b = AddSubtractComponentFullWithCoefficient(
|
|
||||||
c0 & 0xff, c1 & 0xff, c2 & 0xff);
|
|
||||||
return ((uint32_t)a << 24) | (r << 16) | (g << 8) | b;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Find palette entry with minimum error from difference of actual pixel value
|
|
||||||
// and predicted pixel value. Propagate error of pixel to its top and left pixel
|
|
||||||
// in src array. Write predicted_value + palette_entry to new_image. Return
|
|
||||||
// index of best palette entry.
|
|
||||||
static int FindBestPaletteEntry(uint32_t src, uint32_t predicted_value,
|
|
||||||
const uint32_t palette[], int palette_size) {
|
|
||||||
int i;
|
|
||||||
int idx = 0;
|
|
||||||
uint32_t best_distance = CalcDist(predicted_value, src, palette[0]);
|
|
||||||
for (i = 1; i < palette_size; ++i) {
|
|
||||||
const uint32_t distance = CalcDist(predicted_value, src, palette[i]);
|
|
||||||
if (distance < best_distance) {
|
|
||||||
best_distance = distance;
|
|
||||||
idx = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return idx;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ApplyBestPaletteEntry(int x, int y,
|
|
||||||
uint32_t new_value, uint32_t palette_value,
|
|
||||||
uint32_t* src, int src_stride,
|
|
||||||
uint32_t* new_image) {
|
|
||||||
AddPixelsEq(&new_value, palette_value);
|
|
||||||
if (x > 0) {
|
|
||||||
src[x - 1] = ClampedAddSubtractFullWithCoefficient(src[x - 1],
|
|
||||||
new_value, src[x]);
|
|
||||||
}
|
|
||||||
if (y > 0) {
|
|
||||||
src[x - src_stride] =
|
|
||||||
ClampedAddSubtractFullWithCoefficient(src[x - src_stride],
|
|
||||||
new_value, src[x]);
|
|
||||||
}
|
|
||||||
new_image[x] = new_value;
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
// Main entry point
|
|
||||||
|
|
||||||
static WebPEncodingError ApplyDeltaPalette(uint32_t* src, uint32_t* dst,
|
|
||||||
uint32_t src_stride,
|
|
||||||
uint32_t dst_stride,
|
|
||||||
const uint32_t* palette,
|
|
||||||
int palette_size,
|
|
||||||
int width, int height,
|
|
||||||
int num_passes) {
|
|
||||||
int x, y;
|
|
||||||
WebPEncodingError err = VP8_ENC_OK;
|
|
||||||
uint32_t* new_image = (uint32_t*)WebPSafeMalloc(width, sizeof(*new_image));
|
|
||||||
uint8_t* const tmp_row = (uint8_t*)WebPSafeMalloc(width, sizeof(*tmp_row));
|
|
||||||
if (new_image == NULL || tmp_row == NULL) {
|
|
||||||
err = VP8_ENC_ERROR_OUT_OF_MEMORY;
|
|
||||||
goto Error;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (num_passes--) {
|
|
||||||
uint32_t* cur_src = src;
|
|
||||||
uint32_t* cur_dst = dst;
|
|
||||||
for (y = 0; y < height; ++y) {
|
|
||||||
for (x = 0; x < width; ++x) {
|
|
||||||
const uint32_t predicted_value = Predict(x, y, new_image);
|
|
||||||
tmp_row[x] = FindBestPaletteEntry(cur_src[x], predicted_value,
|
|
||||||
palette, palette_size);
|
|
||||||
ApplyBestPaletteEntry(x, y, predicted_value, palette[tmp_row[x]],
|
|
||||||
cur_src, src_stride, new_image);
|
|
||||||
}
|
|
||||||
for (x = 0; x < width; ++x) {
|
|
||||||
cur_dst[x] = palette[tmp_row[x]];
|
|
||||||
}
|
|
||||||
cur_src += src_stride;
|
|
||||||
cur_dst += dst_stride;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Error:
|
|
||||||
WebPSafeFree(new_image);
|
|
||||||
WebPSafeFree(tmp_row);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
// replaces enc->argb_ by a palettizable approximation of it,
|
|
||||||
// and generates optimal enc->palette_[]
|
|
||||||
WebPEncodingError WebPSearchOptimalDeltaPalette(VP8LEncoder* const enc) {
|
|
||||||
const WebPPicture* const pic = enc->pic_;
|
|
||||||
uint32_t* src = pic->argb;
|
|
||||||
uint32_t* dst = enc->argb_;
|
|
||||||
const int width = pic->width;
|
|
||||||
const int height = pic->height;
|
|
||||||
|
|
||||||
WebPEncodingError err = VP8_ENC_OK;
|
|
||||||
memcpy(enc->palette_, kDeltaPalette, sizeof(kDeltaPalette));
|
|
||||||
enc->palette_[DELTA_PALETTE_SIZE - 1] = src[0] - 0xff000000u;
|
|
||||||
enc->palette_size_ = DELTA_PALETTE_SIZE;
|
|
||||||
err = ApplyDeltaPalette(src, dst, pic->argb_stride, enc->current_width_,
|
|
||||||
enc->palette_, enc->palette_size_,
|
|
||||||
width, height, 2);
|
|
||||||
if (err != VP8_ENC_OK) goto Error;
|
|
||||||
|
|
||||||
Error:
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else // !WEBP_EXPERIMENTAL_FEATURES
|
|
||||||
|
|
||||||
WebPEncodingError WebPSearchOptimalDeltaPalette(VP8LEncoder* const enc) {
|
|
||||||
(void)enc;
|
|
||||||
return VP8_ENC_ERROR_INVALID_CONFIGURATION;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // WEBP_EXPERIMENTAL_FEATURES
|
|
@ -1,25 +0,0 @@
|
|||||||
// Copyright 2015 Google Inc. All Rights Reserved.
|
|
||||||
//
|
|
||||||
// Use of this source code is governed by a BSD-style license
|
|
||||||
// that can be found in the COPYING file in the root of the source
|
|
||||||
// tree. An additional intellectual property rights grant can be found
|
|
||||||
// in the file PATENTS. All contributing project authors may
|
|
||||||
// be found in the AUTHORS file in the root of the source tree.
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Author: Mislav Bradac (mislavm@google.com)
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef WEBP_ENC_DELTA_PALETTIZATION_ENC_H_
|
|
||||||
#define WEBP_ENC_DELTA_PALETTIZATION_ENC_H_
|
|
||||||
|
|
||||||
#include "src/webp/encode.h"
|
|
||||||
#include "src/enc/vp8li_enc.h"
|
|
||||||
|
|
||||||
// Replaces enc->argb_[] input by a palettizable approximation of it,
|
|
||||||
// and generates optimal enc->palette_[].
|
|
||||||
// This function can revert enc->use_palette_ / enc->use_predict_ flag
|
|
||||||
// if delta-palettization is not producing expected saving.
|
|
||||||
WebPEncodingError WebPSearchOptimalDeltaPalette(VP8LEncoder* const enc);
|
|
||||||
|
|
||||||
#endif // WEBP_ENC_DELTA_PALETTIZATION_ENC_H_
|
|
@ -26,8 +26,6 @@
|
|||||||
#include "src/utils/utils.h"
|
#include "src/utils/utils.h"
|
||||||
#include "src/webp/format_constants.h"
|
#include "src/webp/format_constants.h"
|
||||||
|
|
||||||
#include "src/enc/delta_palettization_enc.h"
|
|
||||||
|
|
||||||
// Maximum number of histogram images (sub-blocks).
|
// Maximum number of histogram images (sub-blocks).
|
||||||
#define MAX_HUFF_IMAGE_SIZE 2600
|
#define MAX_HUFF_IMAGE_SIZE 2600
|
||||||
|
|
||||||
@ -1464,49 +1462,6 @@ static WebPEncodingError EncodePalette(VP8LBitWriter* const bw, int low_effort,
|
|||||||
20 /* quality */, low_effort);
|
20 /* quality */, low_effort);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WEBP_EXPERIMENTAL_FEATURES
|
|
||||||
|
|
||||||
static WebPEncodingError EncodeDeltaPalettePredictorImage(
|
|
||||||
VP8LBitWriter* const bw, VP8LEncoder* const enc, int quality,
|
|
||||||
int low_effort) {
|
|
||||||
const WebPPicture* const pic = enc->pic_;
|
|
||||||
const int width = pic->width;
|
|
||||||
const int height = pic->height;
|
|
||||||
|
|
||||||
const int pred_bits = 5;
|
|
||||||
const int transform_width = VP8LSubSampleSize(width, pred_bits);
|
|
||||||
const int transform_height = VP8LSubSampleSize(height, pred_bits);
|
|
||||||
const int pred = 7; // default is Predictor7 (Top/Left Average)
|
|
||||||
const int tiles_per_row = VP8LSubSampleSize(width, pred_bits);
|
|
||||||
const int tiles_per_col = VP8LSubSampleSize(height, pred_bits);
|
|
||||||
uint32_t* predictors;
|
|
||||||
int tile_x, tile_y;
|
|
||||||
WebPEncodingError err = VP8_ENC_OK;
|
|
||||||
|
|
||||||
predictors = (uint32_t*)WebPSafeMalloc(tiles_per_col * tiles_per_row,
|
|
||||||
sizeof(*predictors));
|
|
||||||
if (predictors == NULL) return VP8_ENC_ERROR_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
for (tile_y = 0; tile_y < tiles_per_col; ++tile_y) {
|
|
||||||
for (tile_x = 0; tile_x < tiles_per_row; ++tile_x) {
|
|
||||||
predictors[tile_y * tiles_per_row + tile_x] = 0xff000000u | (pred << 8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
VP8LPutBits(bw, TRANSFORM_PRESENT, 1);
|
|
||||||
VP8LPutBits(bw, PREDICTOR_TRANSFORM, 2);
|
|
||||||
VP8LPutBits(bw, pred_bits - 2, 3);
|
|
||||||
err = EncodeImageNoHuffman(
|
|
||||||
bw, predictors, &enc->hash_chain_,
|
|
||||||
(VP8LBackwardRefs*)&enc->refs_[0], // cast const away
|
|
||||||
(VP8LBackwardRefs*)&enc->refs_[1],
|
|
||||||
transform_width, transform_height, quality, low_effort);
|
|
||||||
WebPSafeFree(predictors);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // WEBP_EXPERIMENTAL_FEATURES
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// VP8LEncoder
|
// VP8LEncoder
|
||||||
|
|
||||||
@ -1568,7 +1523,7 @@ static int EncodeStreamHook(void* input, void* data2) {
|
|||||||
WebPEncodingError err = VP8_ENC_OK;
|
WebPEncodingError err = VP8_ENC_OK;
|
||||||
const int quality = (int)config->quality;
|
const int quality = (int)config->quality;
|
||||||
const int low_effort = (config->method == 0);
|
const int low_effort = (config->method == 0);
|
||||||
#if (WEBP_NEAR_LOSSLESS == 1) || defined(WEBP_EXPERIMENTAL_FEATURES)
|
#if (WEBP_NEAR_LOSSLESS == 1)
|
||||||
const int width = picture->width;
|
const int width = picture->width;
|
||||||
#endif
|
#endif
|
||||||
const int height = picture->height;
|
const int height = picture->height;
|
||||||
@ -1627,29 +1582,6 @@ static int EncodeStreamHook(void* input, void* data2) {
|
|||||||
enc->argb_content_ = kEncoderNone;
|
enc->argb_content_ = kEncoderNone;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WEBP_EXPERIMENTAL_FEATURES
|
|
||||||
if (config->use_delta_palette) {
|
|
||||||
enc->use_predict_ = 1;
|
|
||||||
enc->use_cross_color_ = 0;
|
|
||||||
enc->use_subtract_green_ = 0;
|
|
||||||
enc->use_palette_ = 1;
|
|
||||||
if (enc->argb_content_ != kEncoderNearLossless &&
|
|
||||||
enc->argb_content_ != kEncoderPalette) {
|
|
||||||
err = MakeInputImageCopy(enc);
|
|
||||||
if (err != VP8_ENC_OK) goto Error;
|
|
||||||
}
|
|
||||||
err = WebPSearchOptimalDeltaPalette(enc);
|
|
||||||
if (err != VP8_ENC_OK) goto Error;
|
|
||||||
if (enc->use_palette_) {
|
|
||||||
err = AllocateTransformBuffer(enc, width, height);
|
|
||||||
if (err != VP8_ENC_OK) goto Error;
|
|
||||||
err = EncodeDeltaPalettePredictorImage(bw, enc, quality, low_effort);
|
|
||||||
if (err != VP8_ENC_OK) goto Error;
|
|
||||||
use_delta_palette = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // WEBP_EXPERIMENTAL_FEATURES
|
|
||||||
|
|
||||||
// Encode palette
|
// Encode palette
|
||||||
if (enc->use_palette_) {
|
if (enc->use_palette_) {
|
||||||
err = EncodePalette(bw, low_effort, enc);
|
err = EncodePalette(bw, low_effort, enc);
|
||||||
|
Loading…
Reference in New Issue
Block a user