From: Matthew Fearnley <matthew.w.fearn...@gmail.com> If *xored is 0, then histogram[0]==bw*bh and histogram[1..255]==0.
Because histogram[0] is skipped over for the entropy calculation, the return value is always 0 when *xored==0, so we don't need to waste time calculating it. This addition both clarifies the behaviour of the code and improves the speed when the block matches. --- libavcodec/zmbvenc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/zmbvenc.c b/libavcodec/zmbvenc.c index 4d9147657d..2f041dae32 100644 --- a/libavcodec/zmbvenc.c +++ b/libavcodec/zmbvenc.c @@ -71,6 +71,7 @@ static inline int block_cmp(ZmbvEncContext *c, uint8_t *src, int stride, int i, j; uint8_t histogram[256] = {0}; + /* build frequency histogram of byte values for src[] ^ src2[] */ *xored = 0; for(j = 0; j < bh; j++){ for(i = 0; i < bw; i++){ @@ -82,6 +83,10 @@ static inline int block_cmp(ZmbvEncContext *c, uint8_t *src, int stride, src2 += stride2; } + /* early out if src and src2 are equal */ + if (!*xored) return 0; + + /* sum the entropy of the non-zero values */ for(i = 1; i < 256; i++) sum += c->score_tab[histogram[i]]; -- 2.17.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel