From 41686e847907b0ff0bd90873f0f312c88293cd63 Mon Sep 17 00:00:00 2001 From: "fbarchard@google.com" Date: Thu, 13 Oct 2011 17:47:39 +0000 Subject: [PATCH] remove linux.cc and simplify cpuid TEST=pulse build of talk against libyuv BUG=none Review URL: http://webrtc-codereview.appspot.com/224002 git-svn-id: http://libyuv.googlecode.com/svn/trunk@25 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- source/convert.cc | 85 --------- source/cpu_id.cc | 58 +----- source/cpu_id.h | 40 +---- source/format_conversion.cc | 2 +- source/linux.cc | 350 ------------------------------------ source/linux.h | 118 ------------ source/planar_functions.cc | 14 +- source/scale.cc | 20 +-- 8 files changed, 35 insertions(+), 652 deletions(-) delete mode 100644 source/linux.cc delete mode 100644 source/linux.h diff --git a/source/convert.cc b/source/convert.cc index 4e4394a09..8d6d1b1f7 100644 --- a/source/convert.cc +++ b/source/convert.cc @@ -632,91 +632,6 @@ NV12ToRGB565(const uint8* src_yplane, int src_ystride, return 0; } -int -I420ToABGR(const uint8* src_yplane, int src_ystride, - const uint8* src_uplane, int src_ustride, - const uint8* src_vplane, int src_vstride, - uint8* dst_frame, int dst_stride, - int src_width, int src_height) -{ - if (src_yplane == NULL || src_uplane == NULL || src_vplane == NULL || - dst_frame == NULL){ - return -1; - } - - // RGB orientation - bottom up - uint8* out = dst_frame + 4 * dst_stride * (src_height - 1); - uint8* out2 = out - dst_stride * 4; - int32 tmpR, tmpG, tmpB; - const uint8 *y1,*y2, *u, *v; - int h, w; - - y1 = src_yplane; - y2 = y1 + src_ystride; - u = src_uplane; - v = src_vplane; - - for (h = ((src_height + 1) >> 1); h > 0; h--){ - // 2 rows at a time, 2 y's at a time - for (w = 0; w < ((src_width + 1) >> 1); w++){ - // Vertical and horizontal sub-sampling - tmpR = (int32)((298 * (y1[0] - 16) + 409 * (v[0] - 128) + 128) >> 8); - tmpG = (int32)((298 * (y1[0] - 16) - 100 * (u[0] - 128) - - 208 * (v[0] - 128) + 128 ) >> 8); - tmpB = (int32)((298 * (y1[0] - 16) + 516 * (u[0] - 128) + 128 ) >> 8); - - out[0] = Clip(tmpR); - out[1] = Clip(tmpG); - out[2] = Clip(tmpB); - out[3] = 0xff; - - tmpR = (int32)((298 * (y1[1] - 16) + 409 * (v[0] - 128) + 128 ) >> 8); - tmpG = (int32)((298 * (y1[1] - 16) - 100 * (u[0] - 128) - - 208 * (v[0] - 128) + 128 ) >> 8); - tmpB = (int32)((298 * (y1[1] - 16) + 516 * (u[0] - 128) + 128) >> 8); - - out[4] = Clip(tmpR); - out[5] = Clip(tmpG); - out[6] = Clip(tmpB); - out[7] = 0xff; - - tmpR = (int32)((298 * (y2[0] - 16) + 409 * (v[0] - 128) + 128) >> 8); - tmpG = (int32)((298 * (y2[0] - 16) - 100 * (u[0] - 128) - - 208 * (v[0] - 128) + 128) >> 8); - tmpB = (int32)((298 * (y2[0] - 16) + 516 * (u[0] - 128) + 128) >> 8); - - out2[0] = Clip(tmpR); - out2[1] = Clip(tmpG); - out2[2] = Clip(tmpB); - out2[3] = 0xff; - - tmpR = (int32)((298 * (y2[1] - 16) + 409 * (v[0] - 128) + 128) >> 8); - tmpG = (int32)((298 * (y2[1] - 16) - 100 * (u[0] - 128) - - 208 * (v[0] - 128) + 128) >> 8); - tmpB = (int32)((298 * (y2[1] - 16) + 516 * (u[0] - 128) + 128 ) >> 8); - - out2[4] = Clip(tmpR); - out2[5] = Clip(tmpG); - out2[6] = Clip(tmpB); - out2[7] = 0xff; - - out += 8; - out2 += 8; - y1 += 2; - y2 += 2; - u++; - v++; - } - y1 += src_ystride + src_ystride - src_width; - y2 += src_ystride + src_ystride - src_width; - u += src_ustride - ((src_width + 1) >> 1); - v += src_vstride - ((src_width + 1) >> 1); - out -= (2 * dst_stride + src_width) * 4; - out2 -= (2 * dst_stride + src_width) * 4; - } // end height for - return 0; -} - int RGB24ToARGB(const uint8* src_frame, int src_stride, uint8* dst_frame, int dst_stride, diff --git a/source/cpu_id.cc b/source/cpu_id.cc index a538081d6..6d8655c12 100644 --- a/source/cpu_id.cc +++ b/source/cpu_id.cc @@ -8,13 +8,11 @@ * be found in the AUTHORS file in the root of the source tree. */ - #include "cpu_id.h" +#include "basic_types.h" // for CPU_X86 #ifdef _MSC_VER #include -#elif LINUX -#include "linux.h" #endif // TODO(fbarchard): Use cpuid.h when gcc 4.4 is used on OSX and Linux. @@ -41,76 +39,36 @@ static inline void __cpuid(int cpu_info[4], int info_type) { namespace libyuv { // CPU detect function for SIMD instruction sets. -bool CpuInfo::cpu_info_initialized_ = false; -int CpuInfo::cpu_info_ = 0; +static bool cpu_info_initialized_ = false; +static int cpu_info_ = 0; + // Global lock for cpu initialization. - -#ifdef CPU_X86 -void cpuid(int cpu_info[4], int info_type) { - __cpuid(cpu_info, info_type); -} -#endif - -void CpuInfo::InitCpuFlags() { +static void InitCpuFlags() { #ifdef CPU_X86 int cpu_info[4]; __cpuid(cpu_info, 1); cpu_info_ = (cpu_info[2] & 0x00000200 ? kCpuHasSSSE3 : 0) | - (cpu_info[3] & 0x04000000 ? kCpuHasSSE2 : 0); + (cpu_info[3] & 0x04000000 ? kCpuHasSSE2 : 0); #elif defined(__ARM_NEON__) // gcc -mfpu=neon defines __ARM_NEON__ // if code is specifically built for Neon-only, enable the flag. cpu_info_ |= kCpuHasNEON; -#elif LINUX && defined(__arm__) - cpu_info_ = 0; - // Look for NEON support in /proc/cpuinfo - ProcCpuInfo proc_info; - size_t section_count; - if (proc_info.LoadFromSystem() && - proc_info.GetSectionCount(§ion_count)) { - for (size_t i = 0; i < section_count; ++i) { - std::string out_features; - if (proc_info.GetSectionStringValue(i, "Features", &out_features)) { - if (out_features.find("neon") != std::string::npos) { - cpu_info_ |= kCpuHasNEON; - } - break; - } - } - } #else cpu_info_ = 0; #endif cpu_info_initialized_ = true; } -void CpuInfo::MaskCpuFlagsForTest(int enable_flags) { +void MaskCpuFlagsForTest(int enable_flags) { InitCpuFlags(); cpu_info_ &= enable_flags; } -bool CpuInfo::TestCpuFlag(int flag) { +bool TestCpuFlag(int flag) { if (!cpu_info_initialized_) { InitCpuFlags(); } return cpu_info_ & flag ? true : false; } -// Returns the vendor string from the cpu, e.g. "GenuineIntel", "AuthenticAMD". -// See "Intel Processor Identification and the CPUID Instruction" -// (Intel document number: 241618) -std::string CpuInfo::GetCpuVendor() { -#ifdef CPU_X86 - int cpu_info[4]; - cpuid(cpu_info, 0); - cpu_info[0] = cpu_info[1]; // Reorder output - cpu_info[1] = cpu_info[3]; - cpu_info[2] = cpu_info[2]; - cpu_info[3] = 0; - return std::string(reinterpret_cast(&cpu_info[0])); -#else - return std::string("Undefined"); -#endif -} - } // namespace libyuv diff --git a/source/cpu_id.h b/source/cpu_id.h index 2d1d1eeb7..ae33238ba 100644 --- a/source/cpu_id.h +++ b/source/cpu_id.h @@ -11,42 +11,20 @@ #ifndef LIBYUV_SOURCE_CPU_ID_H_ #define LIBYUV_SOURCE_CPU_ID_H_ -#include - -#include "basic_types.h" - namespace libyuv { -#ifdef CPU_X86 -void cpuid(int cpu_info[4], int info_type); -#endif -class CpuInfo { - public: - // These flags are only valid on x86 processors - static const int kCpuHasSSE2 = 1; - static const int kCpuHasSSSE3 = 2; +// These flags are only valid on x86 processors +static const int kCpuHasSSE2 = 1; +static const int kCpuHasSSSE3 = 2; - // SIMD support on ARM processors - static const int kCpuHasNEON = 4; +// SIMD support on ARM processors +static const int kCpuHasNEON = 4; - // Detect CPU has SSE2 etc. - static bool TestCpuFlag(int flag); +// Detect CPU has SSE2 etc. +bool TestCpuFlag(int flag); - // Detect CPU vendor: "GenuineIntel" or "AuthenticAMD" - static std::string GetCpuVendor(); - - // For testing, allow CPU flags to be disabled. - static void MaskCpuFlagsForTest(int enable_flags); - - private: - // Global lock for the cpu initialization - static bool cpu_info_initialized_; - static int cpu_info_; - - static void InitCpuFlags(); - - DISALLOW_IMPLICIT_CONSTRUCTORS(CpuInfo); -}; +// For testing, allow CPU flags to be disabled. +void MaskCpuFlagsForTest(int enable_flags); } // namespace libyuv diff --git a/source/format_conversion.cc b/source/format_conversion.cc index c16d9ff87..0db57ae4c 100644 --- a/source/format_conversion.cc +++ b/source/format_conversion.cc @@ -498,7 +498,7 @@ void ARGBToBayerRGB(const uint8* src_rgb, int src_pitch_rgb, void (*ARGBToBayerRow)(const uint8* src_argb, uint8* dst_bayer, uint32 selector, int pix); #if defined(HAS_ARGBTOBAYERROW_SSSE3) - if (libyuv::CpuInfo::TestCpuFlag(libyuv::CpuInfo::kCpuHasSSSE3) && + if (libyuv::TestCpuFlag(libyuv::kCpuHasSSSE3) && (width % 4 == 0) && IS_ALIGNED(src_rgb, 16) && (src_pitch_rgb % 16 == 0) && IS_ALIGNED(dst_bayer, 4) && (dst_pitch_bayer % 4 == 0)) { diff --git a/source/linux.cc b/source/linux.cc deleted file mode 100644 index 1c3aa9c14..000000000 --- a/source/linux.cc +++ /dev/null @@ -1,350 +0,0 @@ -/* - * Copyright (c) 2011 The LibYuv project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - - -#if defined(LINUX) || defined(ANDROID) -#include "linux.h" - -#include - -#include -#include -#include - -#include -#include - -namespace libyuv { - -static const char kCpuInfoFile[] = "/proc/cpuinfo"; -static const char kCpuMaxFreqFile[] = - "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq"; - -ProcCpuInfo::ProcCpuInfo() { -} - -ProcCpuInfo::~ProcCpuInfo() { -} - -bool ProcCpuInfo::LoadFromSystem() { - ConfigParser procfs; - if (!procfs.Open(kCpuInfoFile)) { - return false; - } - return procfs.Parse(§ions_); -}; - -bool ProcCpuInfo::GetSectionCount(size_t* count) { - if (sections_.empty()) { - return false; - } - if (count) { - *count = sections_.size(); - } - return true; -} - -bool ProcCpuInfo::GetNumCpus(int* num) { - if (sections_.empty()) { - return false; - } - int total_cpus = 0; -#if defined(__arm__) - // Count the number of blocks that have a "processor" key defined. On ARM, - // there may be extra blocks of information that aren't per-processor. - size_t section_count = sections_.size(); - for (size_t i = 0; i < section_count; ++i) { - int processor_id; - if (GetSectionIntValue(i, "processor", &processor_id)) { - ++total_cpus; - } - } - // Single core ARM systems don't include "processor" keys at all, so return - // that we have a single core if we didn't find any explicitly above. - if (total_cpus == 0) { - total_cpus = 1; - } -#else - // On X86, there is exactly one info section per processor. - total_cpus = static_cast(sections_.size()); -#endif - if (num) { - *num = total_cpus; - } - return true; -} - -bool ProcCpuInfo::GetNumPhysicalCpus(int* num) { - if (sections_.empty()) { - return false; - } - // TODO(noahric): /proc/cpuinfo only reports cores that are currently - // _online_, so this may underreport the number of physical cores. -#if defined(__arm__) - // ARM (currently) has no hyperthreading, so just return the same value - // as GetNumCpus. - return GetNumCpus(num); -#else - int total_cores = 0; - std::set physical_ids; - size_t section_count = sections_.size(); - for (size_t i = 0; i < section_count; ++i) { - int physical_id; - int cores; - // Count the cores for the physical id only if we have not counted the id. - if (GetSectionIntValue(i, "physical id", &physical_id) && - GetSectionIntValue(i, "cpu cores", &cores) && - physical_ids.find(physical_id) == physical_ids.end()) { - physical_ids.insert(physical_id); - total_cores += cores; - } - } - - if (num) { - *num = total_cores; - } - return true; -#endif -} - -bool ProcCpuInfo::GetCpuFamily(int* id) { - int cpu_family = 0; - -// shh { -#if defined(__arm__) - // On ChromeOS seaboard, there is no 'cpu family' in '/proc/cpuinfo'. But - // there is 'CPU Architecture' which can be used as 'cpu family'. - // See http://en.wikipedia.org/wiki/ARM_architecture for a good list of - // ARM cpu families, architectures, and their mappings. - // There may be multiple sessions that aren't per-processor. We need to scan - // through each session until we find the first 'CPU architecture'. - size_t section_count = sections_.size(); - for (size_t i = 0; i < section_count; ++i) { - if (GetSectionIntValue(i, "CPU architecture", &cpu_family)) { - // We returns the first one (if there are multiple entries). - break; - }; - } -#else -// shh } - GetSectionIntValue(0, "cpu family", &cpu_family); -// shh { -#endif -// shh } - - if (id) { - *id = cpu_family; - } - return true; -} - -bool ProcCpuInfo::GetSectionStringValue(size_t section_num, - const std::string& key, - std::string* result) { - if (section_num >= sections_.size()) { - return false; - } - ConfigParser::SimpleMap::iterator iter = sections_[section_num].find(key); - if (iter == sections_[section_num].end()) { - return false; - } - *result = iter->second; - return true; -} - -bool ProcCpuInfo::GetSectionIntValue(size_t section_num, - const std::string& key, - int* result) { - if (section_num >= sections_.size()) { - return false; - } - ConfigParser::SimpleMap::iterator iter = sections_[section_num].find(key); - if (iter == sections_[section_num].end()) { - return false; - } - return FromString(iter->second, result); -} - -ConfigParser::ConfigParser() {} - -ConfigParser::~ConfigParser() {} - -bool ConfigParser::Open(const std::string& filename) { - FileStream* fs = new FileStream(); - if (!fs->Open(filename, "r", NULL)) { - return false; - } - instream_.reset(fs); - return true; -} - -void ConfigParser::Attach(StreamInterface* stream) { - instream_.reset(stream); -} - -bool ConfigParser::Parse(MapVector* key_val_pairs) { - // Parses the file and places the found key-value pairs into key_val_pairs. - SimpleMap section; - while (ParseSection(§ion)) { - key_val_pairs->push_back(section); - section.clear(); - } - return (!key_val_pairs->empty()); -} - -bool ConfigParser::ParseSection(SimpleMap* key_val_pair) { - // Parses the next section in the filestream and places the found key-value - // pairs into key_val_pair. - std::string key, value; - while (ParseLine(&key, &value)) { - (*key_val_pair)[key] = value; - } - return (!key_val_pair->empty()); -} - -bool ConfigParser::ParseLine(std::string* key, std::string* value) { - // Parses the next line in the filestream and places the found key-value - // pair into key and val. - std::string line; - if ((instream_->ReadLine(&line)) == EOF) { - return false; - } - std::vector tokens; - if (2 != split(line, ':', &tokens)) { - return false; - } - // Removes whitespace at the end of Key name - size_t pos = tokens[0].length() - 1; - while ((pos > 0) && isspace(tokens[0][pos])) { - pos--; - } - tokens[0].erase(pos + 1); - // Removes whitespace at the start of value - pos = 0; - while (pos < tokens[1].length() && isspace(tokens[1][pos])) { - pos++; - } - tokens[1].erase(0, pos); - *key = tokens[0]; - *value = tokens[1]; - return true; -} - -static bool ExpectLineFromStream(FileStream* stream, - std::string* out) { - StreamResult res = stream->ReadLine(out); - if (res != SR_SUCCESS) { - if (res != SR_EOS) { - LOG(LS_ERROR) << "Error when reading from stream"; - } else { - LOG(LS_ERROR) << "Incorrect number of lines in stream"; - } - return false; - } - return true; -} - -static void ExpectEofFromStream(FileStream* stream) { - std::string unused; - StreamResult res = stream->ReadLine(&unused); - if (res == SR_SUCCESS) { - LOG(LS_WARNING) << "Ignoring unexpected extra lines from stream"; - } else if (res != SR_EOS) { - LOG(LS_WARNING) << "Error when checking for extra lines from stream"; - } -} - -// For caching the lsb_release output (reading it invokes a sub-process and -// hence is somewhat expensive). -static std::string lsb_release_string; -static CriticalSection lsb_release_string_critsec; - -std::string ReadLinuxLsbRelease() { - CritScope cs(&lsb_release_string_critsec); - if (!lsb_release_string.empty()) { - // Have cached result from previous call. - return lsb_release_string; - } - // No cached result. Run lsb_release and parse output. - POpenStream lsb_release_output; - if (!lsb_release_output.Open("lsb_release -idrcs", "r", NULL)) { - LOG_ERR(LS_ERROR) << "Can't run lsb_release"; - return lsb_release_string; // empty - } - // Read in the command's output and build the string. - std::ostringstream sstr; - std::string line; - int wait_status; - - if (!ExpectLineFromStream(&lsb_release_output, &line)) { - return lsb_release_string; // empty - } - sstr << "DISTRIB_ID=" << line; - - if (!ExpectLineFromStream(&lsb_release_output, &line)) { - return lsb_release_string; // empty - } - sstr << " DISTRIB_DESCRIPTION=\"" << line << '"'; - - if (!ExpectLineFromStream(&lsb_release_output, &line)) { - return lsb_release_string; // empty - } - sstr << " DISTRIB_RELEASE=" << line; - - if (!ExpectLineFromStream(&lsb_release_output, &line)) { - return lsb_release_string; // empty - } - sstr << " DISTRIB_CODENAME=" << line; - - // Should not be anything left. - ExpectEofFromStream(&lsb_release_output); - - lsb_release_output.Close(); - wait_status = lsb_release_output.GetWaitStatus(); - if (wait_status == -1 || - !WIFEXITED(wait_status) || - WEXITSTATUS(wait_status) != 0) { - LOG(LS_WARNING) << "Unexpected exit status from lsb_release"; - } - - lsb_release_string = sstr.str(); - - return lsb_release_string; -} - -std::string ReadLinuxUname() { - struct utsname buf; - if (uname(&buf) < 0) { - LOG_ERR(LS_ERROR) << "Can't call uname()"; - return std::string(); - } - std::ostringstream sstr; - sstr << buf.sysname << " " - << buf.release << " " - << buf.version << " " - << buf.machine; - return sstr.str(); -} - -int ReadCpuMaxFreq() { - FileStream fs; - std::string str; - int freq = -1; - if (!fs.Open(kCpuMaxFreqFile, "r", NULL) || - SR_SUCCESS != fs.ReadLine(&str) || - !FromString(str, &freq)) { - return -1; - } - return freq; -} - -} // namespace libyuv - -#endif // defined(LINUX) || defined(ANDROID) diff --git a/source/linux.h b/source/linux.h deleted file mode 100644 index 3d5d0c8f4..000000000 --- a/source/linux.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2011 The LibYuv project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef LIBYUV_SOURCE_LINUX_H_ -#define LIBYUV_SOURCE_LINUX_H_ - -#if defined(LINUX) || defined(ANDROID) -#include -#include -#include - -namespace libyuv { - -////////////////////////////////////////////////////////////////////////////// -// ConfigParser parses a FileStream of an ".ini."-type format into a map. -////////////////////////////////////////////////////////////////////////////// - -// Sample Usage: -// ConfigParser parser; -// ConfigParser::MapVector key_val_pairs; -// if (parser.Open(inifile) && parser.Parse(&key_val_pairs)) { -// for (int section_num=0; i < key_val_pairs.size(); ++section_num) { -// std::string val1 = key_val_pairs[section_num][key1]; -// std::string val2 = key_val_pairs[section_num][key2]; -// // Do something with valn; -// } -// } - -class ConfigParser { - public: - typedef std::map SimpleMap; - typedef std::vector MapVector; - - ConfigParser(); - virtual ~ConfigParser(); - - virtual bool Open(const std::string& filename); - virtual void Attach(StreamInterface* stream); - virtual bool Parse(MapVector* key_val_pairs); - virtual bool ParseSection(SimpleMap* key_val_pair); - virtual bool ParseLine(std::string* key, std::string* value); - - private: - scoped_ptr instream_; -}; - -////////////////////////////////////////////////////////////////////////////// -// ProcCpuInfo reads CPU info from the /proc subsystem on any *NIX platform. -////////////////////////////////////////////////////////////////////////////// - -// Sample Usage: -// ProcCpuInfo proc_info; -// int no_of_cpu; -// if (proc_info.LoadFromSystem()) { -// std::string out_str; -// proc_info.GetNumCpus(&no_of_cpu); -// proc_info.GetCpuStringValue(0, "vendor_id", &out_str); -// } -// } - -class ProcCpuInfo { - public: - ProcCpuInfo(); - virtual ~ProcCpuInfo(); - - // Reads the proc subsystem's cpu info into memory. If this fails, this - // returns false; if it succeeds, it returns true. - virtual bool LoadFromSystem(); - - // Obtains the number of logical CPU threads and places the value num. - virtual bool GetNumCpus(int* num); - - // Obtains the number of physical CPU cores and places the value num. - virtual bool GetNumPhysicalCpus(int* num); - - // Obtains the CPU family id. - virtual bool GetCpuFamily(int* id); - - // Obtains the number of sections in /proc/cpuinfo, which may be greater - // than the number of CPUs (e.g. on ARM) - virtual bool GetSectionCount(size_t* count); - - // Looks for the CPU proc item with the given name for the given section - // number and places the string value in result. - virtual bool GetSectionStringValue(size_t section_num, const std::string& key, - std::string* result); - - // Looks for the CPU proc item with the given name for the given section - // number and places the int value in result. - virtual bool GetSectionIntValue(size_t section_num, const std::string& key, - int* result); - - private: - ConfigParser::MapVector sections_; -}; - -// Builds a string containing the info from lsb_release on a single line. -std::string ReadLinuxLsbRelease(); - -// Returns the output of "uname". -std::string ReadLinuxUname(); - -// Returns the content (int) of -// /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq -// Returns -1 on error. -int ReadCpuMaxFreq(); - -} // namespace libyuv - -#endif // defined(LINUX) || defined(ANDROID) -#endif // LIBYUV_SOURCE_LINUX_H_ diff --git a/source/planar_functions.cc b/source/planar_functions.cc index 8b0a06111..56683f7ce 100644 --- a/source/planar_functions.cc +++ b/source/planar_functions.cc @@ -357,7 +357,7 @@ static void X420ToI420(const uint8* src_y, int halfwidth = (width + 1) >> 1; void (*SplitUV)(const uint8* src_uv, uint8* dst_u, uint8* dst_v, int pix); #if defined(HAS_SPLITUV_NEON) - if (libyuv::CpuInfo::TestCpuFlag(libyuv::CpuInfo::kCpuHasNEON) && + if (libyuv::TestCpuFlag(libyuv::kCpuHasNEON) && (halfwidth % 16 == 0) && IS_ALIGNED(src_uv, 16) && (src_pitch_uv % 16 == 0) && IS_ALIGNED(dst_u, 16) && (dst_pitch_u % 16 == 0) && @@ -365,7 +365,7 @@ static void X420ToI420(const uint8* src_y, SplitUV = SplitUV_NEON; } else #elif defined(HAS_SPLITUV_SSSE3) - if (libyuv::CpuInfo::TestCpuFlag(libyuv::CpuInfo::kCpuHasSSSE3) && + if (libyuv::TestCpuFlag(libyuv::kCpuHasSSSE3) && (halfwidth % 16 == 0) && IS_ALIGNED(src_uv, 16) && (src_pitch_uv % 16 == 0) && IS_ALIGNED(dst_u, 16) && (dst_pitch_u % 16 == 0) && @@ -373,7 +373,7 @@ static void X420ToI420(const uint8* src_y, SplitUV = SplitUV_SSSE3; } else #elif defined(HAS_SPLITUV_SSE2) - if (libyuv::CpuInfo::TestCpuFlag(libyuv::CpuInfo::kCpuHasSSE2) && + if (libyuv::TestCpuFlag(libyuv::kCpuHasSSE2) && (halfwidth % 16 == 0) && IS_ALIGNED(src_uv, 16) && (src_pitch_uv % 16 == 0) && IS_ALIGNED(dst_u, 16) && (dst_pitch_u % 16 == 0) && @@ -552,7 +552,7 @@ void Q420ToI420(const uint8* src_y, int src_pitch_y, void (*SplitYUY2)(const uint8* src_yuy2, uint8* dst_y, uint8* dst_u, uint8* dst_v, int pix); #if defined(HAS_SPLITYUY2_SSE2) - if (libyuv::CpuInfo::TestCpuFlag(libyuv::CpuInfo::kCpuHasSSE2) && + if (libyuv::TestCpuFlag(libyuv::kCpuHasSSE2) && (width % 16 == 0) && IS_ALIGNED(src_yuy2, 16) && (src_pitch_yuy2 % 16 == 0) && IS_ALIGNED(dst_y, 16) && (dst_pitch_y % 16 == 0) && @@ -931,7 +931,7 @@ void YUY2ToI420(const uint8* src_yuy2, int src_pitch_yuy2, void (*YUY2ToI420RowY)(const uint8* src_yuy2, uint8* dst_y, int pix); #if defined(HAS_YUY2TOI420ROW_SSE2) - if (libyuv::CpuInfo::TestCpuFlag(libyuv::CpuInfo::kCpuHasSSE2) && + if (libyuv::TestCpuFlag(libyuv::kCpuHasSSE2) && (width % 16 == 0) && IS_ALIGNED(src_yuy2, 16) && (src_pitch_yuy2 % 16 == 0) && IS_ALIGNED(dst_y, 16) && (dst_pitch_y % 16 == 0) && @@ -971,7 +971,7 @@ void UYVYToI420(const uint8* src_uyvy, int src_pitch_uyvy, void (*UYVYToI420RowY)(const uint8* src_uyvy, uint8* dst_y, int pix); #if defined(HAS_UYVYTOI420ROW_SSE2) - if (libyuv::CpuInfo::TestCpuFlag(libyuv::CpuInfo::kCpuHasSSE2) && + if (libyuv::TestCpuFlag(libyuv::kCpuHasSSE2) && (width % 16 == 0) && IS_ALIGNED(src_uyvy, 16) && (src_pitch_uyvy % 16 == 0) && IS_ALIGNED(dst_y, 16) && (dst_pitch_y % 16 == 0) && @@ -1188,7 +1188,7 @@ void I400ToARGB(const uint8* src_y, int src_pitch_y, int width, int height) { void (*I400ToARGBRow)(const uint8* src_y, uint8* dst_argb, int pix); #if defined(HAS_I400TOARGBROW_SSE2) - if (libyuv::CpuInfo::TestCpuFlag(libyuv::CpuInfo::kCpuHasSSE2) && + if (libyuv::TestCpuFlag(libyuv::kCpuHasSSE2) && (width % 8 == 0) && IS_ALIGNED(src_y, 8) && (src_pitch_y % 8 == 0) && IS_ALIGNED(dst_argb, 16) && (dst_pitch_argb % 16 == 0)) { diff --git a/source/scale.cc b/source/scale.cc index f056de50b..2f802c93e 100644 --- a/source/scale.cc +++ b/source/scale.cc @@ -2182,14 +2182,14 @@ static void ScalePlaneDown2(int32 iwidth, int32 iheight, uint8* orow, int32 owidth); #if defined(HAS_SCALEROWDOWN2_NEON) - if (libyuv::CpuInfo::TestCpuFlag(libyuv::CpuInfo::kCpuHasNEON) && + if (libyuv::TestCpuFlag(libyuv::kCpuHasNEON) && (owidth % 16 == 0) && (istride % 16 == 0) && (ostride % 16 == 0) && IS_ALIGNED(iptr, 16) && IS_ALIGNED(optr, 16)) { ScaleRowDown2 = interpolate ? ScaleRowDown2Int_NEON : ScaleRowDown2_NEON; } else #endif #if defined(HAS_SCALEROWDOWN2_SSE2) - if (libyuv::CpuInfo::TestCpuFlag(libyuv::CpuInfo::kCpuHasSSE2) && + if (libyuv::TestCpuFlag(libyuv::kCpuHasSSE2) && (owidth % 16 == 0) && IS_ALIGNED(iptr, 16) && IS_ALIGNED(optr, 16)) { ScaleRowDown2 = interpolate ? ScaleRowDown2Int_SSE2 : ScaleRowDown2_SSE2; } else @@ -2222,7 +2222,7 @@ static void ScalePlaneDown4(int32 iwidth, int32 iheight, uint8* orow, int32 owidth); #if defined(HAS_SCALEROWDOWN4_SSE2) - if (libyuv::CpuInfo::TestCpuFlag(libyuv::CpuInfo::kCpuHasSSE2) && + if (libyuv::TestCpuFlag(libyuv::kCpuHasSSE2) && (owidth % 8 == 0) && (istride % 16 == 0) && (ostride % 8 == 0) && IS_ALIGNED(iptr, 16) && IS_ALIGNED(optr, 8)) { ScaleRowDown4 = interpolate ? ScaleRowDown4Int_SSE2 : ScaleRowDown4_SSE2; @@ -2256,7 +2256,7 @@ static void ScalePlaneDown8(int32 iwidth, int32 iheight, void (*ScaleRowDown8)(const uint8* iptr, int32 istride, uint8* orow, int32 owidth); #if defined(HAS_SCALEROWDOWN8_SSE2) - if (libyuv::CpuInfo::TestCpuFlag(libyuv::CpuInfo::kCpuHasSSE2) && + if (libyuv::TestCpuFlag(libyuv::kCpuHasSSE2) && (owidth % 16 == 0) && owidth <= kMaxOutputWidth && (istride % 16 == 0) && (ostride % 16 == 0) && IS_ALIGNED(iptr, 16) && IS_ALIGNED(optr, 16)) { @@ -2291,7 +2291,7 @@ static void ScalePlaneDown34(int32 iwidth, int32 iheight, void (*ScaleRowDown34_1)(const uint8* iptr, int32 istride, uint8* orow, int32 owidth); #if defined(HAS_SCALEROWDOWN34_SSSE3) - if (libyuv::CpuInfo::TestCpuFlag(libyuv::CpuInfo::kCpuHasSSSE3) && + if (libyuv::TestCpuFlag(libyuv::kCpuHasSSSE3) && (owidth % 24 == 0) && (istride % 16 == 0) && (ostride % 8 == 0) && IS_ALIGNED(iptr, 16) && IS_ALIGNED(optr, 8)) { if (!interpolate) { @@ -2304,7 +2304,7 @@ static void ScalePlaneDown34(int32 iwidth, int32 iheight, } else #endif #if defined(HAS_SCALEROWDOWN34_SSE2) - if (libyuv::CpuInfo::TestCpuFlag(libyuv::CpuInfo::kCpuHasSSE2) && + if (libyuv::TestCpuFlag(libyuv::kCpuHasSSE2) && (owidth % 24 == 0) && (istride % 16 == 0) && (ostride % 8 == 0) && IS_ALIGNED(iptr, 16) && IS_ALIGNED(optr, 8) && interpolate) { @@ -2372,7 +2372,7 @@ static void ScalePlaneDown38(int32 iwidth, int32 iheight, void (*ScaleRowDown38_2)(const uint8* iptr, int32 istride, uint8* orow, int32 owidth); #if defined(HAS_SCALEROWDOWN38_SSSE3) - if (libyuv::CpuInfo::TestCpuFlag(libyuv::CpuInfo::kCpuHasSSSE3) && + if (libyuv::TestCpuFlag(libyuv::kCpuHasSSSE3) && (owidth % 24 == 0) && (istride % 16 == 0) && (ostride % 8 == 0) && IS_ALIGNED(iptr, 16) && IS_ALIGNED(optr, 8)) { if (!interpolate) { @@ -2520,7 +2520,7 @@ static void ScalePlaneBox(int32 iwidth, int32 iheight, void (*ScaleAddCols)(int32 owidth, int32 boxheight, int dx, const uint16 *iptr, uint8 *optr); #if defined(HAS_SCALEADDROWS_SSE2) - if (libyuv::CpuInfo::TestCpuFlag(libyuv::CpuInfo::kCpuHasSSE2) && + if (libyuv::TestCpuFlag(libyuv::kCpuHasSSE2) && (istride % 16 == 0) && IS_ALIGNED(iptr, 16) && (iwidth % 16) == 0) { ScaleAddRows = ScaleAddRows_SSE2; } else @@ -2611,13 +2611,13 @@ static void ScalePlaneBilinear(int32 iwidth, int32 iheight, void (*ScaleFilterCols)(uint8* optr, const uint8* iptr, int owidth, int dx); #if defined(HAS_SCALEFILTERROWS_SSSE3) - if (libyuv::CpuInfo::TestCpuFlag(libyuv::CpuInfo::kCpuHasSSSE3) && + if (libyuv::TestCpuFlag(libyuv::kCpuHasSSSE3) && (istride % 16 == 0) && IS_ALIGNED(iptr, 16) && (iwidth % 16) == 0) { ScaleFilterRows = ScaleFilterRows_SSSE3; } else #endif #if defined(HAS_SCALEFILTERROWS_SSE2) - if (libyuv::CpuInfo::TestCpuFlag(libyuv::CpuInfo::kCpuHasSSE2) && + if (libyuv::TestCpuFlag(libyuv::kCpuHasSSE2) && (istride % 16 == 0) && IS_ALIGNED(iptr, 16) && (iwidth % 16) == 0) { ScaleFilterRows = ScaleFilterRows_SSE2; } else