libwebm: fixed rand() on windows
Change-Id: Ie17445072f10f91bdaabfba74a1be58764d78b94
This commit is contained in:
@@ -1831,6 +1831,9 @@ Segment::Segment()
|
||||
writer_header_(NULL) {
|
||||
const time_t curr_time = time(NULL);
|
||||
seed_ = static_cast<unsigned int>(curr_time);
|
||||
#ifdef _WIN32
|
||||
srand(seed_);
|
||||
#endif
|
||||
}
|
||||
|
||||
Segment::~Segment() {
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#ifdef _WIN32
|
||||
#define _CRT_RAND_S
|
||||
#endif
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
@@ -81,12 +84,12 @@ uint64 EbmlElementSize(uint64 type, uint64 value) {
|
||||
return ebml_size;
|
||||
}
|
||||
|
||||
uint64 EbmlElementSize(uint64 type, float value) {
|
||||
uint64 EbmlElementSize(uint64 type, float /* value */ ) {
|
||||
// Size of EBML ID
|
||||
uint64 ebml_size = GetUIntSize(type);
|
||||
|
||||
// Datasize
|
||||
ebml_size += sizeof(value);
|
||||
ebml_size += sizeof(float);
|
||||
|
||||
// Size of Datasize
|
||||
ebml_size++;
|
||||
@@ -508,7 +511,15 @@ mkvmuxer::uint64 mkvmuxer::MakeUID(unsigned int* seed) {
|
||||
for (int i = 0; i < 7; ++i) { // avoid problems with 8-byte values
|
||||
uid <<= 8;
|
||||
|
||||
#ifdef _WIN32
|
||||
(void)seed;
|
||||
unsigned int random_value;
|
||||
const errno_t e = rand_s(&random_value);
|
||||
(void)e;
|
||||
const int32 nn = random_value;
|
||||
#elif
|
||||
const int32 nn = rand_r(seed);
|
||||
#endif
|
||||
const int32 n = 0xFF & (nn >> 4); // throw away low-order bits
|
||||
|
||||
uid |= n;
|
||||
|
||||
@@ -164,6 +164,9 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="sample_muxer.cpp" />
|
||||
<ClCompile Include="sample_muxer_metadata.cc" />
|
||||
<ClCompile Include="vttreader.cc" />
|
||||
<ClCompile Include="webvttparser.cc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="libwebm_2010.vcxproj">
|
||||
@@ -171,6 +174,11 @@
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="sample_muxer_metadata.h" />
|
||||
<ClInclude Include="vttreader.h" />
|
||||
<ClInclude Include="webvttparser.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
|
||||
@@ -2,5 +2,13 @@
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<ClCompile Include="sample_muxer.cpp" />
|
||||
<ClCompile Include="sample_muxer_metadata.cc" />
|
||||
<ClCompile Include="vttreader.cc" />
|
||||
<ClCompile Include="webvttparser.cc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="sample_muxer_metadata.h" />
|
||||
<ClInclude Include="vttreader.h" />
|
||||
<ClInclude Include="webvttparser.h" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user