nengel@2: /* nengel@2: * Copyright (c) 2003-2004 Romain Dolbeau nengel@2: * nengel@2: * This file is part of FFmpeg. nengel@2: * nengel@2: * FFmpeg is free software; you can redistribute it and/or nengel@2: * modify it under the terms of the GNU Lesser General Public nengel@2: * License as published by the Free Software Foundation; either nengel@2: * version 2.1 of the License, or (at your option) any later version. nengel@2: * nengel@2: * FFmpeg is distributed in the hope that it will be useful, nengel@2: * but WITHOUT ANY WARRANTY; without even the implied warranty of nengel@2: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU nengel@2: * Lesser General Public License for more details. nengel@2: * nengel@2: * You should have received a copy of the GNU Lesser General Public nengel@2: * License along with FFmpeg; if not, write to the Free Software nengel@2: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA nengel@2: */ nengel@2: nengel@2: #ifndef AVCODEC_PPC_DSPUTIL_PPC_H nengel@2: #define AVCODEC_PPC_DSPUTIL_PPC_H nengel@2: nengel@2: #include "config.h" nengel@2: nengel@2: #if CONFIG_POWERPC_PERF nengel@2: void powerpc_display_perf_report(void); nengel@2: /* the 604* have 2, the G3* have 4, the G4s have 6, nengel@2: and the G5 are completely different (they MUST use nengel@2: ARCH_PPC64, and let's hope all future 64 bis PPC nengel@2: will use the same PMCs... */ nengel@2: #define POWERPC_NUM_PMC_ENABLED 6 nengel@2: /* if you add to the enum below, also add to the perfname array nengel@2: in dsputil_ppc.c */ nengel@2: enum powerpc_perf_index { nengel@2: altivec_fft_num = 0, nengel@2: altivec_gmc1_num, nengel@2: altivec_dct_unquantize_h263_num, nengel@2: altivec_fdct, nengel@2: altivec_idct_add_num, nengel@2: altivec_idct_put_num, nengel@2: altivec_put_pixels16_num, nengel@2: altivec_avg_pixels16_num, nengel@2: altivec_avg_pixels8_num, nengel@2: altivec_put_pixels8_xy2_num, nengel@2: altivec_put_no_rnd_pixels8_xy2_num, nengel@2: altivec_put_pixels16_xy2_num, nengel@2: altivec_put_no_rnd_pixels16_xy2_num, nengel@2: altivec_hadamard8_diff8x8_num, nengel@2: altivec_hadamard8_diff16_num, nengel@2: altivec_avg_pixels8_xy2_num, nengel@2: powerpc_clear_blocks_dcbz32, nengel@2: powerpc_clear_blocks_dcbz128, nengel@2: altivec_put_h264_chroma_mc8_num, nengel@2: altivec_avg_h264_chroma_mc8_num, nengel@2: altivec_put_h264_qpel16_h_lowpass_num, nengel@2: altivec_avg_h264_qpel16_h_lowpass_num, nengel@2: altivec_put_h264_qpel16_v_lowpass_num, nengel@2: altivec_avg_h264_qpel16_v_lowpass_num, nengel@2: altivec_put_h264_qpel16_hv_lowpass_num, nengel@2: altivec_avg_h264_qpel16_hv_lowpass_num, nengel@2: powerpc_perf_total nengel@2: }; nengel@2: enum powerpc_data_index { nengel@2: powerpc_data_min = 0, nengel@2: powerpc_data_max, nengel@2: powerpc_data_sum, nengel@2: powerpc_data_num, nengel@2: powerpc_data_total nengel@2: }; nengel@2: extern unsigned long long perfdata[POWERPC_NUM_PMC_ENABLED][powerpc_perf_total][powerpc_data_total]; nengel@2: nengel@2: #if !ARCH_PPC64 nengel@2: #define POWERP_PMC_DATATYPE unsigned long nengel@2: #define POWERPC_GET_PMC1(a) __asm__ volatile("mfspr %0, 937" : "=r" (a)) nengel@2: #define POWERPC_GET_PMC2(a) __asm__ volatile("mfspr %0, 938" : "=r" (a)) nengel@2: #if (POWERPC_NUM_PMC_ENABLED > 2) nengel@2: #define POWERPC_GET_PMC3(a) __asm__ volatile("mfspr %0, 941" : "=r" (a)) nengel@2: #define POWERPC_GET_PMC4(a) __asm__ volatile("mfspr %0, 942" : "=r" (a)) nengel@2: #else nengel@2: #define POWERPC_GET_PMC3(a) do {} while (0) nengel@2: #define POWERPC_GET_PMC4(a) do {} while (0) nengel@2: #endif nengel@2: #if (POWERPC_NUM_PMC_ENABLED > 4) nengel@2: #define POWERPC_GET_PMC5(a) __asm__ volatile("mfspr %0, 929" : "=r" (a)) nengel@2: #define POWERPC_GET_PMC6(a) __asm__ volatile("mfspr %0, 930" : "=r" (a)) nengel@2: #else nengel@2: #define POWERPC_GET_PMC5(a) do {} while (0) nengel@2: #define POWERPC_GET_PMC6(a) do {} while (0) nengel@2: #endif nengel@2: #else /* ARCH_PPC64 */ nengel@2: #define POWERP_PMC_DATATYPE unsigned long long nengel@2: #define POWERPC_GET_PMC1(a) __asm__ volatile("mfspr %0, 771" : "=r" (a)) nengel@2: #define POWERPC_GET_PMC2(a) __asm__ volatile("mfspr %0, 772" : "=r" (a)) nengel@2: #if (POWERPC_NUM_PMC_ENABLED > 2) nengel@2: #define POWERPC_GET_PMC3(a) __asm__ volatile("mfspr %0, 773" : "=r" (a)) nengel@2: #define POWERPC_GET_PMC4(a) __asm__ volatile("mfspr %0, 774" : "=r" (a)) nengel@2: #else nengel@2: #define POWERPC_GET_PMC3(a) do {} while (0) nengel@2: #define POWERPC_GET_PMC4(a) do {} while (0) nengel@2: #endif nengel@2: #if (POWERPC_NUM_PMC_ENABLED > 4) nengel@2: #define POWERPC_GET_PMC5(a) __asm__ volatile("mfspr %0, 775" : "=r" (a)) nengel@2: #define POWERPC_GET_PMC6(a) __asm__ volatile("mfspr %0, 776" : "=r" (a)) nengel@2: #else nengel@2: #define POWERPC_GET_PMC5(a) do {} while (0) nengel@2: #define POWERPC_GET_PMC6(a) do {} while (0) nengel@2: #endif nengel@2: #endif /* ARCH_PPC64 */ nengel@2: #define POWERPC_PERF_DECLARE(a, cond) \ nengel@2: POWERP_PMC_DATATYPE \ nengel@2: pmc_start[POWERPC_NUM_PMC_ENABLED], \ nengel@2: pmc_stop[POWERPC_NUM_PMC_ENABLED], \ nengel@2: pmc_loop_index; nengel@2: #define POWERPC_PERF_START_COUNT(a, cond) do { \ nengel@2: POWERPC_GET_PMC6(pmc_start[5]); \ nengel@2: POWERPC_GET_PMC5(pmc_start[4]); \ nengel@2: POWERPC_GET_PMC4(pmc_start[3]); \ nengel@2: POWERPC_GET_PMC3(pmc_start[2]); \ nengel@2: POWERPC_GET_PMC2(pmc_start[1]); \ nengel@2: POWERPC_GET_PMC1(pmc_start[0]); \ nengel@2: } while (0) nengel@2: #define POWERPC_PERF_STOP_COUNT(a, cond) do { \ nengel@2: POWERPC_GET_PMC1(pmc_stop[0]); \ nengel@2: POWERPC_GET_PMC2(pmc_stop[1]); \ nengel@2: POWERPC_GET_PMC3(pmc_stop[2]); \ nengel@2: POWERPC_GET_PMC4(pmc_stop[3]); \ nengel@2: POWERPC_GET_PMC5(pmc_stop[4]); \ nengel@2: POWERPC_GET_PMC6(pmc_stop[5]); \ nengel@2: if (cond) { \ nengel@2: for(pmc_loop_index = 0; \ nengel@2: pmc_loop_index < POWERPC_NUM_PMC_ENABLED; \ nengel@2: pmc_loop_index++) { \ nengel@2: if (pmc_stop[pmc_loop_index] >= pmc_start[pmc_loop_index]) { \ nengel@2: POWERP_PMC_DATATYPE diff = \ nengel@2: pmc_stop[pmc_loop_index] - pmc_start[pmc_loop_index]; \ nengel@2: if (diff < perfdata[pmc_loop_index][a][powerpc_data_min]) \ nengel@2: perfdata[pmc_loop_index][a][powerpc_data_min] = diff; \ nengel@2: if (diff > perfdata[pmc_loop_index][a][powerpc_data_max]) \ nengel@2: perfdata[pmc_loop_index][a][powerpc_data_max] = diff; \ nengel@2: perfdata[pmc_loop_index][a][powerpc_data_sum] += diff; \ nengel@2: perfdata[pmc_loop_index][a][powerpc_data_num] ++; \ nengel@2: } \ nengel@2: } \ nengel@2: } \ nengel@2: } while (0) nengel@2: #else /* CONFIG_POWERPC_PERF */ nengel@2: // those are needed to avoid empty statements. nengel@2: #define POWERPC_PERF_DECLARE(a, cond) int altivec_placeholder __attribute__ ((unused)) nengel@2: #define POWERPC_PERF_START_COUNT(a, cond) do {} while (0) nengel@2: #define POWERPC_PERF_STOP_COUNT(a, cond) do {} while (0) nengel@2: #endif /* CONFIG_POWERPC_PERF */ nengel@2: nengel@2: #endif /* AVCODEC_PPC_DSPUTIL_PPC_H */