summaryrefslogtreecommitdiffstats
path: root/media/libstagefright
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2011-06-21 12:12:06 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-06-21 12:12:06 -0700
commit440060f943d9dab6cc5060a6e3159e173d52d9f7 (patch)
treebb2164e15a6d45ba445f3a7b5a3d84601570a530 /media/libstagefright
parent9067e30b3ccb3a07e41b61af22c036378053a9a3 (diff)
parentf3ac3e3c94c14dbf1cdf6a4577f0b3aa8edfad06 (diff)
downloadframeworks_av-440060f943d9dab6cc5060a6e3159e173d52d9f7.zip
frameworks_av-440060f943d9dab6cc5060a6e3159e173d52d9f7.tar.gz
frameworks_av-440060f943d9dab6cc5060a6e3159e173d52d9f7.tar.bz2
Merge "Boost software vp8 decoder performance using multi-threaded decoding if possible"
Diffstat (limited to 'media/libstagefright')
-rw-r--r--media/libstagefright/codecs/on2/dec/SoftVPX.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/media/libstagefright/codecs/on2/dec/SoftVPX.cpp b/media/libstagefright/codecs/on2/dec/SoftVPX.cpp
index e9ce719..7e83163 100644
--- a/media/libstagefright/codecs/on2/dec/SoftVPX.cpp
+++ b/media/libstagefright/codecs/on2/dec/SoftVPX.cpp
@@ -117,11 +117,27 @@ void SoftVPX::initPorts() {
addPort(def);
}
+static int GetCPUCoreCount() {
+ int cpuCoreCount = 1;
+#if defined(_SC_NPROCESSORS_ONLN)
+ cpuCoreCount = sysconf(_SC_NPROCESSORS_ONLN);
+#else
+ // _SC_NPROC_ONLN must be defined...
+ cpuCoreCount = sysconf(_SC_NPROC_ONLN);
+#endif
+ CHECK(cpuCoreCount >= 1);
+ LOGV("Number of CPU cores: %d", cpuCoreCount);
+ return cpuCoreCount;
+}
+
status_t SoftVPX::initDecoder() {
mCtx = new vpx_codec_ctx_t;
vpx_codec_err_t vpx_err;
+ vpx_codec_dec_cfg_t cfg;
+ memset(&cfg, 0, sizeof(vpx_codec_dec_cfg_t));
+ cfg.threads = GetCPUCoreCount();
if ((vpx_err = vpx_codec_dec_init(
- (vpx_codec_ctx_t *)mCtx, &vpx_codec_vp8_dx_algo, NULL, 0))) {
+ (vpx_codec_ctx_t *)mCtx, &vpx_codec_vp8_dx_algo, &cfg, 0))) {
LOGE("on2 decoder failed to initialize. (%d)", vpx_err);
return UNKNOWN_ERROR;
}