diff options
Diffstat (limited to 'libass')
-rw-r--r-- | libass/ass_bitmap_engine.h | 14 | ||||
-rw-r--r-- | libass/c/c_blend_bitmaps.c | 41 | ||||
-rw-r--r-- | libass/x86/blend_bitmaps.asm | 20 |
3 files changed, 37 insertions, 38 deletions
diff --git a/libass/ass_bitmap_engine.h b/libass/ass_bitmap_engine.h index 71750318..36829848 100644 --- a/libass/ass_bitmap_engine.h +++ b/libass/ass_bitmap_engine.h @@ -31,13 +31,13 @@ typedef void FillGenericTileFunc(uint8_t *buf, ptrdiff_t stride, int winding); typedef void MergeTileFunc(uint8_t *buf, ptrdiff_t stride, const uint8_t *tile); -typedef void BitmapBlendFunc(uint8_t *dst, intptr_t dst_stride, - uint8_t *src, intptr_t src_stride, - intptr_t width, intptr_t height); -typedef void BitmapMulFunc(uint8_t *dst, intptr_t dst_stride, - uint8_t *src1, intptr_t src1_stride, - uint8_t *src2, intptr_t src2_stride, - intptr_t width, intptr_t height); +typedef void BitmapBlendFunc(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + size_t width, size_t height); +typedef void BitmapMulFunc(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src1, ptrdiff_t src1_stride, + const uint8_t *src2, ptrdiff_t src2_stride, + size_t width, size_t height); typedef void BeBlurFunc(uint8_t *buf, intptr_t stride, intptr_t width, intptr_t height, uint16_t *tmp); diff --git a/libass/c/c_blend_bitmaps.c b/libass/c/c_blend_bitmaps.c index 9cebcc82..95d189e3 100644 --- a/libass/c/c_blend_bitmaps.c +++ b/libass/c/c_blend_bitmaps.c @@ -29,44 +29,43 @@ * \brief Add two bitmaps together at a given position * Uses additive blending, clipped to [0,255]. Pure C implementation. */ -void ass_add_bitmaps_c(uint8_t *dst, intptr_t dst_stride, - uint8_t *src, intptr_t src_stride, - intptr_t width, intptr_t height) +void ass_add_bitmaps_c(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + size_t width, size_t height) { - unsigned out; - uint8_t* end = dst + dst_stride * height; + uint8_t *end = dst + dst_stride * height; while (dst < end) { - for (unsigned j = 0; j < width; ++j) { - out = dst[j] + src[j]; - dst[j] = FFMIN(out, 255); + for (size_t x = 0; x < width; x++) { + unsigned out = dst[x] + src[x]; + dst[x] = FFMIN(out, 255); } dst += dst_stride; src += src_stride; } } -void ass_imul_bitmaps_c(uint8_t *dst, intptr_t dst_stride, - uint8_t *src, intptr_t src_stride, - intptr_t width, intptr_t height) +void ass_imul_bitmaps_c(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src, ptrdiff_t src_stride, + size_t width, size_t height) { - uint8_t* end = dst + dst_stride * height; + uint8_t *end = dst + dst_stride * height; while (dst < end) { - for (unsigned j = 0; j < width; ++j) { - dst[j] = (dst[j] * (255 - src[j]) + 255) >> 8; + for (size_t x = 0; x < width; x++) { + dst[x] = (dst[x] * (255 - src[x]) + 255) >> 8; } dst += dst_stride; src += src_stride; } } -void ass_mul_bitmaps_c(uint8_t *dst, intptr_t dst_stride, - uint8_t *src1, intptr_t src1_stride, - uint8_t *src2, intptr_t src2_stride, - intptr_t width, intptr_t height) +void ass_mul_bitmaps_c(uint8_t *dst, ptrdiff_t dst_stride, + const uint8_t *src1, ptrdiff_t src1_stride, + const uint8_t *src2, ptrdiff_t src2_stride, + size_t width, size_t height) { - uint8_t* end = src1 + src1_stride * height; - while (src1 < end) { - for (unsigned x = 0; x < width; ++x) { + uint8_t *end = dst + dst_stride * height; + while (dst < end) { + for (size_t x = 0; x < width; x++) { dst[x] = (src1[x] * src2[x] + 255) >> 8; } dst += dst_stride; diff --git a/libass/x86/blend_bitmaps.asm b/libass/x86/blend_bitmaps.asm index e5b87604..cc4b81d9 100644 --- a/libass/x86/blend_bitmaps.asm +++ b/libass/x86/blend_bitmaps.asm @@ -61,9 +61,9 @@ SECTION .text ;------------------------------------------------------------------------------ ; ADD_BITMAPS -; void add_bitmaps(uint8_t *dst, intptr_t dst_stride, -; uint8_t *src, intptr_t src_stride, -; intptr_t width, intptr_t height); +; void add_bitmaps(uint8_t *dst, ptrdiff_t dst_stride, +; const uint8_t *src, ptrdiff_t src_stride, +; size_t width, size_t height); ;------------------------------------------------------------------------------ %macro ADD_BITMAPS 0 @@ -114,9 +114,9 @@ ADD_BITMAPS ;------------------------------------------------------------------------------ ; IMUL_BITMAPS -; void imul_bitmaps(uint8_t *dst, intptr_t dst_stride, -; uint8_t *src, intptr_t src_stride, -; intptr_t width, intptr_t height); +; void imul_bitmaps(uint8_t *dst, ptrdiff_t dst_stride, +; const uint8_t *src, ptrdiff_t src_stride, +; size_t width, size_t height); ;------------------------------------------------------------------------------ %macro IMUL_BITMAPS 0 @@ -197,10 +197,10 @@ IMUL_BITMAPS ;------------------------------------------------------------------------------ ; MUL_BITMAPS -; void mul_bitmaps(uint8_t *dst, intptr_t dst_stride, -; uint8_t *src1, intptr_t src1_stride, -; uint8_t *src2, intptr_t src2_stride, -; intptr_t width, intptr_t height); +; void mul_bitmaps(uint8_t *dst, ptrdiff_t dst_stride, +; const uint8_t *src1, ptrdiff_t src1_stride, +; const uint8_t *src2, ptrdiff_t src2_stride, +; size_t width, size_t height); ;------------------------------------------------------------------------------ %macro MUL_BITMAPS 0 |