diff libavcodec/ppc/dsputil_ppc.h @ 2:897f711a7157

rearrange to work with autoconf
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Tue, 25 Sep 2012 15:55:33 +0200
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libavcodec/ppc/dsputil_ppc.h	Tue Sep 25 15:55:33 2012 +0200
     1.3 @@ -0,0 +1,154 @@
     1.4 +/*
     1.5 + * Copyright (c) 2003-2004 Romain Dolbeau <romain@dolbeau.org>
     1.6 + *
     1.7 + * This file is part of FFmpeg.
     1.8 + *
     1.9 + * FFmpeg is free software; you can redistribute it and/or
    1.10 + * modify it under the terms of the GNU Lesser General Public
    1.11 + * License as published by the Free Software Foundation; either
    1.12 + * version 2.1 of the License, or (at your option) any later version.
    1.13 + *
    1.14 + * FFmpeg is distributed in the hope that it will be useful,
    1.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.17 + * Lesser General Public License for more details.
    1.18 + *
    1.19 + * You should have received a copy of the GNU Lesser General Public
    1.20 + * License along with FFmpeg; if not, write to the Free Software
    1.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
    1.22 + */
    1.23 +
    1.24 +#ifndef AVCODEC_PPC_DSPUTIL_PPC_H
    1.25 +#define AVCODEC_PPC_DSPUTIL_PPC_H
    1.26 +
    1.27 +#include "config.h"
    1.28 +
    1.29 +#if CONFIG_POWERPC_PERF
    1.30 +void powerpc_display_perf_report(void);
    1.31 +/* the 604* have 2, the G3* have 4, the G4s have 6,
    1.32 +   and the G5 are completely different (they MUST use
    1.33 +   ARCH_PPC64, and let's hope all future 64 bis PPC
    1.34 +   will use the same PMCs... */
    1.35 +#define POWERPC_NUM_PMC_ENABLED 6
    1.36 +/* if you add to the enum below, also add to the perfname array
    1.37 +   in dsputil_ppc.c */
    1.38 +enum powerpc_perf_index {
    1.39 +    altivec_fft_num = 0,
    1.40 +    altivec_gmc1_num,
    1.41 +    altivec_dct_unquantize_h263_num,
    1.42 +    altivec_fdct,
    1.43 +    altivec_idct_add_num,
    1.44 +    altivec_idct_put_num,
    1.45 +    altivec_put_pixels16_num,
    1.46 +    altivec_avg_pixels16_num,
    1.47 +    altivec_avg_pixels8_num,
    1.48 +    altivec_put_pixels8_xy2_num,
    1.49 +    altivec_put_no_rnd_pixels8_xy2_num,
    1.50 +    altivec_put_pixels16_xy2_num,
    1.51 +    altivec_put_no_rnd_pixels16_xy2_num,
    1.52 +    altivec_hadamard8_diff8x8_num,
    1.53 +    altivec_hadamard8_diff16_num,
    1.54 +    altivec_avg_pixels8_xy2_num,
    1.55 +    powerpc_clear_blocks_dcbz32,
    1.56 +    powerpc_clear_blocks_dcbz128,
    1.57 +    altivec_put_h264_chroma_mc8_num,
    1.58 +    altivec_avg_h264_chroma_mc8_num,
    1.59 +    altivec_put_h264_qpel16_h_lowpass_num,
    1.60 +    altivec_avg_h264_qpel16_h_lowpass_num,
    1.61 +    altivec_put_h264_qpel16_v_lowpass_num,
    1.62 +    altivec_avg_h264_qpel16_v_lowpass_num,
    1.63 +    altivec_put_h264_qpel16_hv_lowpass_num,
    1.64 +    altivec_avg_h264_qpel16_hv_lowpass_num,
    1.65 +    powerpc_perf_total
    1.66 +};
    1.67 +enum powerpc_data_index {
    1.68 +    powerpc_data_min = 0,
    1.69 +    powerpc_data_max,
    1.70 +    powerpc_data_sum,
    1.71 +    powerpc_data_num,
    1.72 +    powerpc_data_total
    1.73 +};
    1.74 +extern unsigned long long perfdata[POWERPC_NUM_PMC_ENABLED][powerpc_perf_total][powerpc_data_total];
    1.75 +
    1.76 +#if !ARCH_PPC64
    1.77 +#define POWERP_PMC_DATATYPE unsigned long
    1.78 +#define POWERPC_GET_PMC1(a) __asm__ volatile("mfspr %0, 937" : "=r" (a))
    1.79 +#define POWERPC_GET_PMC2(a) __asm__ volatile("mfspr %0, 938" : "=r" (a))
    1.80 +#if (POWERPC_NUM_PMC_ENABLED > 2)
    1.81 +#define POWERPC_GET_PMC3(a) __asm__ volatile("mfspr %0, 941" : "=r" (a))
    1.82 +#define POWERPC_GET_PMC4(a) __asm__ volatile("mfspr %0, 942" : "=r" (a))
    1.83 +#else
    1.84 +#define POWERPC_GET_PMC3(a) do {} while (0)
    1.85 +#define POWERPC_GET_PMC4(a) do {} while (0)
    1.86 +#endif
    1.87 +#if (POWERPC_NUM_PMC_ENABLED > 4)
    1.88 +#define POWERPC_GET_PMC5(a) __asm__ volatile("mfspr %0, 929" : "=r" (a))
    1.89 +#define POWERPC_GET_PMC6(a) __asm__ volatile("mfspr %0, 930" : "=r" (a))
    1.90 +#else
    1.91 +#define POWERPC_GET_PMC5(a) do {} while (0)
    1.92 +#define POWERPC_GET_PMC6(a) do {} while (0)
    1.93 +#endif
    1.94 +#else /* ARCH_PPC64 */
    1.95 +#define POWERP_PMC_DATATYPE unsigned long long
    1.96 +#define POWERPC_GET_PMC1(a) __asm__ volatile("mfspr %0, 771" : "=r" (a))
    1.97 +#define POWERPC_GET_PMC2(a) __asm__ volatile("mfspr %0, 772" : "=r" (a))
    1.98 +#if (POWERPC_NUM_PMC_ENABLED > 2)
    1.99 +#define POWERPC_GET_PMC3(a) __asm__ volatile("mfspr %0, 773" : "=r" (a))
   1.100 +#define POWERPC_GET_PMC4(a) __asm__ volatile("mfspr %0, 774" : "=r" (a))
   1.101 +#else
   1.102 +#define POWERPC_GET_PMC3(a) do {} while (0)
   1.103 +#define POWERPC_GET_PMC4(a) do {} while (0)
   1.104 +#endif
   1.105 +#if (POWERPC_NUM_PMC_ENABLED > 4)
   1.106 +#define POWERPC_GET_PMC5(a) __asm__ volatile("mfspr %0, 775" : "=r" (a))
   1.107 +#define POWERPC_GET_PMC6(a) __asm__ volatile("mfspr %0, 776" : "=r" (a))
   1.108 +#else
   1.109 +#define POWERPC_GET_PMC5(a) do {} while (0)
   1.110 +#define POWERPC_GET_PMC6(a) do {} while (0)
   1.111 +#endif
   1.112 +#endif /* ARCH_PPC64 */
   1.113 +#define POWERPC_PERF_DECLARE(a, cond)       \
   1.114 +    POWERP_PMC_DATATYPE                     \
   1.115 +        pmc_start[POWERPC_NUM_PMC_ENABLED], \
   1.116 +        pmc_stop[POWERPC_NUM_PMC_ENABLED],  \
   1.117 +        pmc_loop_index;
   1.118 +#define POWERPC_PERF_START_COUNT(a, cond) do { \
   1.119 +    POWERPC_GET_PMC6(pmc_start[5]); \
   1.120 +    POWERPC_GET_PMC5(pmc_start[4]); \
   1.121 +    POWERPC_GET_PMC4(pmc_start[3]); \
   1.122 +    POWERPC_GET_PMC3(pmc_start[2]); \
   1.123 +    POWERPC_GET_PMC2(pmc_start[1]); \
   1.124 +    POWERPC_GET_PMC1(pmc_start[0]); \
   1.125 +    } while (0)
   1.126 +#define POWERPC_PERF_STOP_COUNT(a, cond) do { \
   1.127 +    POWERPC_GET_PMC1(pmc_stop[0]);            \
   1.128 +    POWERPC_GET_PMC2(pmc_stop[1]);            \
   1.129 +    POWERPC_GET_PMC3(pmc_stop[2]);            \
   1.130 +    POWERPC_GET_PMC4(pmc_stop[3]);            \
   1.131 +    POWERPC_GET_PMC5(pmc_stop[4]);            \
   1.132 +    POWERPC_GET_PMC6(pmc_stop[5]);            \
   1.133 +    if (cond) {                               \
   1.134 +        for(pmc_loop_index = 0;               \
   1.135 +            pmc_loop_index < POWERPC_NUM_PMC_ENABLED; \
   1.136 +            pmc_loop_index++) {               \
   1.137 +            if (pmc_stop[pmc_loop_index] >= pmc_start[pmc_loop_index]) {  \
   1.138 +                POWERP_PMC_DATATYPE diff =                                \
   1.139 +                  pmc_stop[pmc_loop_index] - pmc_start[pmc_loop_index];   \
   1.140 +                if (diff < perfdata[pmc_loop_index][a][powerpc_data_min]) \
   1.141 +                    perfdata[pmc_loop_index][a][powerpc_data_min] = diff; \
   1.142 +                if (diff > perfdata[pmc_loop_index][a][powerpc_data_max]) \
   1.143 +                    perfdata[pmc_loop_index][a][powerpc_data_max] = diff; \
   1.144 +                perfdata[pmc_loop_index][a][powerpc_data_sum] += diff;    \
   1.145 +                perfdata[pmc_loop_index][a][powerpc_data_num] ++;         \
   1.146 +            }                                 \
   1.147 +        }                                     \
   1.148 +    }                                         \
   1.149 +} while (0)
   1.150 +#else /* CONFIG_POWERPC_PERF */
   1.151 +// those are needed to avoid empty statements.
   1.152 +#define POWERPC_PERF_DECLARE(a, cond)        int altivec_placeholder __attribute__ ((unused))
   1.153 +#define POWERPC_PERF_START_COUNT(a, cond)    do {} while (0)
   1.154 +#define POWERPC_PERF_STOP_COUNT(a, cond)     do {} while (0)
   1.155 +#endif /* CONFIG_POWERPC_PERF */
   1.156 +
   1.157 +#endif /*  AVCODEC_PPC_DSPUTIL_PPC_H */