FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavfilter/x86/vf_spp.c
Date: 2025-11-03 03:39:10
Exec Total Coverage
Lines: 4 14 28.6%
Functions: 1 2 50.0%
Branches: 1 4 25.0%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #include <stdint.h>
22
23 #include "config.h"
24 #include "libavutil/attributes.h"
25 #include "libavutil/cpu.h"
26 #include "libavutil/x86/asm.h"
27 #include "libavutil/x86/cpu.h"
28 #include "libavfilter/vf_spp.h"
29
30 #if HAVE_SSE2_INLINE
31 static void store_slice_sse2(uint8_t *dst, const int16_t *src,
32 int dst_stride, int src_stride,
33 int width, int height, int log2_scale,
34 const uint8_t dither[8][8])
35 {
36 int y;
37
38 for (y = 0; y < height; y++) {
39 uint8_t *dst1 = dst;
40 const int16_t *src1 = src;
41 __asm__ volatile(
42 "movq (%3), %%xmm1 \n"
43 "movd %4, %%xmm2 \n"
44 "pxor %%xmm0, %%xmm0 \n"
45 "punpcklbw %%xmm0, %%xmm1 \n"
46 "psraw %%xmm2, %%xmm1 \n"
47 "movd %5, %%xmm2 \n"
48 "1: \n"
49 "movdqa (%0), %%xmm0 \n"
50 "paddw %%xmm1, %%xmm0 \n"
51 "psraw %%xmm2, %%xmm0 \n"
52 "packuswb %%xmm0, %%xmm0 \n"
53 "movq %%xmm0, (%1) \n"
54 "add $16, %0 \n"
55 "add $8, %1 \n"
56 "cmp %2, %1 \n"
57 " jb 1b \n"
58 : "+r" (src1), "+r"(dst1)
59 : "r"(dst + width), "r"(dither[y]), "g"(log2_scale), "g"(MAX_LEVEL - log2_scale)
60 XMM_CLOBBERS_ONLY("%xmm0", "%xmm1", "%xmm2")
61 );
62 src += src_stride;
63 dst += dst_stride;
64 }
65 }
66
67 #endif /* HAVE_MMX_INLINE */
68
69 1 av_cold void ff_spp_init_x86(SPPContext *s)
70 {
71 #if HAVE_SSE2_INLINE
72 1 int cpu_flags = av_get_cpu_flags();
73
74
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (INLINE_SSE2(cpu_flags)) {
75 s->store_slice = store_slice_sse2;
76 }
77 #endif
78 1 }
79