diff --git a/Android.mk b/Android.mk index f9903c67..ecd3fb56 100644 --- a/Android.mk +++ b/Android.mk @@ -3,7 +3,6 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES := \ src/dec/alpha.c \ - src/dec/bits.c \ src/dec/dsp.c \ src/dec/frame.c \ src/dec/idec.c \ @@ -14,7 +13,6 @@ LOCAL_SRC_FILES := \ src/dec/webp.c \ src/dec/io.c \ src/dec/buffer.c \ - src/dec/thread.c \ src/dsp/yuv.c \ src/dsp/upsampling.c \ src/dsp/cpu.c \ @@ -22,7 +20,6 @@ LOCAL_SRC_FILES := \ src/dsp/enc.c \ src/enc/alpha.c \ src/enc/analysis.c \ - src/enc/bit_writer.c \ src/enc/config.c \ src/enc/dsp.c \ src/enc/filter.c \ @@ -34,6 +31,9 @@ LOCAL_SRC_FILES := \ src/enc/syntax.c \ src/enc/tree.c \ src/enc/webpenc.c + src/utils/bit_reader.c \ + src/utils/bit_writer.c \ + src/utils/thread.c \ LOCAL_CFLAGS := -Wall -DANDROID -DHAVE_MALLOC_H -DHAVE_PTHREAD -DWEBP_USE_THREAD \ -finline-functions -frename-registers -ffast-math \ diff --git a/Makefile.vc b/Makefile.vc index 6d66fcfc..6ed22995 100644 --- a/Makefile.vc +++ b/Makefile.vc @@ -132,7 +132,6 @@ CFGSET = TRUE # X_OBJS= \ - $(DIROBJ)\dec\bits.obj \ $(DIROBJ)\dec\frame.obj \ $(DIROBJ)\dec\quant.obj \ $(DIROBJ)\dec\tree.obj \ @@ -143,9 +142,7 @@ X_OBJS= \ $(DIROBJ)\dec\idec.obj \ $(DIROBJ)\dec\alpha.obj \ $(DIROBJ)\dec\layer.obj \ - $(DIROBJ)\dec\thread.obj \ $(DIROBJ)\enc\analysis.obj \ - $(DIROBJ)\enc\bit_writer.obj \ $(DIROBJ)\enc\config.obj \ $(DIROBJ)\enc\cost.obj \ $(DIROBJ)\enc\frame.obj \ @@ -166,6 +163,9 @@ X_OBJS= \ $(DIROBJ)\dsp\dec_sse2.obj \ $(DIROBJ)\dsp\cpu.obj \ $(DIROBJ)\dsp\yuv.obj \ + $(DIROBJ)\utils\bit_reader.obj \ + $(DIROBJ)\utils\bit_writer.obj \ + $(DIROBJ)\utils\thread.obj \ $(RESOURCE) EXAMPLES_OBJS = \ @@ -187,7 +187,7 @@ $(DIRLIB)\$(TARGET): $(X_OBJS) $(LNK) $(LFLAGS) $(X_OBJS) -xcopy $(DIROBJ)\*.pdb $(DIRLIB) /y -$(X_OBJS): $(DIROBJ)\enc $(DIROBJ)\dec $(DIROBJ)\dsp $(DIRLIB) $(DIRINC) $(DIRBIN) +$(X_OBJS): $(DIROBJ)\enc $(DIROBJ)\dec $(DIROBJ)\dsp $(DIROBJ)\utils $(DIRLIB) $(DIRINC) $(DIRBIN) !IF "$(DLLBUILD)" == "TRUE" $(X_OBJS): $(DIROBJ)\$(DLLINC) clean:: @@ -208,6 +208,9 @@ $(DIROBJ)\dec: $(DIROBJ)\dsp: @if not exist "$(DIROBJ)\dsp" mkdir $(DIROBJ)\dsp +$(DIROBJ)\utils: + @if not exist "$(DIROBJ)\utils" mkdir $(DIROBJ)\utils + $(DIRLIB): @if not exist "$(DIRLIB)" mkdir $(DIRLIB) @@ -233,6 +236,8 @@ $(DIROBJ)\$(DLLINC): $(CC) $(CFLAGS) /Fo"$@" $< {src\dsp}.c{$(DIROBJ)\dsp}.obj: $(CC) $(CFLAGS) /Fo"$@" $< +{src\utils}.c{$(DIROBJ)\utils}.obj: + $(CC) $(CFLAGS) /Fo"$@" $< {$(DIROBJ)\examples}.obj{$(DIRBIN)}.exe: $(LNKEXE) $(LDFLAGS) /OUT:"$@" $< ole32.lib windowscodecs.lib shlwapi.lib $(DIRLIB)\$(TARGET) diff --git a/configure.ac b/configure.ac index ef7324b3..375f524f 100644 --- a/configure.ac +++ b/configure.ac @@ -153,6 +153,7 @@ AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([Makefile src/Makefile man/Makefile \ examples/Makefile src/dec/Makefile \ src/enc/Makefile src/dsp/Makefile \ + src/utils/Makefile \ src/libwebp.pc]) diff --git a/makefile.unix b/makefile.unix index f5f3622b..a96e1c15 100644 --- a/makefile.unix +++ b/makefile.unix @@ -56,23 +56,27 @@ CFLAGS = -O3 -DNDEBUG $(EXTRA_FLAGS) INSTALL = install LDFLAGS = $(EXTRA_LIBS) -lm -OBJS = src/enc/webpenc.o src/enc/bit_writer.o src/enc/syntax.o \ - src/enc/alpha.o src/enc/layer.o \ - src/enc/tree.o src/enc/config.o src/enc/frame.o \ - src/enc/quant.o src/enc/iterator.o src/enc/analysis.o \ - src/enc/cost.o src/enc/picture.o src/enc/filter.o \ - src/dec/bits.o src/dec/frame.o \ - src/dec/webp.o src/dec/quant.o src/dec/tree.o src/dec/vp8.o \ - src/dec/idec.o src/dec/alpha.o src/dec/layer.o \ - src/dec/io.o src/dec/buffer.o src/dec/thread.o \ - src/dsp/cpu.o src/dsp/enc.o src/dsp/enc_sse2.o \ - src/dsp/dec.o src/dsp/dec_sse2.o \ - src/dsp/upsampling.o src/dsp/upsampling_sse2.o \ - src/dsp/yuv.o +DEC_OBJS = src/dec/frame.o src/dec/webp.o src/dec/quant.o src/dec/tree.o \ + src/dec/vp8.o src/dec/idec.o src/dec/alpha.o src/dec/layer.o \ + src/dec/io.o src/dec/buffer.o +ENC_OBJS = src/enc/webpenc.o src/enc/syntax.o \ + src/enc/alpha.o src/enc/layer.o \ + src/enc/tree.o src/enc/config.o src/enc/frame.o \ + src/enc/quant.o src/enc/iterator.o src/enc/analysis.o \ + src/enc/cost.o src/enc/picture.o src/enc/filter.o +DSP_OBJS = src/dsp/cpu.o src/dsp/enc.o \ + src/dsp/enc_sse2.o src/dsp/dec.o src/dsp/dec_sse2.o \ + src/dsp/upsampling.o src/dsp/upsampling_sse2.o \ + src/dsp/yuv.o +UTILS_OBJS = src/utils/bit_reader.o src/utils/bit_writer.o src/utils/thread.o + +OBJS = $(DEC_OBJS) $(ENC_OBJS) $(DSP_OBJS) $(UTILS_OBJS) + +HDRS = src/webp/encode.h src/enc/vp8enci.h src/enc/cost.h \ + src/dec/vp8i.h \ + src/dsp/yuv.h src/dsp/dsp.h \ + src/utils/bit_writer.h src/utils/bit_reader.h src/utils/thread.h -HDRS = src/webp/encode.h src/enc/vp8enci.h src/enc/bit_writer.h \ - src/enc/cost.h src/dec/bits.h src/dec/vp8i.h src/dsp/yuv.h \ - src/dsp/dsp.h OUTPUT = examples/cwebp examples/dwebp src/libwebp.a all:ex @@ -111,6 +115,7 @@ clean: src/enc/*.o src/enc/*~ \ src/dec/*.o src/dec/*~ \ src/dsp/*.o src/dsp/*~ \ + src/utils/*.o src/utils/*~ \ examples/*.o examples/*~ superclean: clean diff --git a/src/Makefile.am b/src/Makefile.am index 0b061be5..90be4a69 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = dec enc dsp +SUBDIRS = dec enc dsp utils AM_CPPFLAGS = -I$(top_srcdir)/src lib_LTLIBRARIES = libwebp.la @@ -6,6 +6,7 @@ lib_LTLIBRARIES = libwebp.la libwebp_la_SOURCES = libwebp_la_LIBADD = dec/libwebpdecode.la \ enc/libwebpencode.la \ + utils/libwebputils.la \ dsp/libwebpdsp.la libwebp_la_LDFLAGS = -version-info 0:0:0 libwebpinclude_HEADERS = webp/types.h webp/decode.h webp/decode_vp8.h \ diff --git a/src/dec/Makefile.am b/src/dec/Makefile.am index bb1b29d8..3fe5ad42 100644 --- a/src/dec/Makefile.am +++ b/src/dec/Makefile.am @@ -1,16 +1,13 @@ AM_CPPFLAGS = -I$(top_srcdir)/src -libwebpdecode_la_SOURCES = bits.h vp8i.h bits.c frame.c \ - quant.c tree.c vp8.c webp.c idec.c alpha.c \ - layer.c io.c buffer.c thread.c +libwebpdecode_la_SOURCES = vp8i.h webpi.h \ + frame.c quant.c tree.c vp8.c webp.c \ + idec.c alpha.c layer.c io.c buffer.c libwebpdecode_la_LDFLAGS = -version-info 0:0:0 libwebpdecode_la_CPPFLAGS = $(USE_EXPERIMENTAL_CODE) libwebpdecodeinclude_HEADERS = ../webp/decode.h ../webp/decode_vp8.h ../webp/types.h libwebpdecodeincludedir = $(includedir)/webp -noinst_HEADERS = bits.h vp8i.h webpi.h thread.h +noinst_HEADERS = vp8i.h webpi.h noinst_LTLIBRARIES = libwebpdecode.la -# uncomment the following line (and comment the above) if you want -# to install libwebpdecode library. -#lib_LTLIBRARIES = libwebpdecode.la diff --git a/src/dec/vp8i.h b/src/dec/vp8i.h index 8bc8dcbb..0bc2c0a2 100644 --- a/src/dec/vp8i.h +++ b/src/dec/vp8i.h @@ -13,8 +13,8 @@ #define WEBP_DEC_VP8I_H_ #include // for memcpy() -#include "./bits.h" -#include "./thread.h" +#include "../utils/bit_reader.h" +#include "../utils/thread.h" #include "../dsp/dsp.h" #if defined(__cplusplus) || defined(c_plusplus) @@ -366,4 +366,4 @@ int VP8DecodeLayer(VP8Decoder* const dec); } // extern "C" #endif -#endif // WEBP_DEC_VP8I_H_ +#endif /* WEBP_DEC_VP8I_H_ */ diff --git a/src/enc/Makefile.am b/src/enc/Makefile.am index 96e872cf..4461b8fb 100644 --- a/src/enc/Makefile.am +++ b/src/enc/Makefile.am @@ -1,7 +1,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/src -libwebpencode_la_SOURCES = analysis.c bit_writer.c bit_writer.h \ - config.c cost.c cost.h filter.c \ +libwebpencode_la_SOURCES = analysis.c config.c cost.c cost.h filter.c \ frame.c iterator.c picture.c quant.c \ syntax.c tree.c vp8enci.h webpenc.c alpha.c \ layer.c @@ -10,5 +9,5 @@ libwebpencode_la_CPPFLAGS = $(USE_EXPERIMENTAL_CODE) libwebpencodeinclude_HEADERS = ../webp/encode.h ../webp/types.h libwebpencodeincludedir = $(includedir)/webp -noinst_HEADERS = cost.h bit_writer.h vp8enci.h +noinst_HEADERS = cost.h vp8enci.h noinst_LTLIBRARIES = libwebpencode.la diff --git a/src/enc/vp8enci.h b/src/enc/vp8enci.h index 4a961456..357523aa 100644 --- a/src/enc/vp8enci.h +++ b/src/enc/vp8enci.h @@ -15,7 +15,7 @@ #include "string.h" // for memcpy() #include "../webp/encode.h" #include "../dsp/dsp.h" -#include "bit_writer.h" +#include "../utils/bit_writer.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { @@ -457,4 +457,4 @@ extern void VP8AdjustFilterStrength(VP8EncIterator* const it); } // extern "C" #endif -#endif // WEBP_ENC_VP8ENCI_H_ +#endif /* WEBP_ENC_VP8ENCI_H_ */ diff --git a/src/utils/Makefile.am b/src/utils/Makefile.am new file mode 100644 index 00000000..81a6797a --- /dev/null +++ b/src/utils/Makefile.am @@ -0,0 +1,13 @@ +AM_CPPFLAGS = -I$(top_srcdir)/src + +libwebputils_la_SOURCES = bit_reader.h bit_reader.c \ + bit_writer.h bit_writer.c \ + thread.h thread.c +libwebputils_la_LDFLAGS = -version-info 0:0:0 +libwebputils_la_CPPFLAGS = $(USE_EXPERIMENTAL_CODE) +libwebputilsinclude_HEADERS = ../webp/types.h +libwebputilsincludedir = $(includedir)/webp + +noinst_HEADERS = bit_reader.h bit_writer.h thread.h + +noinst_LTLIBRARIES = libwebputils.la diff --git a/src/dec/bits.c b/src/utils/bit_reader.c similarity index 99% rename from src/dec/bits.c rename to src/utils/bit_reader.c index fdf1d5af..c37efa71 100644 --- a/src/dec/bits.c +++ b/src/utils/bit_reader.c @@ -9,7 +9,7 @@ // // Author: Skal (pascal.massimino@gmail.com) -#include "bits.h" +#include "./bit_reader.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { diff --git a/src/dec/bits.h b/src/utils/bit_reader.h similarity index 96% rename from src/dec/bits.h rename to src/utils/bit_reader.h index 23ca54ee..b71ed546 100644 --- a/src/dec/bits.h +++ b/src/utils/bit_reader.h @@ -9,8 +9,8 @@ // // Author: Skal (pascal.massimino@gmail.com) -#ifndef WEBP_DEC_BITS_H_ -#define WEBP_DEC_BITS_H_ +#ifndef WEBP_UTILS_BIT_READER_H_ +#define WEBP_UTILS_BIT_READER_H_ #include #include "../webp/decode_vp8.h" @@ -105,4 +105,4 @@ static inline int VP8GetSigned(VP8BitReader* const br, int v) { } // extern "C" #endif -#endif // WEBP_DEC_BITS_H_ +#endif /* WEBP_UTILS_BIT_READER_H_ */ diff --git a/src/enc/bit_writer.c b/src/utils/bit_writer.c similarity index 98% rename from src/enc/bit_writer.c rename to src/utils/bit_writer.c index 8b677644..9ed8275a 100644 --- a/src/enc/bit_writer.c +++ b/src/utils/bit_writer.c @@ -10,8 +10,9 @@ // Author: Skal (pascal.massimino@gmail.com) #include +#include // for memcpy() #include -#include "vp8enci.h" +#include "./bit_writer.h" #if defined(__cplusplus) || defined(c_plusplus) extern "C" { diff --git a/src/enc/bit_writer.h b/src/utils/bit_writer.h similarity index 94% rename from src/enc/bit_writer.h rename to src/utils/bit_writer.h index 5f717742..1368a349 100644 --- a/src/enc/bit_writer.h +++ b/src/utils/bit_writer.h @@ -9,8 +9,8 @@ // // Author: Skal (pascal.massimino@gmail.com) -#ifndef WEBP_ENC_BIT_WRITER_H_ -#define WEBP_ENC_BIT_WRITER_H_ +#ifndef WEBP_UTILS_BIT_WRITER_H_ +#define WEBP_UTILS_BIT_WRITER_H_ #include "../webp/types.h" @@ -60,4 +60,4 @@ static inline size_t VP8BitWriterSize(const VP8BitWriter* const bw) { } // extern "C" #endif -#endif // WEBP_ENC_BIT_WRITER_H_ +#endif /* WEBP_UTILS_BIT_WRITER_H_ */ diff --git a/src/dec/thread.c b/src/utils/thread.c similarity index 99% rename from src/dec/thread.c rename to src/utils/thread.c index 28c56fe2..0e1789d4 100644 --- a/src/dec/thread.c +++ b/src/utils/thread.c @@ -9,7 +9,8 @@ // // Author: skal@google.com (Pascal Massimino) -#include "./vp8i.h" +#include +#include // for memset() #include "./thread.h" #if defined(__cplusplus) || defined(c_plusplus) diff --git a/src/dec/thread.h b/src/utils/thread.h similarity index 94% rename from src/dec/thread.h rename to src/utils/thread.h index b5500e81..2c40f727 100644 --- a/src/dec/thread.h +++ b/src/utils/thread.h @@ -9,8 +9,8 @@ // // Author: skal@google.com (Pascal Massimino) -#ifndef WEBP_DEC_THREAD_H -#define WEBP_DEC_THREAD_H +#ifndef WEBP_UTILS_THREAD_H_ +#define WEBP_UTILS_THREAD_H_ #if defined(__cplusplus) || defined(c_plusplus) extern "C" { @@ -33,8 +33,8 @@ typedef struct { #include -#endif // _WIN32 -#endif // WEBP_USE_THREAD +#endif /* _WIN32 */ +#endif /* WEBP_USE_THREAD */ // State of the worker thread object typedef enum { @@ -83,4 +83,4 @@ void WebPWorkerEnd(WebPWorker* const worker); } // extern "C" #endif -#endif // WEBP_DEC_THREAD_H +#endif /* WEBP_UTILS_THREAD_H_ */