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