[FFmpeg-devel] [PATCH 1/4] zmbvenc: don't sum the entropy when blocks are equal

Matthew Fearnley matthew.w.fearnley at gmail.com
Sat Dec 22 17:32:16 EET 2018


> On 22 Dec 2018, at 12:11, Tomas Härdin <tjoppen at acc.umu.se> wrote:
> 
> tor 2018-12-20 klockan 17:46 +0000 skrev Matthew Fearnley:
>>>> On Thu, 20 Dec 2018 at 16:30, Tomas Härdin <tjoppen at acc.umu.se> wrote:
>>> 
>>> I have a feeling this could be sped up further by just doing *xored =
>>> histogram[0] == ZMBV_BLOCK*ZMBV_BLOCK after the loops, if [PATCH 3/4]
>>> is applied before this. Computing both histogram and xored in the loop
>>> seems pointless.
>>> 
>> 
>> You're right, that speedup didn't occur to me.  It makes the logic a bit
>> more tenuous, but it would be more efficient.
> 
> Eh, I wouldn't really call "we have xored data to output if and only if
> number of zeroes < number of pixel" fairly easy to grasp. A comment
> might be good tho
Agreed.
Just have to get the patch order sorted out now somehow.
>> Note that bw,bh aren't guaranteed to equal ZMBV_BLOCK, so `histogram[0] ==
>> bw*bh` would have to be used to guard against those (literal) edge cases.
> 
> Right, yes. But if we have block sizes other than ZMBV_BLOCK^2 then we
> need score tables for those sizes too.
I’ve thought about that a bit. I wondered if it would be worth it given:
- the extra code, memory and logic needed
- it would only improve the edge blocks
- the existing score table isn’t catastrophically bad for short blocks, and would still favour blocks with more common pixels.

It would be better from a correctness perspective though, and effects on running time should be negligible.

I can work on a patch, see how it looks.


More information about the ffmpeg-devel mailing list