GCC Code Coverage Report
Directory: ../../../ffmpeg/ Exec Total Coverage
File: src/libavcodec/utvideodsp.c Lines: 17 28 60.7 %
Date: 2020-10-23 17:01:47 Branches: 4 8 50.0 %

Line Branch Exec Source
1
/*
2
 * This file is part of FFmpeg.
3
 *
4
 * FFmpeg is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Lesser General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2.1 of the License, or (at your option) any later version.
8
 *
9
 * FFmpeg is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
15
 * License along with FFmpeg; if not, write to the Free Software
16
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
 */
18
19
#include <stdint.h>
20
21
#include "config.h"
22
#include "libavutil/attributes.h"
23
#include "utvideodsp.h"
24
25
28
static void restore_rgb_planes_c(uint8_t *src_r,
26
                                 uint8_t *src_g,
27
                                 uint8_t *src_b,
28
                                 ptrdiff_t linesize_r,
29
                                 ptrdiff_t linesize_g,
30
                                 ptrdiff_t linesize_b,
31
                                 int width, int height)
32
{
33
    uint8_t r, g, b;
34
    int i, j;
35
36
12449
    for (j = 0; j < height; j++) {
37
8179166
        for (i = 0; i < width; i++) {
38
8166745
            r = src_r[i];
39
8166745
            g = src_g[i];
40
8166745
            b = src_b[i];
41
8166745
            src_r[i] = r + g - 0x80;
42
8166745
            src_b[i] = b + g - 0x80;
43
        }
44
12421
        src_r += linesize_r;
45
12421
        src_g += linesize_g;
46
12421
        src_b += linesize_b;
47
    }
48
28
}
49
50
static void restore_rgb_planes10_c(uint16_t *src_r,
51
                                   uint16_t *src_g,
52
                                   uint16_t *src_b,
53
                                   ptrdiff_t linesize_r,
54
                                   ptrdiff_t linesize_g,
55
                                   ptrdiff_t linesize_b,
56
                                   int width, int height)
57
{
58
    int r, g, b;
59
    int i, j;
60
61
    for (j = 0; j < height; j++) {
62
        for (i = 0; i < width; i++) {
63
            r = src_r[i];
64
            g = src_g[i];
65
            b = src_b[i];
66
            src_r[i] = (r + g - 0x200) & 0x3FF;
67
            src_b[i] = (b + g - 0x200) & 0x3FF;
68
        }
69
        src_r += linesize_r;
70
        src_g += linesize_g;
71
        src_b += linesize_b;
72
    }
73
}
74
75
46
av_cold void ff_utvideodsp_init(UTVideoDSPContext *c)
76
{
77
46
    c->restore_rgb_planes   = restore_rgb_planes_c;
78
46
    c->restore_rgb_planes10 = restore_rgb_planes10_c;
79
80
    if (ARCH_X86)
81
46
        ff_utvideodsp_init_x86(c);
82
46
}