systemdependent.c 5.82 KB
Newer Older
John Koleszar's avatar
John Koleszar committed
1
/*
2
 *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
John Koleszar's avatar
John Koleszar committed
3
 *
4
 *  Use of this source code is governed by a BSD-style license
5
6
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
7
 *  in the file PATENTS.  All contributing project authors may
8
 *  be found in the AUTHORS file in the root of the source tree.
John Koleszar's avatar
John Koleszar committed
9
10
11
12
 */


#include "vpx_ports/config.h"
John Koleszar's avatar
John Koleszar committed
13
14
15
16
17
18
#include "vp8/common/g_common.h"
#include "vp8/common/subpixel.h"
#include "vp8/common/loopfilter.h"
#include "vp8/common/recon.h"
#include "vp8/common/idct.h"
#include "vp8/common/onyxc_int.h"
John Koleszar's avatar
John Koleszar committed
19

20
21
22
23
24
25
26
27
28
#if CONFIG_MULTITHREAD
#if HAVE_UNISTD_H
#include <unistd.h>
#elif defined(_WIN32)
#include <windows.h>
typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
#endif
#endif

John Koleszar's avatar
John Koleszar committed
29
extern void vp8_arch_x86_common_init(VP8_COMMON *ctx);
30
extern void vp8_arch_arm_common_init(VP8_COMMON *ctx);
John Koleszar's avatar
John Koleszar committed
31

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#if CONFIG_MULTITHREAD
static int get_cpu_count()
{
    int core_count = 16;

#if HAVE_UNISTD_H
#if defined(_SC_NPROCESSORS_ONLN)
    core_count = sysconf(_SC_NPROCESSORS_ONLN);
#elif defined(_SC_NPROC_ONLN)
    core_count = sysconf(_SC_NPROC_ONLN);
#endif
#elif defined(_WIN32)
    {
        PGNSI pGNSI;
        SYSTEM_INFO sysinfo;

        /* Call GetNativeSystemInfo if supported or
         * GetSystemInfo otherwise. */

        pGNSI = (PGNSI) GetProcAddress(
                GetModuleHandle(TEXT("kernel32.dll")), "GetNativeSystemInfo");
        if (pGNSI != NULL)
            pGNSI(&sysinfo);
        else
            GetSystemInfo(&sysinfo);

        core_count = sysinfo.dwNumberOfProcessors;
    }
#else
    /* other platforms */
#endif

    return core_count > 0 ? core_count : 1;
}
#endif

John Koleszar's avatar
John Koleszar committed
68
69
70
71
72
73
74
void vp8_machine_specific_config(VP8_COMMON *ctx)
{
#if CONFIG_RUNTIME_CPU_DETECT
    VP8_COMMON_RTCD *rtcd = &ctx->rtcd;

    rtcd->idct.idct1        = vp8_short_idct4x4llm_1_c;
    rtcd->idct.idct16       = vp8_short_idct4x4llm_c;
75
    rtcd->idct.idct1_scalar_add = vp8_dc_only_idct_add_c;
John Koleszar's avatar
John Koleszar committed
76
77
    rtcd->idct.iwalsh1      = vp8_short_inv_walsh4x4_1_c;
    rtcd->idct.iwalsh16     = vp8_short_inv_walsh4x4_c;
78
79
80
81
82
83
84
#if CONFIG_T8X8
    rtcd->idct.idct8        = vp8_short_idct8x8_c;
    rtcd->idct.idct8_1      = vp8_short_idct8x8_1_c;
    rtcd->idct.idct1_scalar_add_8x8 = vp8_dc_only_idct_add_8x8_c;
    rtcd->idct.ihaar2       = vp8_short_ihaar2x2_c;
    rtcd->idct.ihaar2_1     = vp8_short_ihaar2x2_1_c;
#endif
John Koleszar's avatar
John Koleszar committed
85
86
    rtcd->recon.copy16x16   = vp8_copy_mem16x16_c;
    rtcd->recon.copy8x8     = vp8_copy_mem8x8_c;
87
88
89
90
#if CONFIG_DUALPRED
    rtcd->recon.avg16x16    = vp8_avg_mem16x16_c;
    rtcd->recon.avg8x8      = vp8_avg_mem8x8_c;
#endif /* CONFIG_DUALPRED */
John Koleszar's avatar
John Koleszar committed
91
    rtcd->recon.copy8x4     = vp8_copy_mem8x4_c;
92
    rtcd->recon.recon       = vp8_recon_b_c;
Yaowu Xu's avatar
Yaowu Xu committed
93
    rtcd->recon.recon_uv    = vp8_recon_uv_b_c;
John Koleszar's avatar
John Koleszar committed
94
    rtcd->recon.recon2      = vp8_recon2b_c;
95
96
97
    rtcd->recon.recon4      = vp8_recon4b_c;
    rtcd->recon.recon_mb    = vp8_recon_mb_c;
    rtcd->recon.recon_mby   = vp8_recon_mby_c;
98
99
100
101
    rtcd->recon.build_intra_predictors_mby =
        vp8_build_intra_predictors_mby;
    rtcd->recon.build_intra_predictors_mby_s =
        vp8_build_intra_predictors_mby_s;
102
103
104
105
106
107
    rtcd->recon.build_intra_predictors_mbuv =
        vp8_build_intra_predictors_mbuv;
    rtcd->recon.build_intra_predictors_mbuv_s =
        vp8_build_intra_predictors_mbuv_s;
    rtcd->recon.intra4x4_predict =
        vp8_intra4x4_predict;
Yaowu Xu's avatar
Yaowu Xu committed
108
109
110
111
112
    rtcd->recon.intra8x8_predict =
        vp8_intra8x8_predict;
    rtcd->recon.intra_uv4x4_predict =
        vp8_intra_uv4x4_predict;

113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
    rtcd->subpix.sixtap16x16       = vp8_sixtap_predict16x16_c;
    rtcd->subpix.sixtap8x8         = vp8_sixtap_predict8x8_c;
#if CONFIG_DUALPRED
    rtcd->subpix.sixtap_avg16x16   = vp8_sixtap_predict_avg16x16_c;
    rtcd->subpix.sixtap_avg8x8     = vp8_sixtap_predict_avg8x8_c;
#endif /* CONFIG_DUALPRED */
    rtcd->subpix.sixtap8x4         = vp8_sixtap_predict8x4_c;
    rtcd->subpix.sixtap4x4         = vp8_sixtap_predict_c;
    rtcd->subpix.bilinear16x16     = vp8_bilinear_predict16x16_c;
    rtcd->subpix.bilinear8x8       = vp8_bilinear_predict8x8_c;
#if CONFIG_DUALPRED
    rtcd->subpix.bilinear_avg16x16 = vp8_bilinear_predict_avg16x16_c;
    rtcd->subpix.bilinear_avg8x8   = vp8_bilinear_predict_avg8x8_c;
#endif /* CONFIG_DUALPRED */
    rtcd->subpix.bilinear8x4       = vp8_bilinear_predict8x4_c;
    rtcd->subpix.bilinear4x4       = vp8_bilinear_predict4x4_c;
John Koleszar's avatar
John Koleszar committed
129
130
131
132
133

    rtcd->loopfilter.normal_mb_v = vp8_loop_filter_mbv_c;
    rtcd->loopfilter.normal_b_v  = vp8_loop_filter_bv_c;
    rtcd->loopfilter.normal_mb_h = vp8_loop_filter_mbh_c;
    rtcd->loopfilter.normal_b_h  = vp8_loop_filter_bh_c;
Attila Nagy's avatar
Attila Nagy committed
134
    rtcd->loopfilter.simple_mb_v = vp8_loop_filter_simple_vertical_edge_c;
John Koleszar's avatar
John Koleszar committed
135
    rtcd->loopfilter.simple_b_v  = vp8_loop_filter_bvs_c;
Attila Nagy's avatar
Attila Nagy committed
136
    rtcd->loopfilter.simple_mb_h = vp8_loop_filter_simple_horizontal_edge_c;
John Koleszar's avatar
John Koleszar committed
137
138
    rtcd->loopfilter.simple_b_h  = vp8_loop_filter_bhs_c;

139
#if CONFIG_POSTPROC || (CONFIG_VP8_ENCODER && CONFIG_INTERNAL_STATS)
140
141
142
143
144
145
146
    rtcd->postproc.down             = vp8_mbpost_proc_down_c;
    rtcd->postproc.across           = vp8_mbpost_proc_across_ip_c;
    rtcd->postproc.downacross       = vp8_post_proc_down_and_across_c;
    rtcd->postproc.addnoise         = vp8_plane_add_noise_c;
    rtcd->postproc.blend_mb_inner   = vp8_blend_mb_inner_c;
    rtcd->postproc.blend_mb_outer   = vp8_blend_mb_outer_c;
    rtcd->postproc.blend_b          = vp8_blend_b_c;
John Koleszar's avatar
John Koleszar committed
147
148
149
150
151
152
153
154
#endif

#endif

#if ARCH_X86 || ARCH_X86_64
    vp8_arch_x86_common_init(ctx);
#endif

155

156
157
158
#if ARCH_ARM
    vp8_arch_arm_common_init(ctx);
#endif
159
160
161
162
163
164
    rtcd->idct.idct1        = vp8_short_idct4x4llm_1_c;
    rtcd->idct.idct16       = vp8_short_idct4x4llm_c;
    rtcd->idct.idct1_scalar_add = vp8_dc_only_idct_add_c;
    rtcd->idct.iwalsh1      = vp8_short_inv_walsh4x4_1_c;
    rtcd->idct.iwalsh16     = vp8_short_inv_walsh4x4_c;

165
166
167
#if CONFIG_MULTITHREAD
    ctx->processor_core_count = get_cpu_count();
#endif /* CONFIG_MULTITHREAD */
John Koleszar's avatar
John Koleszar committed
168
}