summaryrefslogtreecommitdiffstats
path: root/libass
diff options
context:
space:
mode:
authorDr.Smile <vabnick@gmail.com>2021-12-05 09:34:48 +0300
committerDr.Smile <vabnick@gmail.com>2022-12-04 02:17:38 +0300
commitfceed8c028e0afc8e6860ad21d6d463f6a080043 (patch)
treead21d8891b8f3b5ae3ad2084816abae6b25c22f3 /libass
parent8ef5d7ba205e623af64fe011a5489f7dcd5ab07b (diff)
downloadlibass-fceed8c028e0afc8e6860ad21d6d463f6a080043.tar.bz2
libass-fceed8c028e0afc8e6860ad21d6d463f6a080043.tar.xz
blend_bitmaps: cosmetic refactoring
All intptr_t would be gradually replaced with more logically correct ptrdiff_t/size_t. It clearly signifies its intended use and should work even for obscure architectures with sizeof(size_t) != sizeof(void *). For generic architectures it's essentially the same and is a part of ABI.
Diffstat (limited to 'libass')
-rw-r--r--libass/ass_bitmap_engine.h14
-rw-r--r--libass/c/c_blend_bitmaps.c41
-rw-r--r--libass/x86/blend_bitmaps.asm20
3 files changed, 37 insertions, 38 deletions
diff --git a/libass/ass_bitmap_engine.h b/libass/ass_bitmap_engine.h
index 7175031..3682984 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 9cebcc8..95d189e 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 e5b8760..cc4b81d 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