summaryrefslogtreecommitdiffstats
path: root/libass/ass_func_template.h
diff options
context:
space:
mode:
authorDr.Smile <vabnick@gmail.com>2015-06-26 02:14:21 +0300
committerDr.Smile <vabnick@gmail.com>2015-06-26 02:14:21 +0300
commit38a175cad5a894467cb7187ad0187db1ae3f89ff (patch)
treea7262be6620f31c2f0d8df26218c6160c5354f56 /libass/ass_func_template.h
parent88f1fd37fe5785851f069e3dc6939f1ab905f4bc (diff)
downloadlibass-38a175cad5a894467cb7187ad0187db1ae3f89ff.tar.bz2
libass-38a175cad5a894467cb7187ad0187db1ae3f89ff.tar.xz
Switch to virtual function table
Use one pointer to table of functions instead of scattered bunch of function pointers. Different versions of these tables can be constructed in compile time. Also, bitmap memory alignment now depends only on SSE2/AVX2 support and is constant for every width. That simplifies code without noticeable performance penalty.
Diffstat (limited to 'libass/ass_func_template.h')
-rw-r--r--libass/ass_func_template.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/libass/ass_func_template.h b/libass/ass_func_template.h
new file mode 100644
index 0000000..6ffc730
--- /dev/null
+++ b/libass/ass_func_template.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2015 Vabishchevich Nikolay <vabnick@gmail.com>
+ *
+ * This file is part of libass.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+
+
+void DECORATE(fill_solid_tile16)(uint8_t *buf, ptrdiff_t stride, int set);
+void DECORATE(fill_solid_tile32)(uint8_t *buf, ptrdiff_t stride, int set);
+void DECORATE(fill_halfplane_tile16)(uint8_t *buf, ptrdiff_t stride,
+ int32_t a, int32_t b, int64_t c, int32_t scale);
+void DECORATE(fill_halfplane_tile32)(uint8_t *buf, ptrdiff_t stride,
+ int32_t a, int32_t b, int64_t c, int32_t scale);
+void DECORATE(fill_generic_tile16)(uint8_t *buf, ptrdiff_t stride,
+ const struct segment *line, size_t n_lines,
+ int winding);
+void DECORATE(fill_generic_tile32)(uint8_t *buf, ptrdiff_t stride,
+ const struct segment *line, size_t n_lines,
+ int winding);
+
+void DECORATE(add_bitmaps)(uint8_t *dst, intptr_t dst_stride,
+ uint8_t *src, intptr_t src_stride,
+ intptr_t height, intptr_t width);
+void DECORATE(sub_bitmaps)(uint8_t *dst, intptr_t dst_stride,
+ uint8_t *src, intptr_t src_stride,
+ intptr_t height, intptr_t width);
+void DECORATE(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 DECORATE(be_blur)(uint8_t *buf, intptr_t w, intptr_t h,
+ intptr_t stride, uint16_t *tmp);
+
+
+const BitmapEngine DECORATE(bitmap_engine) = {
+ .align_order = ALIGN,
+
+#if CONFIG_RASTERIZER
+#if CONFIG_LARGE_TILES
+ .tile_order = 5,
+ .fill_solid = DECORATE(fill_solid_tile32),
+ .fill_halfplane = DECORATE(fill_halfplane_tile32),
+ .fill_generic = DECORATE(fill_generic_tile32),
+#else
+ .tile_order = 4,
+ .fill_solid = DECORATE(fill_solid_tile16),
+ .fill_halfplane = DECORATE(fill_halfplane_tile16),
+ .fill_generic = DECORATE(fill_generic_tile16),
+#endif
+#endif
+
+ .add_bitmaps = DECORATE(add_bitmaps),
+#ifdef __x86_64__
+ .sub_bitmaps = DECORATE(sub_bitmaps),
+ .mul_bitmaps = DECORATE(mul_bitmaps),
+#else
+ .sub_bitmaps = ass_sub_bitmaps_c,
+ .mul_bitmaps = ass_mul_bitmaps_c,
+#endif
+
+#ifdef __x86_64__
+ .be_blur = DECORATE(be_blur),
+#else
+ .be_blur = ass_be_blur_c,
+#endif
+};