diff options
author | Martin Vignali <martin.vignali@gmail.com> | 2017-12-02 18:32:05 +0100 |
---|---|---|
committer | Martin Vignali <martin.vignali@gmail.com> | 2017-12-09 15:12:54 +0100 |
commit | 001173b8ff8eae862822fdfb101ce3cc15372937 (patch) | |
tree | 80c2551e780a986166bd1faff6778c85c4d770ac /libavcodec | |
parent | 57877f2b449f265ae1dd070b46aaadff4f0b3e34 (diff) | |
download | ffmpeg-001173b8ff8eae862822fdfb101ce3cc15372937.tar.gz |
avcodec/huffyuvenc : remove code duplication in sub_left_prediction
start of the line (before dsp call), can be merge with width < 32 part
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/huffyuvenc.c | 48 |
1 files changed, 18 insertions, 30 deletions
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c index 4f3a28e033..6e2e83bd3e 100644 --- a/libavcodec/huffyuvenc.c +++ b/libavcodec/huffyuvenc.c @@ -52,42 +52,30 @@ static inline int sub_left_prediction(HYuvContext *s, uint8_t *dst, const uint8_t *src, int w, int left) { int i; + int min_width = FFMIN(w, 32); + if (s->bps <= 8) { - if (w < 32) { - for (i = 0; i < w; i++) { - const int temp = src[i]; - dst[i] = temp - left; - left = temp; - } - return left; - } else { - for (i = 0; i < 32; i++) { - const int temp = src[i]; - dst[i] = temp - left; - left = temp; - } - s->llvidencdsp.diff_bytes(dst + 32, src + 32, src + 31, w - 32); - return src[w-1]; + for (i = 0; i < min_width; i++) { /* scalar loop before dsp call */ + const int temp = src[i]; + dst[i] = temp - left; + left = temp; } + if (w < 32) + return left; + s->llvidencdsp.diff_bytes(dst + 32, src + 32, src + 31, w - 32); + return src[w-1]; } else { const uint16_t *src16 = (const uint16_t *)src; uint16_t *dst16 = ( uint16_t *)dst; - if (w < 32) { - for (i = 0; i < w; i++) { - const int temp = src16[i]; - dst16[i] = temp - left; - left = temp; - } - return left; - } else { - for (i = 0; i < 32; i++) { - const int temp = src16[i]; - dst16[i] = temp - left; - left = temp; - } - s->hencdsp.diff_int16(dst16 + 32, src16 + 32, src16 + 31, s->n - 1, w - 32); - return src16[w-1]; + for (i = 0; i < min_width; i++) { /* scalar loop before dsp call */ + const int temp = src16[i]; + dst16[i] = temp - left; + left = temp; } + if (w < 32) + return left; + s->hencdsp.diff_int16(dst16 + 32, src16 + 32, src16 + 31, s->n - 1, w - 32); + return src16[w-1]; } } |