diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-09-11 23:35:57 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-09-11 23:35:57 +0100 |
| commit | 88065ad7e9070c7c6a0f9b15202c392084e9e8ba (patch) | |
| tree | 95aa18859010fb3b534a1a860f38b0b62368e98d /src/lib/image.cc | |
| parent | 61ae2097c03bc287d654a9bab72280312a21d577 (diff) | |
Spot repeated frames from single-image sources and optimise encoding.
Diffstat (limited to 'src/lib/image.cc')
| -rw-r--r-- | src/lib/image.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/lib/image.cc b/src/lib/image.cc index 2eb2dbe28..0b06d39b1 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -690,3 +690,30 @@ Image::digest () const return digester.get (); } + +bool +operator== (Image const & a, Image const & b) +{ + if (a.components() != b.components() || a.pixel_format() != b.pixel_format() || a.aligned() != b.aligned()) { + return false; + } + + for (int c = 0; c < a.components(); ++c) { + if (a.lines(c) != b.lines(c) || a.line_size()[c] != b.line_size()[c] || a.stride()[c] != b.stride()[c]) { + return false; + } + + uint8_t* p = a.data()[c]; + uint8_t* q = b.data()[c]; + for (int y = 0; y < a.lines(c); ++y) { + if (memcmp (p, q, a.line_size()[c]) != 0) { + return false; + } + + p += a.stride()[c]; + q += b.stride()[c]; + } + } + + return true; +} |
