FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/x86/diracdsp_init.c
Date: 2026-01-16 07:34:38
Exec Total Coverage
Lines: 17 20 85.0%
Functions: 1 6 16.7%
Branches: 4 10 40.0%

Line Branch Exec Source
1 /*
2 * Copyright (C) 2010 David Conrad
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (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 GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #include "libavutil/x86/cpu.h"
22 #include "libavcodec/diracdsp.h"
23 #include "fpel.h"
24
25 void ff_add_rect_clamped_sse2(uint8_t *, const uint16_t *, int, const int16_t *, int, int, int);
26
27 void ff_add_dirac_obmc8_sse2(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen);
28 void ff_add_dirac_obmc16_sse2(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen);
29 void ff_add_dirac_obmc32_sse2(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen);
30
31 void ff_put_rect_clamped_sse2(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height);
32 void ff_put_signed_rect_clamped_sse2(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height);
33 void ff_put_signed_rect_clamped_10_sse4(uint8_t *dst, int dst_stride, const uint8_t *src, int src_stride, int width, int height);
34
35 void ff_dequant_subband_32_sse4(uint8_t *src, uint8_t *dst, ptrdiff_t stride, const int qf, const int qs, int tot_v, int tot_h);
36
37 #define HPEL_FILTER(MMSIZE, EXT) \
38 void ff_dirac_hpel_filter_v_ ## EXT(uint8_t *, const uint8_t *, int, int); \
39 void ff_dirac_hpel_filter_h_ ## EXT(uint8_t *, const uint8_t *, int); \
40 \
41 static void dirac_hpel_filter_ ## EXT(uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, \
42 const uint8_t *src, int stride, int width, int height) \
43 { \
44 while( height-- ) \
45 { \
46 ff_dirac_hpel_filter_v_ ## EXT(dstv-MMSIZE, src-MMSIZE, stride, width+MMSIZE+5); \
47 ff_dirac_hpel_filter_h_ ## EXT(dsth, src, width); \
48 ff_dirac_hpel_filter_h_ ## EXT(dstc, dstv, width); \
49 \
50 dsth += stride; \
51 dstv += stride; \
52 dstc += stride; \
53 src += stride; \
54 } \
55 }
56
57 #define DIRAC_PIXOP(OPNAME, EXT)\
58 static void OPNAME ## _dirac_pixels16_ ## EXT(uint8_t *dst, const uint8_t *src[5], \
59 int stride, int h) \
60 {\
61 if (h&3)\
62 ff_ ## OPNAME ## _dirac_pixels16_c(dst, src, stride, h);\
63 else\
64 ff_ ## OPNAME ## _pixels16_ ## EXT(dst, src[0], stride, h);\
65 }\
66 static void OPNAME ## _dirac_pixels32_ ## EXT(uint8_t *dst, const uint8_t *src[5], \
67 int stride, int h) \
68 {\
69 if (h&3) {\
70 ff_ ## OPNAME ## _dirac_pixels32_c(dst, src, stride, h);\
71 } else {\
72 ff_ ## OPNAME ## _pixels16_ ## EXT(dst , src[0] , stride, h);\
73 ff_ ## OPNAME ## _pixels16_ ## EXT(dst+16, src[0]+16, stride, h);\
74 }\
75 }
76
77 DIRAC_PIXOP(put, sse2)
78 DIRAC_PIXOP(avg, sse2)
79
80 HPEL_FILTER(16, sse2)
81
82 112 void ff_diracdsp_init_x86(DiracDSPContext* c)
83 {
84 112 int mm_flags = av_get_cpu_flags();
85
86
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 82 times.
112 if (EXTERNAL_SSE2(mm_flags)) {
87 30 c->dirac_hpel_filter = dirac_hpel_filter_sse2;
88 30 c->add_rect_clamped = ff_add_rect_clamped_sse2;
89 30 c->put_signed_rect_clamped[0] = (void *)ff_put_signed_rect_clamped_sse2;
90
91 30 c->add_dirac_obmc[0] = ff_add_dirac_obmc8_sse2;
92 30 c->add_dirac_obmc[1] = ff_add_dirac_obmc16_sse2;
93 30 c->add_dirac_obmc[2] = ff_add_dirac_obmc32_sse2;
94
95 30 c->put_dirac_pixels_tab[1][0] = put_dirac_pixels16_sse2;
96 30 c->avg_dirac_pixels_tab[1][0] = avg_dirac_pixels16_sse2;
97 30 c->put_dirac_pixels_tab[2][0] = put_dirac_pixels32_sse2;
98 30 c->avg_dirac_pixels_tab[2][0] = avg_dirac_pixels32_sse2;
99 }
100
101
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 91 times.
112 if (EXTERNAL_SSE4(mm_flags)) {
102 21 c->dequant_subband[1] = ff_dequant_subband_32_sse4;
103 21 c->put_signed_rect_clamped[1] = ff_put_signed_rect_clamped_10_sse4;
104 }
105 112 }
106