| rev |
line source |
|
nengel@2
|
1 /*
|
|
nengel@2
|
2 * Copyright (c) 2003-2004 Romain Dolbeau <romain@dolbeau.org>
|
|
nengel@2
|
3 *
|
|
nengel@2
|
4 * This file is part of FFmpeg.
|
|
nengel@2
|
5 *
|
|
nengel@2
|
6 * FFmpeg is free software; you can redistribute it and/or
|
|
nengel@2
|
7 * modify it under the terms of the GNU Lesser General Public
|
|
nengel@2
|
8 * License as published by the Free Software Foundation; either
|
|
nengel@2
|
9 * version 2.1 of the License, or (at your option) any later version.
|
|
nengel@2
|
10 *
|
|
nengel@2
|
11 * FFmpeg is distributed in the hope that it will be useful,
|
|
nengel@2
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
nengel@2
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
nengel@2
|
14 * Lesser General Public License for more details.
|
|
nengel@2
|
15 *
|
|
nengel@2
|
16 * You should have received a copy of the GNU Lesser General Public
|
|
nengel@2
|
17 * License along with FFmpeg; if not, write to the Free Software
|
|
nengel@2
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
nengel@2
|
19 */
|
|
nengel@2
|
20
|
|
nengel@2
|
21 #ifndef AVCODEC_PPC_DSPUTIL_PPC_H
|
|
nengel@2
|
22 #define AVCODEC_PPC_DSPUTIL_PPC_H
|
|
nengel@2
|
23
|
|
nengel@2
|
24 #include "config.h"
|
|
nengel@2
|
25
|
|
nengel@2
|
26 #if CONFIG_POWERPC_PERF
|
|
nengel@2
|
27 void powerpc_display_perf_report(void);
|
|
nengel@2
|
28 /* the 604* have 2, the G3* have 4, the G4s have 6,
|
|
nengel@2
|
29 and the G5 are completely different (they MUST use
|
|
nengel@2
|
30 ARCH_PPC64, and let's hope all future 64 bis PPC
|
|
nengel@2
|
31 will use the same PMCs... */
|
|
nengel@2
|
32 #define POWERPC_NUM_PMC_ENABLED 6
|
|
nengel@2
|
33 /* if you add to the enum below, also add to the perfname array
|
|
nengel@2
|
34 in dsputil_ppc.c */
|
|
nengel@2
|
35 enum powerpc_perf_index {
|
|
nengel@2
|
36 altivec_fft_num = 0,
|
|
nengel@2
|
37 altivec_gmc1_num,
|
|
nengel@2
|
38 altivec_dct_unquantize_h263_num,
|
|
nengel@2
|
39 altivec_fdct,
|
|
nengel@2
|
40 altivec_idct_add_num,
|
|
nengel@2
|
41 altivec_idct_put_num,
|
|
nengel@2
|
42 altivec_put_pixels16_num,
|
|
nengel@2
|
43 altivec_avg_pixels16_num,
|
|
nengel@2
|
44 altivec_avg_pixels8_num,
|
|
nengel@2
|
45 altivec_put_pixels8_xy2_num,
|
|
nengel@2
|
46 altivec_put_no_rnd_pixels8_xy2_num,
|
|
nengel@2
|
47 altivec_put_pixels16_xy2_num,
|
|
nengel@2
|
48 altivec_put_no_rnd_pixels16_xy2_num,
|
|
nengel@2
|
49 altivec_hadamard8_diff8x8_num,
|
|
nengel@2
|
50 altivec_hadamard8_diff16_num,
|
|
nengel@2
|
51 altivec_avg_pixels8_xy2_num,
|
|
nengel@2
|
52 powerpc_clear_blocks_dcbz32,
|
|
nengel@2
|
53 powerpc_clear_blocks_dcbz128,
|
|
nengel@2
|
54 altivec_put_h264_chroma_mc8_num,
|
|
nengel@2
|
55 altivec_avg_h264_chroma_mc8_num,
|
|
nengel@2
|
56 altivec_put_h264_qpel16_h_lowpass_num,
|
|
nengel@2
|
57 altivec_avg_h264_qpel16_h_lowpass_num,
|
|
nengel@2
|
58 altivec_put_h264_qpel16_v_lowpass_num,
|
|
nengel@2
|
59 altivec_avg_h264_qpel16_v_lowpass_num,
|
|
nengel@2
|
60 altivec_put_h264_qpel16_hv_lowpass_num,
|
|
nengel@2
|
61 altivec_avg_h264_qpel16_hv_lowpass_num,
|
|
nengel@2
|
62 powerpc_perf_total
|
|
nengel@2
|
63 };
|
|
nengel@2
|
64 enum powerpc_data_index {
|
|
nengel@2
|
65 powerpc_data_min = 0,
|
|
nengel@2
|
66 powerpc_data_max,
|
|
nengel@2
|
67 powerpc_data_sum,
|
|
nengel@2
|
68 powerpc_data_num,
|
|
nengel@2
|
69 powerpc_data_total
|
|
nengel@2
|
70 };
|
|
nengel@2
|
71 extern unsigned long long perfdata[POWERPC_NUM_PMC_ENABLED][powerpc_perf_total][powerpc_data_total];
|
|
nengel@2
|
72
|
|
nengel@2
|
73 #if !ARCH_PPC64
|
|
nengel@2
|
74 #define POWERP_PMC_DATATYPE unsigned long
|
|
nengel@2
|
75 #define POWERPC_GET_PMC1(a) __asm__ volatile("mfspr %0, 937" : "=r" (a))
|
|
nengel@2
|
76 #define POWERPC_GET_PMC2(a) __asm__ volatile("mfspr %0, 938" : "=r" (a))
|
|
nengel@2
|
77 #if (POWERPC_NUM_PMC_ENABLED > 2)
|
|
nengel@2
|
78 #define POWERPC_GET_PMC3(a) __asm__ volatile("mfspr %0, 941" : "=r" (a))
|
|
nengel@2
|
79 #define POWERPC_GET_PMC4(a) __asm__ volatile("mfspr %0, 942" : "=r" (a))
|
|
nengel@2
|
80 #else
|
|
nengel@2
|
81 #define POWERPC_GET_PMC3(a) do {} while (0)
|
|
nengel@2
|
82 #define POWERPC_GET_PMC4(a) do {} while (0)
|
|
nengel@2
|
83 #endif
|
|
nengel@2
|
84 #if (POWERPC_NUM_PMC_ENABLED > 4)
|
|
nengel@2
|
85 #define POWERPC_GET_PMC5(a) __asm__ volatile("mfspr %0, 929" : "=r" (a))
|
|
nengel@2
|
86 #define POWERPC_GET_PMC6(a) __asm__ volatile("mfspr %0, 930" : "=r" (a))
|
|
nengel@2
|
87 #else
|
|
nengel@2
|
88 #define POWERPC_GET_PMC5(a) do {} while (0)
|
|
nengel@2
|
89 #define POWERPC_GET_PMC6(a) do {} while (0)
|
|
nengel@2
|
90 #endif
|
|
nengel@2
|
91 #else /* ARCH_PPC64 */
|
|
nengel@2
|
92 #define POWERP_PMC_DATATYPE unsigned long long
|
|
nengel@2
|
93 #define POWERPC_GET_PMC1(a) __asm__ volatile("mfspr %0, 771" : "=r" (a))
|
|
nengel@2
|
94 #define POWERPC_GET_PMC2(a) __asm__ volatile("mfspr %0, 772" : "=r" (a))
|
|
nengel@2
|
95 #if (POWERPC_NUM_PMC_ENABLED > 2)
|
|
nengel@2
|
96 #define POWERPC_GET_PMC3(a) __asm__ volatile("mfspr %0, 773" : "=r" (a))
|
|
nengel@2
|
97 #define POWERPC_GET_PMC4(a) __asm__ volatile("mfspr %0, 774" : "=r" (a))
|
|
nengel@2
|
98 #else
|
|
nengel@2
|
99 #define POWERPC_GET_PMC3(a) do {} while (0)
|
|
nengel@2
|
100 #define POWERPC_GET_PMC4(a) do {} while (0)
|
|
nengel@2
|
101 #endif
|
|
nengel@2
|
102 #if (POWERPC_NUM_PMC_ENABLED > 4)
|
|
nengel@2
|
103 #define POWERPC_GET_PMC5(a) __asm__ volatile("mfspr %0, 775" : "=r" (a))
|
|
nengel@2
|
104 #define POWERPC_GET_PMC6(a) __asm__ volatile("mfspr %0, 776" : "=r" (a))
|
|
nengel@2
|
105 #else
|
|
nengel@2
|
106 #define POWERPC_GET_PMC5(a) do {} while (0)
|
|
nengel@2
|
107 #define POWERPC_GET_PMC6(a) do {} while (0)
|
|
nengel@2
|
108 #endif
|
|
nengel@2
|
109 #endif /* ARCH_PPC64 */
|
|
nengel@2
|
110 #define POWERPC_PERF_DECLARE(a, cond) \
|
|
nengel@2
|
111 POWERP_PMC_DATATYPE \
|
|
nengel@2
|
112 pmc_start[POWERPC_NUM_PMC_ENABLED], \
|
|
nengel@2
|
113 pmc_stop[POWERPC_NUM_PMC_ENABLED], \
|
|
nengel@2
|
114 pmc_loop_index;
|
|
nengel@2
|
115 #define POWERPC_PERF_START_COUNT(a, cond) do { \
|
|
nengel@2
|
116 POWERPC_GET_PMC6(pmc_start[5]); \
|
|
nengel@2
|
117 POWERPC_GET_PMC5(pmc_start[4]); \
|
|
nengel@2
|
118 POWERPC_GET_PMC4(pmc_start[3]); \
|
|
nengel@2
|
119 POWERPC_GET_PMC3(pmc_start[2]); \
|
|
nengel@2
|
120 POWERPC_GET_PMC2(pmc_start[1]); \
|
|
nengel@2
|
121 POWERPC_GET_PMC1(pmc_start[0]); \
|
|
nengel@2
|
122 } while (0)
|
|
nengel@2
|
123 #define POWERPC_PERF_STOP_COUNT(a, cond) do { \
|
|
nengel@2
|
124 POWERPC_GET_PMC1(pmc_stop[0]); \
|
|
nengel@2
|
125 POWERPC_GET_PMC2(pmc_stop[1]); \
|
|
nengel@2
|
126 POWERPC_GET_PMC3(pmc_stop[2]); \
|
|
nengel@2
|
127 POWERPC_GET_PMC4(pmc_stop[3]); \
|
|
nengel@2
|
128 POWERPC_GET_PMC5(pmc_stop[4]); \
|
|
nengel@2
|
129 POWERPC_GET_PMC6(pmc_stop[5]); \
|
|
nengel@2
|
130 if (cond) { \
|
|
nengel@2
|
131 for(pmc_loop_index = 0; \
|
|
nengel@2
|
132 pmc_loop_index < POWERPC_NUM_PMC_ENABLED; \
|
|
nengel@2
|
133 pmc_loop_index++) { \
|
|
nengel@2
|
134 if (pmc_stop[pmc_loop_index] >= pmc_start[pmc_loop_index]) { \
|
|
nengel@2
|
135 POWERP_PMC_DATATYPE diff = \
|
|
nengel@2
|
136 pmc_stop[pmc_loop_index] - pmc_start[pmc_loop_index]; \
|
|
nengel@2
|
137 if (diff < perfdata[pmc_loop_index][a][powerpc_data_min]) \
|
|
nengel@2
|
138 perfdata[pmc_loop_index][a][powerpc_data_min] = diff; \
|
|
nengel@2
|
139 if (diff > perfdata[pmc_loop_index][a][powerpc_data_max]) \
|
|
nengel@2
|
140 perfdata[pmc_loop_index][a][powerpc_data_max] = diff; \
|
|
nengel@2
|
141 perfdata[pmc_loop_index][a][powerpc_data_sum] += diff; \
|
|
nengel@2
|
142 perfdata[pmc_loop_index][a][powerpc_data_num] ++; \
|
|
nengel@2
|
143 } \
|
|
nengel@2
|
144 } \
|
|
nengel@2
|
145 } \
|
|
nengel@2
|
146 } while (0)
|
|
nengel@2
|
147 #else /* CONFIG_POWERPC_PERF */
|
|
nengel@2
|
148 // those are needed to avoid empty statements.
|
|
nengel@2
|
149 #define POWERPC_PERF_DECLARE(a, cond) int altivec_placeholder __attribute__ ((unused))
|
|
nengel@2
|
150 #define POWERPC_PERF_START_COUNT(a, cond) do {} while (0)
|
|
nengel@2
|
151 #define POWERPC_PERF_STOP_COUNT(a, cond) do {} while (0)
|
|
nengel@2
|
152 #endif /* CONFIG_POWERPC_PERF */
|
|
nengel@2
|
153
|
|
nengel@2
|
154 #endif /* AVCODEC_PPC_DSPUTIL_PPC_H */
|