X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fhuffyuvdsp.c;h=e770923bb22d05ede83f11822e10682cb5399df8;hb=54d839e80a06ed7c195ed0b60af3cd7a744e7085;hp=e8a05f6592a6d444eafad75dbfe24a016b9d7c28;hpb=bebab21176c1f052f748cfb2384cc01e0bdb13f4;p=ffmpeg diff --git a/libavcodec/huffyuvdsp.c b/libavcodec/huffyuvdsp.c index e8a05f6592a..e770923bb22 100644 --- a/libavcodec/huffyuvdsp.c +++ b/libavcodec/huffyuvdsp.c @@ -23,36 +23,32 @@ #include "mathops.h" #include "huffyuvdsp.h" -// 0x7f7f7f7f or 0x7f7f7f7f7f7f7f7f or whatever, depending on the cpu's native arithmetic size -#define pb_7f (~0UL / 255 * 0x7f) -#define pb_80 (~0UL / 255 * 0x80) +// 0x00010001 or 0x0001000100010001 or whatever, depending on the cpu's native arithmetic size +#define pw_1 (ULONG_MAX / UINT16_MAX) -static void add_bytes_c(uint8_t *dst, uint8_t *src, intptr_t w) -{ +static void add_int16_c(uint16_t *dst, const uint16_t *src, unsigned mask, int w){ long i; - - for (i = 0; i <= w - (int) sizeof(long); i += sizeof(long)) { - long a = *(long *) (src + i); - long b = *(long *) (dst + i); - *(long *) (dst + i) = ((a & pb_7f) + (b & pb_7f)) ^ ((a ^ b) & pb_80); + unsigned long pw_lsb = (mask >> 1) * pw_1; + unsigned long pw_msb = pw_lsb + pw_1; + for (i = 0; i <= w - (int)sizeof(long)/2; i += sizeof(long)/2) { + long a = *(long*)(src+i); + long b = *(long*)(dst+i); + *(long*)(dst+i) = ((a&pw_lsb) + (b&pw_lsb)) ^ ((a^b)&pw_msb); } - for (; i < w; i++) - dst[i + 0] += src[i + 0]; + for(; iadd_bytes = add_bytes_c; - c->add_hfyu_median_pred = add_hfyu_median_pred_c; - c->add_hfyu_left_pred = add_hfyu_left_pred_c; + c->add_int16 = add_int16_c; + c->add_hfyu_median_pred_int16 = add_hfyu_median_pred_int16_c; c->add_hfyu_left_pred_bgr32 = add_hfyu_left_pred_bgr32_c; if (ARCH_X86) - ff_huffyuvdsp_init_x86(c); + ff_huffyuvdsp_init_x86(c, avctx); }