Commit Graph

2214 Commits

Author SHA1 Message Date
Pascal Massimino
ba843a92e7 fix some SSIM calculations
* prevent 64bit overflow by controlling the 32b->64b conversions
  and preventively descaling by 8bit before the final multiply
* adjust the threshold constants C1 and C2 to de-emphasis the dark
  areas
* use a hat-like filter instead of box-filtering to avoid blockiness
  during averaging

SSIM distortion calc is actually *faster* now in SSE2, because of the
unrolling during the function rewrite.
The C-version is quite slower because still un-optimized.

Change-Id: I96e2715827f79d26faae354cc28c7406c6800c90
2016-10-04 01:09:07 -07:00
Vincent Rabaud
f79450ca02 Speedup ApplyMap.
If a small hash map can be used, use it to avoid binary search.
This fist hash function that is tried works with the previous
use case of having indexed data in green.

Change-Id: I2f91cec5f3ca7e9c393fd829e69e09bab74f4e7c
2016-09-28 17:18:08 +02:00
Pascal Massimino
cfdda7c6bf Merge "prevent 32b overflow for very large canvas_width / height" 2016-09-28 15:09:58 +00:00
Vincent Rabaud
30d43706d3 Speed-up Combined entropy for palettized histograms.
Change-Id: Ie9bdebb26c726e5b44c2dbcc84d453f85a03f419
2016-09-28 13:22:13 +02:00
Pascal Massimino
86a84b3598 2x faster SSE2 implementation of SSIMGet
Change-Id: I53705d7ddfa595389ff2d542e5088f96f948d351
2016-09-23 23:23:06 -07:00
James Zern
b8384b53d6 lower WEBP_MAX_ALLOCABLE_MEMORY default
restrict to 2^34 for 64-bit targets, < 2^32 for 32-bit

Change-Id: Iff4ce40ae2c3c7fc119f018c2128dbe8f744341f
2016-09-22 23:13:33 -07:00
Pascal Massimino
1c36440094 prevent 32b overflow for very large canvas_width / height
some multiplies here and there needed some extra checks
and error reporting. Even if width * height is guaranteed
to be < 2**32, we were multiplying by num_channels and
triggering a 32b overflow.
Some multiplies were not using size_t or uint64_t, additionally.

Change-Id: If2a35b94c8af204135f4b88a7fd63850aa381bbf
2016-09-23 05:19:32 +00:00
Vincent Rabaud
5f1caf2987 Small LZ77 speedups.
The most common conditions are re-ordered and cached.

iter_min was recently introduced to make sure enough iterations
are made in cases where there are many matches (mostly uniform regions).
Now that those are properly analyzed, it becomes useless.

Change-Id: Id3010ee4ec66b84d602fcb926f91eb9155ad27f4
2016-09-22 14:03:25 +02:00
hui su
a2fe9bf404 Speedup TrellisQuantizeBlock().
-Skip examining quantized levels that are too high.
-Calculate last_pos_cost only when needed.

Encoding speed for m6 is increased by about 3%;
Compression performance is neutral.

Change-Id: I8af70b049587cca0375d9b3eb00479ec7c0c842a
2016-09-20 14:54:15 -07:00
Pascal Massimino
573cce270e smartYUV improvements
* switch to Rec709 transfer function in SmartYUV
* use Rec709 for Gray evaluation too.
* stop iterations if error is going up

See paragraph 1.2 and 3.2:
https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.709-6-201506-I!!PDF-E.pdf

(digest: https://en.wikipedia.org/wiki/Rec._709#Transfer_characteristics)

suggested by pdknsk@gmail.com on the mailing list

Change-Id: I12b5f4d3e318dd5134984e1c0a4b244a620a57d7
2016-09-20 06:14:31 +00:00
Pascal Massimino
21e7537abe fix infinite loop in case of PARTITION0 overflow
max_i4_header_bits_ could drop to zero for difficult image and trigger
a loop. Surprisingly, StatLoop() didn't have this bug.

Change-Id: Idc0f9eadef30a2b2f02041b994f25def30901e36
2016-09-15 02:38:28 -07:00
Pascal Massimino
053a1565c8 Merge "Change the rule of picking UV mode in MBAnalyzeBestUVMode()" 2016-09-15 06:58:40 +00:00
hui su
1377ac2ec1 Change the rule of picking UV mode in MBAnalyzeBestUVMode()
Pick the mode with the smallest alpha.
It only affects m0, in which case the mode decision is not re-examined
later in VP8Decimate(). Tests on some natural content png images show
PSNR increase as well as visual quality improvement.

Change-Id: Iea997e718cd7477160fa05eb7cfb35f4cec2fa9a
2016-09-15 06:01:03 +00:00
Pascal Massimino
7c1fb7d0ff fix uint32_t initialization (0. -> 0)
Change-Id: Ia4aae27f70c4e74ddeb5654cfabb21d785cea9cf
2016-09-14 20:26:05 +02:00
Pascal Massimino
bfff0bf329 speed-up SSIM calculation
SSIM results are incompatible with previous version!
We're now averaging the SSIM value for each pixels instead of
printing a frame-level global SSIM value.

* Got rid of some old code
* switched to uint32_t for accumulation
* refactoring

SSIM calculation is ~4x faster now.

Change-Id: I48d838e66aef5199b9b5cd5cddef6a98411f5673
2016-09-14 16:15:43 +02:00
Vincent Rabaud
64577de8ae De-VP8L-ize GetEntropUnrefinedHelper.
Having it architecture dependent resulted in an extra
function call of an extern function, hence no inlining and
a 5-10% impact on performance.

Change-Id: I0ff40d2d881edc76d3594213a64ee53097d42450
2016-09-14 13:55:24 +02:00
Pascal Massimino
a7be73280b Merge "refactor the PSNR / SSIM calculation code" 2016-09-14 06:37:56 +00:00
Pascal Massimino
50c3d7da9a refactor the PSNR / SSIM calculation code
-print_psnr is now much faster because it doesn't use the SSIM code.
The SSIM speed-up and re-write will come later.

Change-Id: Iabf565e0a8b41651d8164df1266cfeded4ab4823
2016-09-14 06:13:24 +00:00
Pascal Massimino
d6228aed6a indentation fix after I7055d3ee3bd7ed5e78e94ae82cb858fa7db3ddc0
Change-Id: I2145815d778321b9ccc7ac2775aaf64cf2372a42
2016-09-13 22:49:42 -07:00
Vincent Rabaud
dd538b192d Remove unused declaration.
Change-Id: I8ab19654df63e7ef8aad00e97d1428c7b53ee33f
2016-09-13 16:25:46 +02:00
Vincent Rabaud
6cc48b1728 Move some lossless logic out of dsp.
Change-Id: I4cfd60cd5497666a2e1c188ceada2e71b05f1505
2016-09-13 15:37:32 +02:00
Pascal Massimino
78363e9e51 Merge "Remove a redundant call to InitLeft() in VP8IteratorReset()" 2016-09-13 04:47:51 +00:00
hui su
ffd01929f1 Refactor VP8IteratorNext().
Change-Id: I7055d3ee3bd7ed5e78e94ae82cb858fa7db3ddc0
2016-09-12 15:08:24 -07:00
hui su
c4f6d9c939 Remove a redundant call to InitLeft() in VP8IteratorReset()
VP8IteratorSetRow(it, 0) already did it.

Change-Id: I410e48b5205897a6a23301d8a98aa266787676c6
2016-09-12 14:41:15 -07:00
Pascal Massimino
c27d821096 Merge "smartYUV: simplify main loop" 2016-09-12 17:14:22 +00:00
Pascal Massimino
0779529616 smartYUV: simplify main loop
we don't need to centralize best_uv[] since target_uv[] and best_rgb_uv[]
are already centralized. The diff 'W' was just in the ~[-2,2] range, so
we can ignore the correction.

Overall speed-impact is not large, though. Around ~4% faster conversion.

Output with -pre 4 is expected to be slightly different

Change-Id: Ib59f033955577c49b084d0560108020f42d84102
also: remove the useless clipping in StoreGray()
2016-09-12 18:51:40 +02:00
Vincent Rabaud
c9b45863e2 Split off common lossless dsp inline functions.
Change-Id: I64f96897b11d1c21f033c7e47b21edccb5c68738
2016-09-12 17:35:08 +02:00
Pascal Massimino
490ae5b13d smartYUV: improve initial state for faster convergence
For speed reason, the 'gray' plane was initialized with the same
value for 2x2 block. But in some cases (underlying camera noise, e.g.),
it could lead to instability during iteration, noise amplification,
and visible banding.
Using a precise (but slower) initialization solves the issue, and
since the convergence is faster, we might actually gain some speed.

Change-Id: I81c42101497e7096a8f60289d710f5a3bcb0ddea
2016-09-09 18:29:32 +02:00
Pascal Massimino
894232be56 smartYUV: fix and simplify the over-zealous stop criterion
We usually need at least 2 iterations to converge
(and usually not much more after that). Only 1 was not enough.

Change-Id: Iaf802ea81afa2596f4ba045c92f5eaff61623b7b
2016-09-09 10:10:13 +02:00
Hui Su
8de08483b6 Remove unused code in webpi.h
Change-Id: If927530034cefa0da62ddfde588833aafec51d4d
2016-09-08 22:46:32 -07:00
Pascal Massimino
545c147fd8 remove mention of fragment, frgm, FRGM, etc.
demux.h still has a 'fragment' field, for historical reasons.

bumped the ABI number in mux.h

Change-Id: I73299aa2e96b1f2e44f5cebfd84c597d1db12bff
2016-09-02 14:43:12 +02:00
hui su
9e478f808e dec/vp8l.c: add assertions in EmitRescaledRowsRGBA/YUVA
Add assertions to make sure the number of lines that are imported
into rescaler is as expected.

Change-Id: I3e9e4202e696bb09f7aa54519285b6b0deb84c1a
2016-09-01 20:58:37 -07:00
James Zern
0a57ad0dc5 cosmetics: WebPSafeAlloc -> WebPSafeMalloc
Change-Id: I0c47b827cadc18cf739f1648c605311c9bc41375
2016-08-30 18:34:37 -07:00
James Zern
0a4699bcc9 Merge "WebPPictureDistortion(): free() -> WebPSafeFree()" 2016-08-31 01:27:06 +00:00
hui su
29fedbf58b Anim_encoder: correctly handle enc->prev_candidate_undecided_
Set enc->prev_candidate_undecided_ as 0 when a frame is not chosen
as a possible keyframe, so that the dispose method can be
dispose-to-background.

Change-Id: If2899f5dbc06fb53705fb8240072ab6440a6de12
2016-08-30 15:25:09 -07:00
Pascal Massimino
32dead4ee3 WebPPictureDistortion(): free() -> WebPSafeFree()
missed one!

Change-Id: I643170451b3ac07c748b70a9abfe8af17a716b24
2016-08-30 15:43:23 +02:00
Vincent Rabaud
85cd5d061c Smarter LZ77 for uniform regions.
No need to find backward references for pixels in uniform regions
by looking at all pixels.
Only pixels at the same distance from the end need to be compared to.

Change-Id: I4f187e965f0667d3a929775726a412f7e69f6473
2016-08-26 09:53:49 +02:00
Pascal Massimino
6585075f8a Change PixelsAreSimilar() to handle black pixels correctly.
if src_{r,g,b} = 0, any value of src_a or dst_a such that
   abs(src_a - dst_a) <= max_allowed_diff
was making the test pass, despite being very different-looking pixels.

The fix is to require same values for src_a and dst_a before attempting
an r/g/b comparison.

Change-Id: If3a55a229eab3904ed454f20065e49e35c39f25c
2016-08-25 07:33:18 +02:00
Vincent Rabaud
7f1b897bee Faster stochastic histogram merging.
Constants are such that brute force is sometimes faster for some
data (mostly big images it seems).

Change-Id: I90aef536408683535e3b09ddfa2e77a9834038f6
2016-08-19 14:52:57 +02:00
Pascal Massimino
3884972e3f remove WEBP_FORCE_ALIGNED and use memcpy() instead.
BUG=webp:297

Change-Id: I89a08debec7bb1b3f411c897260ab1bb63f77df2
2016-08-17 20:16:03 -07:00
James Zern
005e15b10a Merge "{extras,mux}/Makefile.am: add missing -lm" 2016-08-17 18:18:39 +00:00
skal
6ab496ed22 fix some 'unsigned integer overflow' warnings in ubsan
I couldn't find a safe way of fixing VP8GetSigned() so i just
used the big-hammer.

Change-Id: I1039bc00307d1c90c85909a458a4bc70670e48b7
2016-08-16 23:18:27 -07:00
James Zern
8a4ebc6ab0 Revert "fix 'unsigned integer overflow' warnings in ubsan"
This reverts commit e44f5248ff.

contains unintentional changes in quant.c

Change-Id: I1928f072566788b0c9ea80f6fbc9e571061f9b3e
2016-08-16 16:55:56 -07:00
Pascal Massimino
9d4f209f80 Merge changes I25711dd5,I43188fab
* changes:
  Fix assertions in WebPRescalerExportRow()
  Add descriptions of default configuration in help info.
2016-08-16 22:13:23 +00:00
skal
e44f5248ff fix 'unsigned integer overflow' warnings in ubsan
I couldn't find a safe way of fixing VP8GetSigned() so i just
used the big-hammer.

Change-Id: I1039bc00307d1c90c85909a458a4bc70670e48b7
2016-08-16 15:04:41 -07:00
Hui Su
27b5d991e2 Fix assertions in WebPRescalerExportRow()
Change-Id: I25711dd54e71c90a25f7b18e0ef9155e8151a15e
2016-08-16 14:32:48 -07:00
James Zern
aaf2530cc3 {extras,mux}/Makefile.am: add missing -lm
+ libwebpmux.pc

quality_estimate.c, anim_encode.c rely on functions from math.h

BUG=webp:306

Change-Id: I3a8eb48febfd52bfbeb04f4dc615ccbed72926f7
2016-08-15 22:32:46 -07:00
hui su
1269dc7cfb Refactor VP8LColorCacheContains()
Return key/index if the query is found, and -1 otherwise.
The benefit of this is to save a hashing computation.

Change-Id: Iff056be330f5fb8204011259ac814f7677dd40fe
2016-08-12 15:16:06 -07:00
James Zern
40872fb2e6 dec_neon,NeedsHev: micro optimization
trade 2 compares + 1 logical or for max + compare

Change-Id: I785ad8efdc64db2d0609456d6e7af795ab2117d8
2016-08-08 20:12:30 -07:00
James Zern
b551e587b3 cosmetics: add {}s on continued control statements
for consistency within the codebase. in some cases simply join the
lines.

Change-Id: I071f061052e274c8a69f651ed4305befb4414a40
2016-08-03 19:08:59 -07:00