| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 | 11 |
| 12 #include "vpx_ports/config.h" | 12 #include "vpx_ports/config.h" |
| 13 #include "vp8/common/g_common.h" | 13 #include "vp8/common/g_common.h" |
| 14 #include "vp8/common/subpixel.h" | 14 #include "vp8/common/subpixel.h" |
| 15 #include "vp8/common/loopfilter.h" | 15 #include "vp8/common/loopfilter.h" |
| 16 #include "vp8/common/recon.h" | 16 #include "vp8/common/recon.h" |
| 17 #include "vp8/common/idct.h" | 17 #include "vp8/common/idct.h" |
| 18 #include "vp8/common/onyxc_int.h" | 18 #include "vp8/common/onyxc_int.h" |
| 19 | 19 |
| 20 #if CONFIG_MULTITHREAD |
| 21 #if HAVE_UNISTD_H |
| 22 #include <unistd.h> |
| 23 #elif defined(_WIN32) |
| 24 #include <windows.h> |
| 25 typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO); |
| 26 #endif |
| 27 #endif |
| 28 |
| 20 extern void vp8_arch_x86_common_init(VP8_COMMON *ctx); | 29 extern void vp8_arch_x86_common_init(VP8_COMMON *ctx); |
| 21 extern void vp8_arch_arm_common_init(VP8_COMMON *ctx); | 30 extern void vp8_arch_arm_common_init(VP8_COMMON *ctx); |
| 22 | 31 |
| 32 #if CONFIG_MULTITHREAD |
| 33 static int get_cpu_count() |
| 34 { |
| 35 int core_count = 16; |
| 36 |
| 37 #if HAVE_UNISTD_H |
| 38 #if defined(_SC_NPROCESSORS_ONLN) |
| 39 core_count = sysconf(_SC_NPROCESSORS_ONLN); |
| 40 #elif defined(_SC_NPROC_ONLN) |
| 41 core_count = sysconf(_SC_NPROC_ONLN); |
| 42 #endif |
| 43 #elif defined(_WIN32) |
| 44 { |
| 45 PGNSI pGNSI; |
| 46 SYSTEM_INFO sysinfo; |
| 47 |
| 48 /* Call GetNativeSystemInfo if supported or |
| 49 * GetSystemInfo otherwise. */ |
| 50 |
| 51 pGNSI = (PGNSI) GetProcAddress( |
| 52 GetModuleHandle(TEXT("kernel32.dll")), "GetNativeSystemInfo"); |
| 53 if (pGNSI != NULL) |
| 54 pGNSI(&sysinfo); |
| 55 else |
| 56 GetSystemInfo(&sysinfo); |
| 57 |
| 58 core_count = sysinfo.dwNumberOfProcessors; |
| 59 } |
| 60 #else |
| 61 /* other platforms */ |
| 62 #endif |
| 63 |
| 64 return core_count > 0 ? core_count : 1; |
| 65 } |
| 66 #endif |
| 67 |
| 23 void vp8_machine_specific_config(VP8_COMMON *ctx) | 68 void vp8_machine_specific_config(VP8_COMMON *ctx) |
| 24 { | 69 { |
| 25 #if CONFIG_RUNTIME_CPU_DETECT | 70 #if CONFIG_RUNTIME_CPU_DETECT |
| 26 VP8_COMMON_RTCD *rtcd = &ctx->rtcd; | 71 VP8_COMMON_RTCD *rtcd = &ctx->rtcd; |
| 27 | 72 |
| 28 rtcd->idct.idct1 = vp8_short_idct4x4llm_1_c; | 73 rtcd->idct.idct1 = vp8_short_idct4x4llm_1_c; |
| 29 rtcd->idct.idct16 = vp8_short_idct4x4llm_c; | 74 rtcd->idct.idct16 = vp8_short_idct4x4llm_c; |
| 30 rtcd->idct.idct1_scalar_add = vp8_dc_only_idct_add_c; | 75 rtcd->idct.idct1_scalar_add = vp8_dc_only_idct_add_c; |
| 31 rtcd->idct.iwalsh1 = vp8_short_inv_walsh4x4_1_c; | 76 rtcd->idct.iwalsh1 = vp8_short_inv_walsh4x4_1_c; |
| 32 rtcd->idct.iwalsh16 = vp8_short_inv_walsh4x4_c; | 77 rtcd->idct.iwalsh16 = vp8_short_inv_walsh4x4_c; |
| 33 | 78 |
| 34 rtcd->recon.copy16x16 = vp8_copy_mem16x16_c; | 79 rtcd->recon.copy16x16 = vp8_copy_mem16x16_c; |
| 35 rtcd->recon.copy8x8 = vp8_copy_mem8x8_c; | 80 rtcd->recon.copy8x8 = vp8_copy_mem8x8_c; |
| 36 rtcd->recon.copy8x4 = vp8_copy_mem8x4_c; | 81 rtcd->recon.copy8x4 = vp8_copy_mem8x4_c; |
| 37 rtcd->recon.recon = vp8_recon_b_c; | 82 rtcd->recon.recon = vp8_recon_b_c; |
| 38 rtcd->recon.recon2 = vp8_recon2b_c; | 83 rtcd->recon.recon2 = vp8_recon2b_c; |
| 39 rtcd->recon.recon4 = vp8_recon4b_c; | 84 rtcd->recon.recon4 = vp8_recon4b_c; |
| 40 rtcd->recon.recon_mb = vp8_recon_mb_c; | 85 rtcd->recon.recon_mb = vp8_recon_mb_c; |
| 41 rtcd->recon.recon_mby = vp8_recon_mby_c; | 86 rtcd->recon.recon_mby = vp8_recon_mby_c; |
| 42 rtcd->recon.build_intra_predictors_mby = | 87 rtcd->recon.build_intra_predictors_mby = |
| 43 vp8_build_intra_predictors_mby; | 88 vp8_build_intra_predictors_mby; |
| 44 rtcd->recon.build_intra_predictors_mby_s = | 89 rtcd->recon.build_intra_predictors_mby_s = |
| 45 vp8_build_intra_predictors_mby_s; | 90 vp8_build_intra_predictors_mby_s; |
| 91 rtcd->recon.build_intra_predictors_mbuv = |
| 92 vp8_build_intra_predictors_mbuv; |
| 93 rtcd->recon.build_intra_predictors_mbuv_s = |
| 94 vp8_build_intra_predictors_mbuv_s; |
| 95 rtcd->recon.intra4x4_predict = |
| 96 vp8_intra4x4_predict; |
| 46 | 97 |
| 47 rtcd->subpix.sixtap16x16 = vp8_sixtap_predict16x16_c; | 98 rtcd->subpix.sixtap16x16 = vp8_sixtap_predict16x16_c; |
| 48 rtcd->subpix.sixtap8x8 = vp8_sixtap_predict8x8_c; | 99 rtcd->subpix.sixtap8x8 = vp8_sixtap_predict8x8_c; |
| 49 rtcd->subpix.sixtap8x4 = vp8_sixtap_predict8x4_c; | 100 rtcd->subpix.sixtap8x4 = vp8_sixtap_predict8x4_c; |
| 50 rtcd->subpix.sixtap4x4 = vp8_sixtap_predict_c; | 101 rtcd->subpix.sixtap4x4 = vp8_sixtap_predict_c; |
| 51 rtcd->subpix.bilinear16x16 = vp8_bilinear_predict16x16_c; | 102 rtcd->subpix.bilinear16x16 = vp8_bilinear_predict16x16_c; |
| 52 rtcd->subpix.bilinear8x8 = vp8_bilinear_predict8x8_c; | 103 rtcd->subpix.bilinear8x8 = vp8_bilinear_predict8x8_c; |
| 53 rtcd->subpix.bilinear8x4 = vp8_bilinear_predict8x4_c; | 104 rtcd->subpix.bilinear8x4 = vp8_bilinear_predict8x4_c; |
| 54 rtcd->subpix.bilinear4x4 = vp8_bilinear_predict4x4_c; | 105 rtcd->subpix.bilinear4x4 = vp8_bilinear_predict4x4_c; |
| 55 | 106 |
| 56 rtcd->loopfilter.normal_mb_v = vp8_loop_filter_mbv_c; | 107 rtcd->loopfilter.normal_mb_v = vp8_loop_filter_mbv_c; |
| 57 rtcd->loopfilter.normal_b_v = vp8_loop_filter_bv_c; | 108 rtcd->loopfilter.normal_b_v = vp8_loop_filter_bv_c; |
| 58 rtcd->loopfilter.normal_mb_h = vp8_loop_filter_mbh_c; | 109 rtcd->loopfilter.normal_mb_h = vp8_loop_filter_mbh_c; |
| 59 rtcd->loopfilter.normal_b_h = vp8_loop_filter_bh_c; | 110 rtcd->loopfilter.normal_b_h = vp8_loop_filter_bh_c; |
| 60 rtcd->loopfilter.simple_mb_v = vp8_loop_filter_mbvs_c; | 111 rtcd->loopfilter.simple_mb_v = vp8_loop_filter_simple_vertical_edge_c; |
| 61 rtcd->loopfilter.simple_b_v = vp8_loop_filter_bvs_c; | 112 rtcd->loopfilter.simple_b_v = vp8_loop_filter_bvs_c; |
| 62 rtcd->loopfilter.simple_mb_h = vp8_loop_filter_mbhs_c; | 113 rtcd->loopfilter.simple_mb_h = vp8_loop_filter_simple_horizontal_edge_c; |
| 63 rtcd->loopfilter.simple_b_h = vp8_loop_filter_bhs_c; | 114 rtcd->loopfilter.simple_b_h = vp8_loop_filter_bhs_c; |
| 64 | 115 |
| 65 #if CONFIG_POSTPROC || (CONFIG_VP8_ENCODER && CONFIG_PSNR) | 116 #if CONFIG_POSTPROC || (CONFIG_VP8_ENCODER && CONFIG_INTERNAL_STATS) |
| 66 rtcd->postproc.down = vp8_mbpost_proc_down_c; | 117 rtcd->postproc.down = vp8_mbpost_proc_down_c; |
| 67 rtcd->postproc.across = vp8_mbpost_proc_across_ip_c; | 118 rtcd->postproc.across = vp8_mbpost_proc_across_ip_c; |
| 68 rtcd->postproc.downacross = vp8_post_proc_down_and_across_c; | 119 rtcd->postproc.downacross = vp8_post_proc_down_and_across_c; |
| 69 rtcd->postproc.addnoise = vp8_plane_add_noise_c; | 120 rtcd->postproc.addnoise = vp8_plane_add_noise_c; |
| 70 rtcd->postproc.blend_mb_inner = vp8_blend_mb_inner_c; | 121 rtcd->postproc.blend_mb_inner = vp8_blend_mb_inner_c; |
| 71 rtcd->postproc.blend_mb_outer = vp8_blend_mb_outer_c; | 122 rtcd->postproc.blend_mb_outer = vp8_blend_mb_outer_c; |
| 72 rtcd->postproc.blend_b = vp8_blend_b_c; | 123 rtcd->postproc.blend_b = vp8_blend_b_c; |
| 73 #endif | 124 #endif |
| 74 | 125 |
| 75 #endif | 126 #endif |
| 76 | 127 |
| 77 #if ARCH_X86 || ARCH_X86_64 | 128 #if ARCH_X86 || ARCH_X86_64 |
| 78 vp8_arch_x86_common_init(ctx); | 129 vp8_arch_x86_common_init(ctx); |
| 79 #endif | 130 #endif |
| 80 | 131 |
| 81 #if ARCH_ARM | 132 #if ARCH_ARM |
| 82 vp8_arch_arm_common_init(ctx); | 133 vp8_arch_arm_common_init(ctx); |
| 83 #endif | 134 #endif |
| 84 | 135 |
| 136 #if CONFIG_MULTITHREAD |
| 137 ctx->processor_core_count = get_cpu_count(); |
| 138 #endif /* CONFIG_MULTITHREAD */ |
| 85 } | 139 } |
| OLD | NEW |