Coverage Report

Created: 2026-10-17 07:10

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libass/libass/c/c_blur.c
Line
Count
Source
1
/*
2
 * Copyright (C) 2015-2022 libass contributors
3
 *
4
 * This file is part of libass.
5
 *
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.
9
 *
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.
17
 */
18
19
#include "config.h"
20
#include "ass_compat.h"
21
#include "ass_utils.h"
22
23
#include <stddef.h>
24
#include <stdint.h>
25
#include <memory.h>
26
27
28
static int16_t zero_line[16];
29
static int16_t dither_line[32] = {
30
     8, 40,  8, 40,  8, 40,  8, 40,  8, 40,  8, 40,  8, 40,  8, 40,
31
    56, 24, 56, 24, 56, 24, 56, 24, 56, 24, 56, 24, 56, 24, 56, 24,
32
};
33
34
inline static const int16_t *get_line(const int16_t *ptr, size_t offs, size_t size)
35
250k
{
36
250k
    return offs < size ? ptr + offs : zero_line;
37
250k
}
38
39
static inline int16_t shrink_func(int16_t p1p, int16_t p1n,
40
                                  int16_t z0p, int16_t z0n,
41
                                  int16_t n1p, int16_t n1n)
42
2.99k
{
43
    /*
44
    return (1 * p1p + 5 * p1n + 10 * z0p + 10 * z0n + 5 * n1p + 1 * n1n + 16) >> 5;
45
    */
46
2.99k
    int32_t r = (p1p + p1n + n1p + n1n) >> 1;
47
2.99k
    r = (r + z0p + z0n) >> 1;
48
2.99k
    r = (r + p1n + n1p) >> 1;
49
2.99k
    return (r + z0p + z0n + 2) >> 2;
50
2.99k
}
51
52
static inline void expand_func(int16_t *rp, int16_t *rn,
53
                               int16_t p1, int16_t z0, int16_t n1)
54
655k
{
55
    /*
56
    *rp = (5 * p1 + 10 * z0 + 1 * n1 + 8) >> 4;
57
    *rn = (1 * p1 + 10 * z0 + 5 * n1 + 8) >> 4;
58
    */
59
655k
    uint16_t r = (uint16_t) (((uint16_t) (p1 + n1) >> 1) + z0) >> 1;
60
655k
    *rp = (uint16_t) (((uint16_t) (r + p1) >> 1) + z0 + 1) >> 1;
61
655k
    *rn = (uint16_t) (((uint16_t) (r + n1) >> 1) + z0 + 1) >> 1;
62
655k
}
63
64
65
2.68M
#define ALIGNMENT     16
66
5.19k
#define SUFFIX(name)  name ## 16_c
67
#include "blur_template.h"
68
#undef ALIGNMENT
69
#undef SUFFIX
70
71
0
#define ALIGNMENT     32
72
0
#define SUFFIX(name)  name ## 32_c
73
#include "blur_template.h"
74
#undef ALIGNMENT
75
#undef SUFFIX