本文整理汇总了C++中IsNaN函数的典型用法代码示例。如果您正苦于以下问题:C++ IsNaN函数的具体用法?C++ IsNaN怎么用?C++ IsNaN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsNaN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MOZ_ASSERT
void
SourceBuffer::Remove(double aStart, double aEnd, ErrorResult& aRv)
{
MOZ_ASSERT(NS_IsMainThread());
MSE_API("SourceBuffer(%p)::Remove(aStart=%f, aEnd=%f)", this, aStart, aEnd);
if (!IsAttached()) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
if (IsNaN(mMediaSource->Duration()) ||
aStart < 0 || aStart > mMediaSource->Duration() ||
aEnd <= aStart || IsNaN(aEnd)) {
aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
return;
}
if (mUpdating || mMediaSource->ReadyState() != MediaSourceReadyState::Open) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
StartUpdating();
/// TODO: Run coded frame removal algorithm.
// Run the final step of the coded frame removal algorithm asynchronously
// to ensure the SourceBuffer's updating flag transition behaves as
// required by the spec.
nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(this, &SourceBuffer::StopUpdating);
NS_DispatchToMainThread(event);
}
示例2: MOZ_ASSERT
void
SourceBuffer::Remove(double aStart, double aEnd, ErrorResult& aRv)
{
MOZ_ASSERT(NS_IsMainThread());
MSE_API("Remove(aStart=%f, aEnd=%f)", aStart, aEnd);
if (!IsAttached()) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
if (mUpdating) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
if (IsNaN(mMediaSource->Duration()) ||
aStart < 0 || aStart > mMediaSource->Duration() ||
aEnd <= aStart || IsNaN(aEnd)) {
aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
return;
}
if (mMediaSource->ReadyState() == MediaSourceReadyState::Ended) {
mMediaSource->SetReadyState(MediaSourceReadyState::Open);
}
RangeRemoval(aStart, aEnd);
}
示例3: MOZ_ASSERT
void
SourceBuffer::Remove(double aStart, double aEnd, ErrorResult& aRv)
{
MOZ_ASSERT(NS_IsMainThread());
MSE_API("Remove(aStart=%f, aEnd=%f)", aStart, aEnd);
if (!IsAttached()) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
if (mUpdating) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
if (IsNaN(mMediaSource->Duration()) ||
aStart < 0 || aStart > mMediaSource->Duration() ||
aEnd <= aStart || IsNaN(aEnd)) {
aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
return;
}
if (mMediaSource->ReadyState() == MediaSourceReadyState::Ended) {
mMediaSource->SetReadyState(MediaSourceReadyState::Open);
}
StartUpdating();
nsCOMPtr<nsIRunnable> task = new RangeRemovalRunnable(this, aStart, aEnd);
NS_DispatchToMainThread(task);
}
示例4: MOZ_ASSERT
media::TimeIntervals
MediaSourceDecoder::GetSeekable()
{
MOZ_ASSERT(NS_IsMainThread());
if (!mMediaSource) {
NS_WARNING("MediaSource element isn't attached");
return media::TimeIntervals::Invalid();
}
media::TimeIntervals seekable;
double duration = mMediaSource->Duration();
if (IsNaN(duration)) {
// Return empty range.
} else if (duration > 0 && mozilla::IsInfinite(duration)) {
media::TimeIntervals buffered = GetBuffered();
if (buffered.Length()) {
seekable +=
media::TimeInterval(media::TimeUnit::FromSeconds(0), buffered.GetEnd());
}
} else {
seekable += media::TimeInterval(media::TimeUnit::FromSeconds(0),
media::TimeUnit::FromSeconds(duration));
}
MSE_DEBUG("ranges=%s", DumpTimeRanges(seekable).get());
return seekable;
}
示例5: calculateNormalizationScale
static float calculateNormalizationScale(ThreadSharedFloatArrayBufferList* response, size_t aLength, float sampleRate)
{
// Normalize by RMS power
size_t numberOfChannels = response->GetChannels();
float power = 0;
for (size_t i = 0; i < numberOfChannels; ++i) {
float channelPower = AudioBufferSumOfSquares(static_cast<const float*>(response->GetData(i)), aLength);
power += channelPower;
}
power = sqrt(power / (numberOfChannels * aLength));
// Protect against accidental overload
if (!IsFinite(power) || IsNaN(power) || power < MinPower)
power = MinPower;
float scale = 1 / power;
scale *= GainCalibration; // calibrate to make perceived volume same as unprocessed
// Scale depends on sample-rate.
if (sampleRate)
scale *= GainCalibrationSampleRate / sampleRate;
// True-stereo compensation
if (response->GetChannels() == 4)
scale *= 0.5f;
return scale;
}
示例6: IsCacheCorrect
// For NaNs, etc.
static bool IsCacheCorrect(float cached, float actual) {
if (IsNaN(cached)) {
// GL is allowed to do anything it wants for NaNs, so if we're shadowing
// a NaN, then whatever `actual` is might be correct.
return true;
}
return cached == actual;
}
示例7: CheckNaN
void CheckNaN( const Matrix44& matrix )
{
for (int i = 0; i < 16; ++i)
{
if (IsNaN( matrix.m[ i ] ))
{
//std::cerr << "Matrix contains NaN" << std::endl;
}
}
}
示例8: MOZ_ASSERT
void
SourceBuffer::Remove(double aStart, double aEnd, ErrorResult& aRv)
{
MOZ_ASSERT(NS_IsMainThread());
MSE_API("SourceBuffer(%p)::Remove(aStart=%f, aEnd=%f)", this, aStart, aEnd);
if (IsNaN(mMediaSource->Duration()) ||
aStart < 0 || aStart > mMediaSource->Duration() ||
aEnd <= aStart || IsNaN(aEnd)) {
aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
return;
}
if (!IsAttached() || mUpdating ||
mMediaSource->ReadyState() != MediaSourceReadyState::Open) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
StartUpdating();
/// TODO: Run coded frame removal algorithm asynchronously (would call StopUpdating()).
StopUpdating();
}
示例9: TestDouble
/* Test given float values */
void TestDouble(double a, double b)
{
DOUB_LONG param1, param2, result, check;
param1.d = a;
param2.d = b;
check.d = param1.d + param2.d;
result.l = DoubleAdd (param1.l, param2.l);
#if ALWAYS_PRINT
printf("\n");
Display(param1, param2, result);
#endif
if (result.l != check.l && !(IsNaN(result.l) && IsNaN(check.l)) &&
!(IsZero(result.l) && IsZero(check.l)))
{
printf("\nFailed! Answer should be %e (%08lx).\n", check.d, check.l);
Display(param1, param2, result);
printf("\n");
}
}
示例10: f4PlaneCoefs
bool Ray::Intersects(const Plane& plane, F32* distance) const {
Vector3f planeNormal = plane.GetNormal();
Vector3f rayEnd = origin + direction * this->distance;
XMFLOAT4 f4PlaneCoefs(planeNormal.x, planeNormal.y, planeNormal.z, plane.GetDistance());
XMFLOAT3 f3RayBegin(origin.v);
XMFLOAT3 f3RayEnd(rayEnd.v);
XMVECTOR vPlaneCoefs = XMLoadFloat4(&f4PlaneCoefs);
XMVECTOR vRayBegin = XMLoadFloat3(&f3RayBegin);
XMVECTOR vRayEnd = XMLoadFloat3(&f3RayEnd);
XMVECTOR vIntersection = XMPlaneIntersectLine(vPlaneCoefs, vRayBegin, vRayEnd);
XMFLOAT3 f3Intersection;
XMStoreFloat3(&f3Intersection, vIntersection);
if (IsNaN(f3Intersection.x) || IsNaN(f3Intersection.y) || IsNaN(f3Intersection.z)) {
return false;
} else {
*distance = Vector3f::Distance(origin, Vector3f(f3Intersection.x, f3Intersection.y, f3Intersection.z));
return true;
}
}
示例11: find_minmax
/* ------------------------------------------------------------------------
* Function: find_minmax
* ------------------------------------------------------------------------ */
void find_minmax(double *input, int M,
double *minval, int *minind, double *maxval, int *maxind)
{
int i;
for (i = 0; i < M; i++) {
if (!IsNaN(input[i])) { // init min/max to first non-NAN element
*minval = input[i]; *minind = i;
*maxval = input[i]; *maxind = i;
break;
}
}
if (i == M) { // special case: if all NaNs
*minval = GetNaN(); *minind = 0; *maxval = GetNaN(); *maxind = 0;
}
for (; i < M; i++) { // go through keeping track of min/max
if ((input[i] < *minval) && (!IsNaN(input[i])))
{*minval = input[i]; *minind = i;}
else if ((input[i] > *maxval) && (!IsNaN(input[i])))
{*maxval = input[i]; *maxind = i;}
}
}
示例12: MOZ_ASSERT
void
SourceBuffer::SetAppendWindowEnd(double aAppendWindowEnd, ErrorResult& aRv)
{
MOZ_ASSERT(NS_IsMainThread());
MSE_API("SetAppendWindowEnd(aAppendWindowEnd=%f)", aAppendWindowEnd);
if (!IsAttached() || mUpdating) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
if (IsNaN(aAppendWindowEnd) || aAppendWindowEnd <= mAppendWindowStart) {
aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
return;
}
mAppendWindowEnd = aAppendWindowEnd;
}
示例13: ASCIIShade
char ASCIIShade(double x)
{
if(IsNaN(x)) return 'E';
if(IsInf(x)==1) return 'I';
else if(IsInf(x)==-1) return 'i';
int index = (int)Trunc(x*8) + 7;
if(index < 0) index=0;
if(index >= kNumAsciiShades) index=kNumAsciiShades-1;
if(index == 7) {
if(x > 0) return kAsciiShades[8];
else if(x < 0) return kAsciiShades[6];
else return kAsciiShades[7];
}
return kAsciiShades[index];
}
示例14: GetResource
int64_t
SubBufferDecoder::ConvertToByteOffset(double aTime)
{
// Uses a conversion based on (aTime/duration) * length. For the
// purposes of eviction this should be adequate since we have the
// byte threshold as well to ensure data actually gets evicted and
// we ensure we don't evict before the current playable point.
double duration = mParentDecoder->GetMediaSourceDuration();
if (duration <= 0.0 || IsNaN(duration)) {
return -1;
}
int64_t length = GetResource()->GetLength();
MOZ_ASSERT(length > 0);
int64_t offset = (aTime / duration) * length;
return offset;
}
示例15: mon
void
MediaSourceDecoder::SetInitialDuration(int64_t aDuration)
{
// Only use the decoded duration if one wasn't already
// set.
ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
if (!mMediaSource || !IsNaN(mMediaSourceDuration)) {
return;
}
double duration = aDuration;
// A duration of -1 is +Infinity.
if (aDuration >= 0) {
duration /= USECS_PER_S;
}
SetMediaSourceDuration(duration, MSRangeRemovalAction::SKIP);
}