FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/x86/h264chroma_init.c
Date: 2024-11-20 23:03:26
Exec Total Coverage
Lines: 28 28 100.0%
Functions: 1 1 100.0%
Branches: 27 30 90.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 "libavutil/cpu.h"
24 #include "libavutil/x86/cpu.h"
25 #include "libavcodec/h264chroma.h"
26
27 void ff_put_h264_chroma_mc8_rnd_mmx (uint8_t *dst, const uint8_t *src,
28 ptrdiff_t stride, int h, int x, int y);
29 void ff_avg_h264_chroma_mc8_rnd_mmxext(uint8_t *dst, const uint8_t *src,
30 ptrdiff_t stride, int h, int x, int y);
31
32 void ff_put_h264_chroma_mc4_mmx (uint8_t *dst, const uint8_t *src,
33 ptrdiff_t stride, int h, int x, int y);
34 void ff_avg_h264_chroma_mc4_mmxext (uint8_t *dst, const uint8_t *src,
35 ptrdiff_t stride, int h, int x, int y);
36
37 void ff_put_h264_chroma_mc2_mmxext (uint8_t *dst, const uint8_t *src,
38 ptrdiff_t stride, int h, int x, int y);
39 void ff_avg_h264_chroma_mc2_mmxext (uint8_t *dst, const uint8_t *src,
40 ptrdiff_t stride, int h, int x, int y);
41
42 void ff_put_h264_chroma_mc8_rnd_ssse3(uint8_t *dst, const uint8_t *src,
43 ptrdiff_t stride, int h, int x, int y);
44 void ff_put_h264_chroma_mc4_ssse3 (uint8_t *dst, const uint8_t *src,
45 ptrdiff_t stride, int h, int x, int y);
46
47 void ff_avg_h264_chroma_mc8_rnd_ssse3(uint8_t *dst, const uint8_t *src,
48 ptrdiff_t stride, int h, int x, int y);
49 void ff_avg_h264_chroma_mc4_ssse3 (uint8_t *dst, const uint8_t *src,
50 ptrdiff_t stride, int h, int x, int y);
51
52 #define CHROMA_MC(OP, NUM, DEPTH, OPT) \
53 void ff_ ## OP ## _h264_chroma_mc ## NUM ## _ ## DEPTH ## _ ## OPT \
54 (uint8_t *dst, const uint8_t *src, \
55 ptrdiff_t stride, int h, int x, int y);
56
57 CHROMA_MC(put, 2, 10, mmxext)
58 CHROMA_MC(avg, 2, 10, mmxext)
59 CHROMA_MC(put, 4, 10, mmxext)
60 CHROMA_MC(avg, 4, 10, mmxext)
61 CHROMA_MC(put, 8, 10, sse2)
62 CHROMA_MC(avg, 8, 10, sse2)
63 CHROMA_MC(put, 8, 10, avx)
64 CHROMA_MC(avg, 8, 10, avx)
65
66 1336 av_cold void ff_h264chroma_init_x86(H264ChromaContext *c, int bit_depth)
67 {
68 1336 int high_bit_depth = bit_depth > 8;
69 1336 int cpu_flags = av_get_cpu_flags();
70
71
4/4
✓ Branch 0 taken 250 times.
✓ Branch 1 taken 1086 times.
✓ Branch 2 taken 214 times.
✓ Branch 3 taken 36 times.
1336 if (EXTERNAL_MMX(cpu_flags) && !high_bit_depth) {
72 214 c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_rnd_mmx;
73 214 c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_mmx;
74 }
75
76
4/4
✓ Branch 0 taken 247 times.
✓ Branch 1 taken 1089 times.
✓ Branch 2 taken 213 times.
✓ Branch 3 taken 34 times.
1336 if (EXTERNAL_MMXEXT(cpu_flags) && !high_bit_depth) {
77 213 c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_rnd_mmxext;
78 213 c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_mmxext;
79 213 c->avg_h264_chroma_pixels_tab[2] = ff_avg_h264_chroma_mc2_mmxext;
80 213 c->put_h264_chroma_pixels_tab[2] = ff_put_h264_chroma_mc2_mmxext;
81 }
82
83
5/6
✓ Branch 0 taken 247 times.
✓ Branch 1 taken 1089 times.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 213 times.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
1336 if (EXTERNAL_MMXEXT(cpu_flags) && bit_depth > 8 && bit_depth <= 10) {
84 34 c->put_h264_chroma_pixels_tab[2] = ff_put_h264_chroma_mc2_10_mmxext;
85 34 c->avg_h264_chroma_pixels_tab[2] = ff_avg_h264_chroma_mc2_10_mmxext;
86 34 c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_10_mmxext;
87 34 c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_10_mmxext;
88 }
89
90
5/6
✓ Branch 0 taken 241 times.
✓ Branch 1 taken 1095 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 211 times.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
1336 if (EXTERNAL_SSE2(cpu_flags) && bit_depth > 8 && bit_depth <= 10) {
91 30 c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_10_sse2;
92 30 c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_10_sse2;
93 }
94
95
4/4
✓ Branch 0 taken 235 times.
✓ Branch 1 taken 1101 times.
✓ Branch 2 taken 209 times.
✓ Branch 3 taken 26 times.
1336 if (EXTERNAL_SSSE3(cpu_flags) && !high_bit_depth) {
96 209 c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_rnd_ssse3;
97 209 c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_rnd_ssse3;
98 209 c->put_h264_chroma_pixels_tab[1] = ff_put_h264_chroma_mc4_ssse3;
99 209 c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_ssse3;
100 }
101
102
5/6
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 1113 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 205 times.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
1336 if (EXTERNAL_AVX(cpu_flags) && bit_depth > 8 && bit_depth <= 10) {
103 // AVX implies !cache64.
104 // TODO: Port cache(32|64) detection from x264.
105 18 c->put_h264_chroma_pixels_tab[0] = ff_put_h264_chroma_mc8_10_avx;
106 18 c->avg_h264_chroma_pixels_tab[0] = ff_avg_h264_chroma_mc8_10_avx;
107 }
108 1336 }
109