From 398da989f93bf16d9a567f6be82e044df13302f8 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Fri, 21 Mar 2008 03:02:39 +0000 Subject: [PATCH] Fixed small OpenMP bug. Originally committed to SVN as r2089. --- aegilib/aegilib.vcproj | 17 ++++++++++++++--- aegilib/src/utils.cpp | 30 +++++++++++++++--------------- aegisub/audio_spectrum.cpp | 2 +- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/aegilib/aegilib.vcproj b/aegilib/aegilib.vcproj index 8043c7fed..0cbee39ce 100644 --- a/aegilib/aegilib.vcproj +++ b/aegilib/aegilib.vcproj @@ -97,7 +97,7 @@ Name="Release|Win32" OutputDirectory="$(SolutionDir)$(ConfigurationName)" IntermediateDirectory="$(ConfigurationName)" - ConfigurationType="4" + ConfigurationType="2" CharacterSet="1" WholeProgramOptimization="1" > @@ -123,9 +123,11 @@ AdditionalIncludeDirectories="include/aegilib" PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_WINDOWS" RuntimeLibrary="2" - OpenMP="true" + OpenMP="false" UsePrecompiledHeader="2" PrecompiledHeaderThrough="prec.h" + AssemblerOutput="4" + AssemblerListingLocation="$(IntDir)\" WarningLevel="4" WarnAsError="true" Detect64BitPortabilityProblems="true" @@ -144,11 +146,14 @@ Name="VCPreLinkEventTool" /> + @@ -158,6 +163,12 @@ + + diff --git a/aegilib/src/utils.cpp b/aegilib/src/utils.cpp index 4dd3a4964..bb0ff76df 100644 --- a/aegilib/src/utils.cpp +++ b/aegilib/src/utils.cpp @@ -236,24 +236,21 @@ size_t Athenasub::GetUTF8Len(const wchar_t *utf16) // Convert UTF-16 to UTF-8 size_t Athenasub::UTF16toUTF8(const wchar_t *utf16,char *utf8) { - wchar_t curChar = 1; + wchar_t curChar = utf16[0]; size_t value; size_t written = 0; for (size_t i=0;;i++) { - // Get next - curChar = utf16[i]; - // 1 byte if ((curChar & 0xFF80) == 0) { - *utf8++ = char(curChar); + utf8[written] = char(curChar); if (curChar == 0) break; written++; } // 2 bytes else if ((curChar & 0xF800) == 0) { - *utf8++ = char(((curChar & 0x07C0) >> 6) | 0xC0); - *utf8++ = char((curChar & 0x003F) | 0x80); + utf8[written] = char(((curChar & 0x07C0) >> 6) | 0xC0); + utf8[written+1] = char((curChar & 0x003F) | 0x80); written += 2; } @@ -261,24 +258,27 @@ size_t Athenasub::UTF16toUTF8(const wchar_t *utf16,char *utf8) else if ((curChar & 0xFC00) == 0xD800) { // Read value = (curChar - 0xD800) << 10; + value |= utf16[i+1] & 0x3FF; i++; - value |= utf16[i] & 0x3FF; // Write - *utf8++ = char(((value & 0x1C0000) >> 18) | 0xF0); - *utf8++ = char(((value & 0x03F000) >> 12) | 0x80); - *utf8++ = char(((value & 0x000FC0) >> 6) | 0x80); - *utf8++ = char((value & 0x00003F) | 0x80); + utf8[written] = char(((value & 0x1C0000) >> 18) | 0xF0); + utf8[written+1] = char(((value & 0x03F000) >> 12) | 0x80); + utf8[written+2] = char(((value & 0x000FC0) >> 6) | 0x80); + utf8[written+3] = char((value & 0x00003F) | 0x80); written += 4; } // 3 bytes else if (curChar & 0xF800) { - *utf8++ = char(((curChar & 0xF000) >> 12) | 0xE0); - *utf8++ = char(((curChar & 0x0FC0) >> 6) | 0x80); - *utf8++ = char((curChar & 0x003F) | 0x80); + utf8[written] = char(((curChar & 0xF000) >> 12) | 0xE0); + utf8[written+1] = char(((curChar & 0x0FC0) >> 6) | 0x80); + utf8[written+2] = char((curChar & 0x003F) | 0x80); written += 3; } + + // Get next + curChar = utf16[i+1]; } return written; } diff --git a/aegisub/audio_spectrum.cpp b/aegisub/audio_spectrum.cpp index 585ebd1bf..7e63c672b 100644 --- a/aegisub/audio_spectrum.cpp +++ b/aegisub/audio_spectrum.cpp @@ -168,7 +168,7 @@ public: long len = length; #ifdef _OPENMP -#pragma omp parallel shared(overlap,len,line_length) +#pragma omp parallel shared(overlap,len) #endif { short *raw_sample_data = new short[line_length*2];