diff --git a/configure.in b/configure.ac similarity index 100% rename from configure.in rename to configure.ac diff --git a/examples/Makefile.am b/examples/Makefile.am index e177746..06aa524 100644 --- examples/Makefile.am +++ examples/Makefile.am @@ -24,7 +24,7 @@ noinst_PROGRAMS = test-libvideogfx bitstream_output cputest pixmaptest filtertes ppmflip chromatest dynarray symmatrix \ $(linuxprogs) $(audioprogs) $(x11progs) # ppm2avi smartpointer -INCLUDES = -I.. +AM_CPPFLAGS = -I.. test_libvideogfx_DEPENDENCIES = ../libvideogfx/libvideogfx.la test_libvideogfx_CFLAGS = $(X_CFLAGS) diff --git a/examples/dynarray.cc b/examples/dynarray.cc index 623d97a..3d0d88b 100644 --- examples/dynarray.cc +++ examples/dynarray.cc @@ -13,7 +13,7 @@ void Show(const DynArray& d) cout << endl; } -main() +int main() { DynArray dynarray; dynarray.SetEmptyValue(-1); diff --git a/examples/symmatrix.cc b/examples/symmatrix.cc index d21ab51..0d06ea4 100644 --- examples/symmatrix.cc +++ examples/symmatrix.cc @@ -16,7 +16,7 @@ void Show(const SymMatrix& d) } } -main() +int main() { SymMatrix m; m.Create(6); diff --git a/libvideogfx/Makefile.am b/libvideogfx/Makefile.am index dd37563..97dc5ce 100644 --- libvideogfx/Makefile.am +++ libvideogfx/Makefile.am @@ -8,7 +8,7 @@ endif DIST_SUBDIRS = arch audio utility graphics containers x11 -INCLUDES = \ +AM_CPPFLAGS = \ -DDATADIR=\"$(datadir)\" \ -DLIBDIR=\"$(libdir)\" \ -DSYSCONFDIR=\"$(sysconfdir)\" \ diff --git a/libvideogfx/arch/Makefile.am b/libvideogfx/arch/Makefile.am index c8df929..4244625 100644 --- libvideogfx/arch/Makefile.am +++ libvideogfx/arch/Makefile.am @@ -19,5 +19,5 @@ libvideogfx_arch_include_HEADERS = \ cpu.hh \ $(mmx_headers) -INCLUDES = \ +AM_CPPFLAGS = \ -I$(top_srcdir) diff --git a/libvideogfx/audio/fileio/Makefile.am b/libvideogfx/audio/fileio/Makefile.am index 815c628..f7fa586 100644 --- libvideogfx/audio/fileio/Makefile.am +++ libvideogfx/audio/fileio/Makefile.am @@ -24,6 +24,6 @@ libvideogfx_audio_fileio_include_HEADERS = \ timedsink.hh \ $(linux_headers) -INCLUDES = \ +AM_CPPFLAGS = \ -I$(top_srcdir) diff --git a/libvideogfx/containers/Makefile.am b/libvideogfx/containers/Makefile.am index 78adf30..e1282b2 100644 --- libvideogfx/containers/Makefile.am +++ libvideogfx/containers/Makefile.am @@ -2,7 +2,21 @@ noinst_LTLIBRARIES = libvideogfx-containers.la -libvideogfx_containers_includedir = $(includedir)/libvideogfx/containers +libvideogfx_containers_includedir = \ + $(includedir)/libvideogfx/containers + +libvideogfx_containers_la_SOURCES = \ + dummy.cc \ + heap.hh \ + heap.icc \ + dynarray.hh \ + array.hh \ + array.icc \ + array2.hh \ + array2.icc \ + symmatrix.hh \ + queue.hh \ + queue.icc # Header files for public installation (non-generated) libvideogfx_containers_include_HEADERS = \ @@ -17,14 +31,5 @@ libvideogfx_containers_include_HEADERS = \ queue.hh \ queue.icc -libvideogfx_containers_la_SOURCES = - -INCLUDES = \ +AM_CPPFLAGS = \ -I$(top_srcdir) - -.PHONY: files - -files: - @files=`ls $(DISTFILES) 2> /dev/null`; for p in $$files; do \ - echo $$p; \ - done diff --git a/libvideogfx/containers/dummy.cc b/libvideogfx/containers/dummy.cc new file mode 100644 index 0000000..5ca23f1 --- /dev/null +++ libvideogfx/containers/dummy.cc @@ -0,0 +1,33 @@ +/* A dummy file, to prevent empty libraries from breaking builds. + Copyright (C) 2004, 2007, 2009-2012 Free Software Foundation, Inc. + + Copying and distribution of this file, with or without + modification, are permitted in any medium without royalty + provided the copyright notice and this notice are preserved. */ + +/* Some systems, reportedly OpenBSD and Mac OS X, refuse to create + libraries without any object files. You might get an error like: + + > ar cru .libs/libgl.a + > ar: no archive members specified + + Compiling this file, and adding its object file to the library, will + prevent the library from being empty. */ + +/* Some systems, such as Solaris with cc 5.0, refuse to work with libraries + that don't export any symbol. You might get an error like: + + > cc ... libgnu.a + > ild: (bad file) garbled symbol table in archive ../gllib/libgnu.a + + Compiling this file, and adding its object file to the library, will + prevent the library from exporting no symbols. */ + +#ifdef __sun +/* This declaration ensures that the library will export at least 1 symbol. */ +int gl_dummy_symbol; +#else +/* This declaration is solely to ensure that after preprocessing + this file is never empty. */ +typedef int dummy; +#endif diff --git a/libvideogfx/graphics/color/Makefile.am b/libvideogfx/graphics/color/Makefile.am index 11c8846..bfe83a8 100644 --- libvideogfx/graphics/color/Makefile.am +++ libvideogfx/graphics/color/Makefile.am @@ -34,6 +34,5 @@ libvideogfx_graphics_color_include_HEADERS = \ img2raw.hh \ colorspace.hh - -INCLUDES = \ +AM_CPPFLAGS = \ -I$(top_srcdir) diff --git a/libvideogfx/graphics/datatypes/Makefile.am b/libvideogfx/graphics/datatypes/Makefile.am index 7edf956..30364d5 100644 --- libvideogfx/graphics/datatypes/Makefile.am +++ libvideogfx/graphics/datatypes/Makefile.am @@ -18,5 +18,5 @@ libvideogfx_graphics_datatypes_include_HEADERS = \ bitmap.hh \ image.hh -INCLUDES = \ +AM_CPPFLAGS = \ -I$(top_srcdir) diff --git a/libvideogfx/graphics/draw/Makefile.am b/libvideogfx/graphics/draw/Makefile.am index aaa4d66..2b61035 100644 --- libvideogfx/graphics/draw/Makefile.am +++ libvideogfx/graphics/draw/Makefile.am @@ -19,5 +19,5 @@ libvideogfx_graphics_draw_include_HEADERS = \ blit.hh \ scale.hh -INCLUDES = \ +AM_CPPFLAGS = \ -I$(top_srcdir) diff --git a/libvideogfx/graphics/fileio/Makefile.am b/libvideogfx/graphics/fileio/Makefile.am index 78fb782..27d094e 100644 --- libvideogfx/graphics/fileio/Makefile.am +++ libvideogfx/graphics/fileio/Makefile.am @@ -74,6 +74,6 @@ libvideogfx_graphics_fileio_include_HEADERS = \ $(linux_headers) \ $(ffmpeg_headers) -INCLUDES = \ +AM_CPPFLAGS = \ -I$(top_srcdir) diff --git a/libvideogfx/graphics/fileio/ffmpeg.cc b/libvideogfx/graphics/fileio/ffmpeg.cc index 6b0a76e..42034b6 100644 --- libvideogfx/graphics/fileio/ffmpeg.cc +++ libvideogfx/graphics/fileio/ffmpeg.cc @@ -166,7 +166,7 @@ namespace videogfx if (frameRGB) { av_free(frameRGB); frameRGB=NULL; } if (frame) { av_free(frame); frame=NULL; } if (codecCtx) { avcodec_close(codecCtx); codecCtx=NULL; } - if (formatCtx) { av_close_input_file(formatCtx); formatCtx=NULL; } + if (formatCtx) { avformat_close_input(&formatCtx); formatCtx=NULL; } } diff --git a/libvideogfx/graphics/fileio/imagesink.hh b/libvideogfx/graphics/fileio/imagesink.hh index 915b597..bdc9e9f 100644 --- libvideogfx/graphics/fileio/imagesink.hh +++ libvideogfx/graphics/fileio/imagesink.hh @@ -34,7 +34,7 @@ ********************************************************************************/ #ifndef LIBVIDEOGFX_GRAPHICS_FILEIO_IMAGESINK_HH -#define LIBVIDEOGFX_GRAPHICS_FILEIO_IMGAESINK_HH +#define LIBVIDEOGFX_GRAPHICS_FILEIO_IMAGESINK_HH #include diff --git a/libvideogfx/graphics/fileio/jpeg.cc b/libvideogfx/graphics/fileio/jpeg.cc index 1e0e557..25d0187 100644 --- libvideogfx/graphics/fileio/jpeg.cc +++ libvideogfx/graphics/fileio/jpeg.cc @@ -73,7 +73,7 @@ namespace videogfx { // initialize decompressor jpeg_create_decompress(&cinfo); - + cinfo.err = jpeg_std_error(&jerr); jpeg_stdio_src(&cinfo, infile); @@ -156,20 +156,26 @@ namespace videogfx { py [cinfo.output_scanline-1][x] = *bufp++; pcb[(cinfo.output_scanline-1)/2][x/2] = *bufp++; pcr[(cinfo.output_scanline-1)/2][x/2] = *bufp++; - py [cinfo.output_scanline-1][x+1] = *bufp++; + + if (x+1 < cinfo.output_width) { + py [cinfo.output_scanline-1][x+1] = *bufp++; + } + bufp+=2; } - (void) jpeg_read_scanlines(&cinfo, buffer, 1); + if (cinfo.output_scanline < cinfo.output_height) { + (void) jpeg_read_scanlines(&cinfo, buffer, 1); - bufp = buffer[0]; + bufp = buffer[0]; - for (unsigned int x=0;x& img, istream& is) { - assert(is != NULL); // , "Open stream first."); + assert(is.good()); // , "Open stream first."); png_structp png_ptr; png_infop info_ptr; @@ -135,7 +135,7 @@ namespace videogfx { &interlace_type, NULL, NULL); assert(bit_depth < 16); // , "cannot handle 16 bit images"); - + /**** Set up the data transformations you want. Note that these are all **** optional. Only call them if you want/need them. Many of the **** transformations only work on specific types of images, and many @@ -291,7 +291,7 @@ namespace videogfx { delete[] row_pointers; } - + void WriteImage_PNG(ostream& os, const Image& img) { /* Create and initialize the png_struct with the desired error handler @@ -416,8 +416,8 @@ namespace videogfx { } } } - - + + png_write_image(png_ptr, row_pointers); /* It is REQUIRED to call this to finish writing the rest of the file */ diff --git a/libvideogfx/graphics/filters/Makefile.am b/libvideogfx/graphics/filters/Makefile.am index 7eba05e..6bd69b6 100644 --- libvideogfx/graphics/filters/Makefile.am +++ libvideogfx/graphics/filters/Makefile.am @@ -36,5 +36,5 @@ libvideogfx_graphics_filters_include_HEADERS = \ resampler.h \ $(mmx_headers) -INCLUDES = \ +AM_CPPFLAGS = \ -I$(top_srcdir) diff --git a/libvideogfx/graphics/geometry/Makefile.am b/libvideogfx/graphics/geometry/Makefile.am index c555cac..b0cb546 100644 --- libvideogfx/graphics/geometry/Makefile.am +++ libvideogfx/graphics/geometry/Makefile.am @@ -15,5 +15,5 @@ libvideogfx_graphics_geometry_include_HEADERS = \ matrix.hh \ transform.hh -INCLUDES = \ +AM_CPPFLAGS = \ -I$(top_srcdir) diff --git a/libvideogfx/graphics/measure/Makefile.am b/libvideogfx/graphics/measure/Makefile.am index c5201ff..21f72c1 100644 --- libvideogfx/graphics/measure/Makefile.am +++ libvideogfx/graphics/measure/Makefile.am @@ -3,14 +3,14 @@ noinst_LTLIBRARIES = libvideogfx-graphics-measure.la libvideogfx_graphics_measure_la_SOURCES = \ - snr.hh \ - snr.cc + snr.hh snr.cc \ + ssim.hh ssim.cc libvideogfx_graphics_measure_includedir = \ $(includedir)/libvideogfx/graphics/measure libvideogfx_graphics_measure_include_HEADERS = \ - snr.hh + snr.hh ssim.hh -INCLUDES = \ +AM_CPPFLAGS = \ -I$(top_srcdir) diff --git a/libvideogfx/graphics/measure/snr.cc b/libvideogfx/graphics/measure/snr.cc index 9400734..e7a5aab 100644 --- libvideogfx/graphics/measure/snr.cc +++ libvideogfx/graphics/measure/snr.cc @@ -103,4 +103,52 @@ namespace videogfx { return psnr; } + + Bitmap CalcErrorMap(const Bitmap& img1, + const Bitmap& img2, + enum TransferCurve transfer_curve, + bool inverted) + { + int w = img1.AskWidth(); + int h = img1.AskHeight(); + + const Pixel*const* p1 = img1.AskFrame(); + const Pixel*const* p2 = img2.AskFrame(); + + Bitmap error; + error.Create(w,h); + + Pixel*const* p = error.AskFrame(); + + + // --- prepare transfer curve --- + + Pixel transfer[255+1+255]; + for (int d=-255;d<=255;d++) + { + switch (transfer_curve) + { + case TransferCurve_Linear: + transfer[d+255] = abs(d); + break; + + case TransferCurve_Sqrt: + transfer[d+255] = sqrt(abs(d)/255.0)*255; + break; + } + + if (inverted) transfer[d+255] = 255 - transfer[d+255]; + } + + + // --- generate error map --- + + for (int y=0;y CalcErrorMap(const Bitmap& img1, + const Bitmap& img2, + enum TransferCurve transfer=TransferCurve_Linear, + bool inverted=true); } diff --git a/libvideogfx/graphics/measure/ssim.cc b/libvideogfx/graphics/measure/ssim.cc new file mode 100644 index 0000000..45c9fcb --- /dev/null +++ libvideogfx/graphics/measure/ssim.cc @@ -0,0 +1,118 @@ +/******************************************************************************** + LibVideoGfx - video processing library + Copyright (C) 2002-2014 Dirk Farin + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + ********************************************************************************/ + +#include "libvideogfx/graphics/measure/ssim.hh" +#include "libvideogfx/graphics/filters/linear.hh" +#include "libvideogfx/containers/array.hh" + +#include +#include +using namespace std; + + +namespace videogfx { + + template T SQ(T t) { return t*t; } + + + Bitmap SSIM::calcSSIM(const Bitmap& img_x, + const Bitmap& img_y) + { + int w = img_x.AskWidth(); + int h = img_y.AskHeight(); + + Array filter; + CreateGaussFilter(filter, sigma, 0.01); + + Bitmap mean_x, mean_y; + ConvolveHV(mean_x,img_x, filter); + ConvolveHV(mean_y,img_y, filter); + + Bitmap meandiff_x, meandiff_y; + meandiff_x.Create(w,h); + meandiff_y.Create(w,h); + + for (int y=0;y sigma_x, sigma_y; + ConvolveHV(sigma_x,meandiff_x, filter); + ConvolveHV(sigma_y,meandiff_y, filter); + + for (int y=0;y corr_tmp; + corr_tmp.Create(w,h); + for (int y=0;y corr; + ConvolveHV(corr, corr_tmp, filter); + + //return corr; + + Bitmap ssim; + ssim.Create(w,h); + for (int y=0;y1.0) s = 1.0; + + ssim[y][x] = s; + } + + return ssim; + } + + + + float SSIM::calcMSSIM(const Bitmap& img1, + const Bitmap& img2) + { + int w = img1.AskWidth(); + int h = img1.AskHeight(); + + Bitmap ssim = calcSSIM(img1,img2); + + double ssimSum = 0.0; + + for (int y=0;y + +namespace videogfx { + + class SSIM + { + public: + SSIM() : + C1(0.01 * 256), + C2(0.03 * 256), + r (5), // 11x11 patches + sigma(1.5) + { } + + float C1, C2; + int r; + float sigma; + + Bitmap calcSSIM(const Bitmap& img1, + const Bitmap& img2); + + float calcMSSIM(const Bitmap& img1, + const Bitmap& img2); + }; +} + + +#endif diff --git a/libvideogfx/graphics/visualize/Makefile.am b/libvideogfx/graphics/visualize/Makefile.am index 02a02f0..0ed5bfc 100644 --- libvideogfx/graphics/visualize/Makefile.am +++ libvideogfx/graphics/visualize/Makefile.am @@ -20,5 +20,5 @@ libvideogfx_graphics_visualize_include_HEADERS = \ # markblks.hh \ # motionfield.hh -INCLUDES = \ +AM_CPPFLAGS = \ -I$(top_srcdir) diff --git a/libvideogfx/libvideogfx.hh.in b/libvideogfx/libvideogfx.hh.in index 704553b..bf698ed 100644 --- libvideogfx/libvideogfx.hh.in +++ libvideogfx/libvideogfx.hh.in @@ -63,6 +63,7 @@ #include #include #include +#include #include #include #include diff --git a/libvideogfx/utility/Makefile.am b/libvideogfx/utility/Makefile.am index 7150ec6..4da98ba 100644 --- libvideogfx/utility/Makefile.am +++ libvideogfx/utility/Makefile.am @@ -21,5 +21,5 @@ libvideogfx_utility_include_HEADERS = \ refcntr.hh # smartpointer.hh -INCLUDES = \ +AM_CPPFLAGS = \ -I$(top_srcdir) diff --git a/libvideogfx/utility/bitstream/Makefile.am b/libvideogfx/utility/bitstream/Makefile.am index f6cb79d..5f45d84 100644 --- libvideogfx/utility/bitstream/Makefile.am +++ libvideogfx/utility/bitstream/Makefile.am @@ -27,5 +27,5 @@ libvideogfx_utility_bitstream_include_HEADERS = \ inputstream.hh \ inputstream_istr.hh -INCLUDES = \ +AM_CPPFLAGS = \ -I$(top_srcdir) diff --git a/libvideogfx/utility/bitstream/bitbuffer.cc b/libvideogfx/utility/bitstream/bitbuffer.cc index 9f879ac..3b469fd 100644 --- libvideogfx/utility/bitstream/bitbuffer.cc +++ libvideogfx/utility/bitstream/bitbuffer.cc @@ -58,7 +58,7 @@ namespace videogfx { void BitBuffer::WriteBitsMasked(uint32 bits,int nBits) { - uint32 long mask=1; + uint32 mask=1; mask<<=nBits; mask--; diff --git a/libvideogfx/x11/Makefile.am b/libvideogfx/x11/Makefile.am index 06f8309..2eb6c0e 100644 --- libvideogfx/x11/Makefile.am +++ libvideogfx/x11/Makefile.am @@ -22,5 +22,5 @@ libvideogfx_x11_include_HEADERS = \ draw_x11.hh \ server.hh -INCLUDES = \ +AM_CPPFLAGS = \ -I$(top_srcdir)