Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * Chinese AVS video (AVS1-P2, JiZhun profile) decoder. | ||
3 | * Copyright (c) 2006 Stefan Gehrer <stefan.gehrer@gmx.de> | ||
4 | * | ||
5 | * MMX-optimized DSP functions, based on H.264 optimizations by | ||
6 | * Michael Niedermayer and Loren Merritt | ||
7 | * | ||
8 | * This file is part of FFmpeg. | ||
9 | * | ||
10 | * FFmpeg is free software; you can redistribute it and/or | ||
11 | * modify it under the terms of the GNU Lesser General Public | ||
12 | * License as published by the Free Software Foundation; either | ||
13 | * version 2.1 of the License, or (at your option) any later version. | ||
14 | * | ||
15 | * FFmpeg is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
18 | * Lesser General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU Lesser General Public | ||
21 | * License along with FFmpeg; if not, write to the Free Software | ||
22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
23 | */ | ||
24 | |||
25 | #include "libavutil/attributes.h" | ||
26 | #include "libavutil/cpu.h" | ||
27 | #include "libavutil/mem_internal.h" | ||
28 | #include "libavutil/x86/cpu.h" | ||
29 | #include "libavcodec/cavsdsp.h" | ||
30 | #include "libavcodec/idctdsp.h" | ||
31 | #include "fpel.h" | ||
32 | #include "idctdsp.h" | ||
33 | #include "config.h" | ||
34 | |||
35 | |||
36 | #if HAVE_SSE2_EXTERNAL | ||
37 | |||
38 | void ff_cavs_idct8_sse2(int16_t *out, const int16_t *in); | ||
39 | |||
40 | 4921 | static void cavs_idct8_add_sse2(uint8_t *dst, int16_t *block, ptrdiff_t stride) | |
41 | { | ||
42 | 4921 | LOCAL_ALIGNED(16, int16_t, b2, [64]); | |
43 | 4921 | ff_cavs_idct8_sse2(b2, block); | |
44 | 4921 | ff_add_pixels_clamped_sse2(b2, dst, stride); | |
45 | 4921 | } | |
46 | |||
47 | #endif /* HAVE_SSE2_EXTERNAL */ | ||
48 | |||
49 | #if HAVE_SSE2_EXTERNAL | ||
50 | #define DEF_QPEL(OPNAME) \ | ||
51 | void ff_ ## OPNAME ## _cavs_qpel8_mc20_sse2(uint8_t *dst, const uint8_t *src, ptrdiff_t stride); \ | ||
52 | void ff_ ## OPNAME ## _cavs_qpel8_mc02_sse2(uint8_t *dst, const uint8_t *src, ptrdiff_t stride); \ | ||
53 | void ff_ ## OPNAME ## _cavs_qpel8_mc03_sse2(uint8_t *dst, const uint8_t *src, ptrdiff_t stride); \ | ||
54 | void ff_ ## OPNAME ## _cavs_qpel8_h_sse2(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h); \ | ||
55 | void ff_ ## OPNAME ## _cavs_qpel8_v2_sse2(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h);\ | ||
56 | void ff_ ## OPNAME ## _cavs_qpel8_v3_sse2(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h);\ | ||
57 | |||
58 | DEF_QPEL(put) | ||
59 | DEF_QPEL(avg) | ||
60 | |||
61 | #define QPEL_CAVS_XMM(OPNAME, XMM) \ | ||
62 | static void OPNAME ## _cavs_qpel16_mc02_ ## XMM(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) \ | ||
63 | { \ | ||
64 | ff_ ## OPNAME ## _cavs_qpel8_v2_ ## XMM(dst, src, stride, 16); \ | ||
65 | ff_ ## OPNAME ## _cavs_qpel8_v2_ ## XMM(dst + 8, src + 8, stride, 16); \ | ||
66 | } \ | ||
67 | static void OPNAME ## _cavs_qpel16_mc03_ ## XMM(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) \ | ||
68 | { \ | ||
69 | ff_ ## OPNAME ## _cavs_qpel8_v3_ ## XMM(dst, src, stride, 16); \ | ||
70 | ff_ ## OPNAME ## _cavs_qpel8_v3_ ## XMM(dst + 8, src + 8, stride, 16); \ | ||
71 | } \ | ||
72 | static void OPNAME ## _cavs_qpel8_mc01_ ## XMM(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) \ | ||
73 | { \ | ||
74 | ff_ ## OPNAME ## _cavs_qpel8_mc03_ ## XMM(dst + 7 * stride, src + 8 * stride, -stride); \ | ||
75 | } \ | ||
76 | static void OPNAME ## _cavs_qpel16_mc01_ ## XMM(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) \ | ||
77 | { \ | ||
78 | OPNAME ## _cavs_qpel16_mc03_ ## XMM(dst + 15 * stride, src + 16 * stride, -stride); \ | ||
79 | } \ | ||
80 | static void OPNAME ## _cavs_qpel16_mc20_ ## XMM(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) \ | ||
81 | { \ | ||
82 | ff_ ## OPNAME ## _cavs_qpel8_h_ ## XMM(dst, src, stride, 16); \ | ||
83 | ff_ ## OPNAME ## _cavs_qpel8_h_ ## XMM(dst + 8, src + 8, stride, 16); \ | ||
84 | } | ||
85 | |||
86 | 12 | QPEL_CAVS_XMM(put, sse2) | |
87 | 12 | QPEL_CAVS_XMM(avg, sse2) | |
88 | #endif | ||
89 | |||
90 | 19 | av_cold void ff_cavsdsp_init_x86(CAVSDSPContext *c) | |
91 | { | ||
92 | 19 | av_unused int cpu_flags = av_get_cpu_flags(); | |
93 | |||
94 | #if HAVE_MMX_EXTERNAL | ||
95 |
2/2✓ Branch 0 taken 13 times.
✓ Branch 1 taken 6 times.
|
19 | if (EXTERNAL_MMXEXT(cpu_flags)) { |
96 | 13 | c->avg_cavs_qpel_pixels_tab[1][0] = ff_avg_pixels8x8_mmxext; | |
97 | } | ||
98 | #endif | ||
99 | #if HAVE_SSE2_EXTERNAL | ||
100 |
2/2✓ Branch 0 taken 11 times.
✓ Branch 1 taken 8 times.
|
19 | if (EXTERNAL_SSE2(cpu_flags)) { |
101 | 11 | c->put_cavs_qpel_pixels_tab[0][ 0] = ff_put_pixels16x16_sse2; | |
102 | 11 | c->put_cavs_qpel_pixels_tab[0][ 2] = put_cavs_qpel16_mc20_sse2; | |
103 | 11 | c->put_cavs_qpel_pixels_tab[0][ 4] = put_cavs_qpel16_mc01_sse2; | |
104 | 11 | c->put_cavs_qpel_pixels_tab[0][ 8] = put_cavs_qpel16_mc02_sse2; | |
105 | 11 | c->put_cavs_qpel_pixels_tab[0][12] = put_cavs_qpel16_mc03_sse2; | |
106 | 11 | c->put_cavs_qpel_pixels_tab[1][ 0] = ff_put_pixels8x8_sse2; | |
107 | 11 | c->put_cavs_qpel_pixels_tab[1][ 2] = ff_put_cavs_qpel8_mc20_sse2; | |
108 | 11 | c->put_cavs_qpel_pixels_tab[1][ 4] = put_cavs_qpel8_mc01_sse2; | |
109 | 11 | c->put_cavs_qpel_pixels_tab[1][ 8] = ff_put_cavs_qpel8_mc02_sse2; | |
110 | 11 | c->put_cavs_qpel_pixels_tab[1][12] = ff_put_cavs_qpel8_mc03_sse2; | |
111 | |||
112 | 11 | c->avg_cavs_qpel_pixels_tab[0][ 0] = ff_avg_pixels16x16_sse2; | |
113 | 11 | c->avg_cavs_qpel_pixels_tab[0][ 2] = avg_cavs_qpel16_mc20_sse2; | |
114 | 11 | c->avg_cavs_qpel_pixels_tab[0][ 4] = avg_cavs_qpel16_mc01_sse2; | |
115 | 11 | c->avg_cavs_qpel_pixels_tab[0][ 8] = avg_cavs_qpel16_mc02_sse2; | |
116 | 11 | c->avg_cavs_qpel_pixels_tab[0][12] = avg_cavs_qpel16_mc03_sse2; | |
117 | 11 | c->avg_cavs_qpel_pixels_tab[1][ 2] = ff_avg_cavs_qpel8_mc20_sse2; | |
118 | 11 | c->avg_cavs_qpel_pixels_tab[1][ 4] = avg_cavs_qpel8_mc01_sse2; | |
119 | 11 | c->avg_cavs_qpel_pixels_tab[1][ 8] = ff_avg_cavs_qpel8_mc02_sse2; | |
120 | 11 | c->avg_cavs_qpel_pixels_tab[1][12] = ff_avg_cavs_qpel8_mc03_sse2; | |
121 | |||
122 | 11 | c->cavs_idct8_add = cavs_idct8_add_sse2; | |
123 | 11 | c->idct_perm = FF_IDCT_PERM_TRANSPOSE; | |
124 | } | ||
125 | #endif | ||
126 | 19 | } | |
127 |