2 * Copyright (C) 2006 Evgeniy Stepanov <eugeni.stepanov@gmail.com>
4 * This file is part of libass.
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #ifndef LIBASS_BITMAP_H
20 #define LIBASS_BITMAP_H
27 #include "ass_outline.h"
31 typedef void (*FillSolidTileFunc)(uint8_t *buf, ptrdiff_t stride, int set);
32 typedef void (*FillHalfplaneTileFunc)(uint8_t *buf, ptrdiff_t stride,
33 int32_t a, int32_t b, int64_t c, int32_t scale);
34 typedef void (*FillGenericTileFunc)(uint8_t *buf, ptrdiff_t stride,
35 const struct segment *line, size_t n_lines,
38 typedef void (*BitmapBlendFunc)(uint8_t *dst, intptr_t dst_stride,
39 uint8_t *src, intptr_t src_stride,
40 intptr_t height, intptr_t width);
41 typedef void (*BitmapMulFunc)(uint8_t *dst, intptr_t dst_stride,
42 uint8_t *src1, intptr_t src1_stride,
43 uint8_t *src2, intptr_t src2_stride,
44 intptr_t width, intptr_t height);
46 typedef void (*BeBlurFunc)(uint8_t *buf, intptr_t w, intptr_t h,
47 intptr_t stride, uint16_t *tmp);
49 // intermediate bitmaps represented as sets of verical stripes of int16_t[alignment / 2]
50 typedef void (*Convert8to16Func)(int16_t *dst, const uint8_t *src, ptrdiff_t src_stride,
51 uintptr_t width, uintptr_t height);
52 typedef void (*Convert16to8Func)(uint8_t *dst, ptrdiff_t dst_stride, const int16_t *src,
53 uintptr_t width, uintptr_t height);
54 typedef void (*FilterFunc)(int16_t *dst, const int16_t *src,
55 uintptr_t src_width, uintptr_t src_height);
56 typedef void (*ParamFilterFunc)(int16_t *dst, const int16_t *src,
57 uintptr_t src_width, uintptr_t src_height,
58 const int16_t *param);
60 #define C_ALIGN_ORDER 5
63 int align_order; // log2(alignment)
65 // rasterizer functions
66 int tile_order; // log2(tile_size)
67 FillSolidTileFunc fill_solid;
68 FillHalfplaneTileFunc fill_halfplane;
69 FillGenericTileFunc fill_generic;
72 BitmapBlendFunc add_bitmaps, sub_bitmaps;
73 BitmapMulFunc mul_bitmaps;
78 // gaussian blur functions
79 Convert8to16Func stripe_unpack;
80 Convert16to8Func stripe_pack;
81 FilterFunc shrink_horz, shrink_vert;
82 FilterFunc expand_horz, expand_vert;
83 FilterFunc pre_blur_horz[3], pre_blur_vert[3];
84 ParamFilterFunc main_blur_horz[3], main_blur_vert[3];
87 extern const BitmapEngine ass_bitmap_engine_c;
88 extern const BitmapEngine ass_bitmap_engine_sse2;
89 extern const BitmapEngine ass_bitmap_engine_avx2;
94 int w, h; // width, height
96 unsigned char *buffer; // h * stride buffer
99 Bitmap *alloc_bitmap(const BitmapEngine *engine, int w, int h, bool zero);
100 bool realloc_bitmap(const BitmapEngine *engine, Bitmap *bm, int w, int h);
101 Bitmap *copy_bitmap(const BitmapEngine *engine, const Bitmap *src);
102 void ass_free_bitmap(Bitmap *bm);
104 Bitmap *outline_to_bitmap(ASS_Renderer *render_priv,
105 ASS_Outline *outline1, ASS_Outline *outline2,
108 void ass_synth_blur(const BitmapEngine *engine, int opaque_box, int be,
109 double blur_radius, Bitmap *bm_g, Bitmap *bm_o);
111 int be_padding(int be);
112 void be_blur_pre(uint8_t *buf, intptr_t w,
113 intptr_t h, intptr_t stride);
114 void be_blur_post(uint8_t *buf, intptr_t w,
115 intptr_t h, intptr_t stride);
116 bool ass_gaussian_blur(const BitmapEngine *engine, Bitmap *bm, double r2);
117 void shift_bitmap(Bitmap *bm, int shift_x, int shift_y);
118 void fix_outline(Bitmap *bm_g, Bitmap *bm_o);
120 #endif /* LIBASS_BITMAP_H */