• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ FindBlock函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中FindBlock函数的典型用法代码示例。如果您正苦于以下问题:C++ FindBlock函数的具体用法?C++ FindBlock怎么用?C++ FindBlock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了FindBlock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: FindBlock

bool Sequence::GetRMS(sampleCount start, sampleCount len,
                         float * outRMS) const
{
   if (len == 0 || mBlock->Count() == 0) {
      *outRMS = float(0.0);
      return true;
   }

   double sumsq = 0.0;
   sampleCount length = 0;

   unsigned int block0 = FindBlock(start);
   unsigned int block1 = FindBlock(start + len);

   sampleCount s0, l0, maxl0;

   // First calculate the rms of the blocks in the middle of this region;
   // this is very fast because we have the rms of every entire block
   // already in memory.
   unsigned int b;

   for (b = block0 + 1; b < block1; b++) {
      float blockMin, blockMax, blockRMS;
      mBlock->Item(b)->f->GetMinMax(&blockMin, &blockMax, &blockRMS);

      sumsq += blockRMS * blockRMS * mBlock->Item(block0)->f->GetLength();
      length += mBlock->Item(block0)->f->GetLength();
   }

   // Now we take the first and last blocks into account, noting that the
   // selection may only partly overlap these blocks.
   // If not, we need read some samples and summaries from disk.
   s0 = start - mBlock->Item(block0)->start;
   l0 = len;
   maxl0 = mBlock->Item(block0)->start + mBlock->Item(block0)->f->GetLength() - start;
   if (l0 > maxl0)
      l0 = maxl0;

   float partialMin, partialMax, partialRMS;
   mBlock->Item(block0)->f->GetMinMax(s0, l0, &partialMin, &partialMax, &partialRMS);

   sumsq += partialRMS * partialRMS * l0;
   length += l0;

   if (block1 > block0) {
      s0 = 0;
      l0 = (start + len) - mBlock->Item(block1)->start;

      mBlock->Item(block1)->f->GetMinMax(s0, l0,
                                         &partialMin, &partialMax, &partialRMS);
      sumsq += partialRMS * partialRMS * l0;
      length += l0;
   }

   *outRMS = sqrt(sumsq/length);

   return true;
}
开发者ID:Kirushanr,项目名称:audacity,代码行数:58,代码来源:Sequence.cpp


示例2: wxASSERT

int WaveTrack::FindBlock(sampleCount pos, sampleCount lo,
                         sampleCount guess, sampleCount hi)
{
   wxASSERT(block->Item(guess)->len > 0);
   wxASSERT(lo <= guess && guess <= hi && lo <= hi);

   if (pos >= block->Item(guess)->start &&
       pos < block->Item(guess)->start + block->Item(guess)->len)
      return guess;

   if (pos < block->Item(guess)->start)
      return FindBlock(pos, lo, (lo + guess) / 2, guess);
   else
      return FindBlock(pos, guess + 1, (guess + 1 + hi) / 2, hi);
}
开发者ID:ruthmagnus,项目名称:audacity,代码行数:15,代码来源:WaveTrack.cpp


示例3: wxASSERT

int Sequence::FindBlock(sampleCount pos, sampleCount lo,
                        sampleCount guess, sampleCount hi) const
{
   wxASSERT(mBlock->Item(guess)->len > 0);
   wxASSERT(lo <= guess && guess <= hi && lo <= hi);

   if (pos >= mBlock->Item(guess)->start &&
       pos < mBlock->Item(guess)->start + mBlock->Item(guess)->len)
      return guess;

   if (pos < mBlock->Item(guess)->start)
      return FindBlock(pos, lo, (lo + guess) / 2, guess);
   else
      return FindBlock(pos, guess + 1, (guess + 1 + hi) / 2, hi);
}
开发者ID:ruthmagnus,项目名称:audacity,代码行数:15,代码来源:Sequence.cpp


示例4: FindBlock

//======================================================
int ParmFile::GetIntParm(const char* parm_nam)
{
  int num;
  char parm_str[20];

  if(GetParmStr(parm_nam, parm_str)!=0)
    {
    FindBlock(Block_Name);
    if(GetParmStr(parm_nam, parm_str) !=0)
      {
      ErrorStream <<  "Error: parameter '" << parm_nam 
                  << "' not found after 2 attempts" << endl;
      exit(-1);
      }
    }
  cout << "str = " << parm_str << endl;
//  for(c_ptr=parm_str; c_ptr<parm_str+strlen(parm_str);c_ptr++) {
//   if(!isdigit(*c_ptr)) {
//      ErrorStream << "Error: non-numeric data where numeric expected" << endl;
//      exit(-1);
//      }
//   }
   if(!isnumeric(parm_str)) {
      ErrorStream << "Error: non-numeric data where numeric expected" << endl;
      exit(-1);
      }
  num = atoi(parm_str);
  cout << "num = " << num << endl;
  return(num);
}
开发者ID:otrewyi191,项目名称:WirelessModelCPP,代码行数:31,代码来源:parmfile.cpp


示例5: Refresh

BOOL CSysinfo::GetProcessName (pid_t pid, char *dest, int sz)
{
	// this code is deprecated. It was causing ACCESS_VIOLATIONS
	// on Windows XP.
#if 0
	DWORD *block;
	Refresh();
	block = FindBlock (pid);
	if (!block)
	{
		dest[0] = '\0';
		return FALSE;
	}
	MakeAnsiString ((WORD*)(*(block+15)), dest);
#endif
	HANDLE Hnd;

	if( ! (Hnd = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid))) {
		return FALSE;
	}

	if ( ! GetModuleBaseName(Hnd, NULL, dest, sz) ) {
		return FALSE;
	}
	
	return TRUE;
}
开发者ID:AlainRoy,项目名称:htcondor,代码行数:27,代码来源:ntsysinfo.WINDOWS.cpp


示例6: CopyFileToMappedBlock

/*
 * Copy data in specified file to specified block in channel data memory map
 */
void CopyFileToMappedBlock(char *blockName, char *inputFilename) {
	if (!FileExists(inputFilename)) {
		printf( "ERROR: Input file %s does not exist!\n" );
		return;
	}

	int fd = open(inputFilename, O_RDONLY);

	if (fd < 0) {
		printf( "ERROR: Unable to open input file %s: %s",
			inputFilename, strerror(errno));
		return;
	}

	if (OpenChannelControlMemoryMap() < 0) {
		close(fd);
		return;
	}

	if (OpenChannelMemoryMap() < 0) {
		CloseChannelControlMemoryMap();
		close(fd);
		return;
	}

	if (OpenChannelPixelMap() < 0) {
		CloseChannelMemoryMap();
		CloseChannelControlMemoryMap();
		close(fd);
		return;
	}

	FPPChannelMemoryMapControlBlock *cb = FindBlock(blockName);

	if (cb) {
		char data[FPPD_MAX_CHANNELS];
		int r = read(fd, data, cb->channelCount);
		if (r != cb->channelCount) {
			printf( "WARNING: Expected %d bytes of data but only read %d.\n",
				cb->channelCount, r);
		} else {
			int i;
			int limit = cb->channelCount - 3;
			for (i = 0; i <= limit; ) {
				dataMap[pixelMap[cb->startChannel - 1 + i]] = data[i]; i++; // R |
				dataMap[pixelMap[cb->startChannel - 1 + i]] = data[i]; i++; // G |- triplet
				dataMap[pixelMap[cb->startChannel - 1 + i]] = data[i]; i++; // B |
			}
			printf( "Data imported\n" );
		}
	} else {
		printf( "ERROR: Could not find MAP %s\n", blockName);
	}

	CloseChannelMemoryMap();
	CloseChannelControlMemoryMap();
	close(fd);
}
开发者ID:bagumondigi,项目名称:fpp,代码行数:61,代码来源:fppmm.c


示例7: wxASSERT

int Sequence::FindBlock(sampleCount pos, sampleCount lo,
                        sampleCount guess, sampleCount hi) const
{
   wxASSERT(mBlock->Item(guess)->f->GetLength() > 0);
   wxASSERT(lo <= guess && guess <= hi && lo <= hi);

   if (pos >= mBlock->Item(guess)->start &&
       pos < mBlock->Item(guess)->start + mBlock->Item(guess)->f->GetLength())
      return guess;

   //this is a binary search, but we probably could benefit by something more like
   //dictionary search where we guess something smarter than the binary division
   //of the unsearched area, since samples are usually proportional to block file number.
   if (pos < mBlock->Item(guess)->start)
      return FindBlock(pos, lo, (lo + guess) / 2, guess);
   else
      return FindBlock(pos, guess + 1, (guess + 1 + hi) / 2, hi);
}
开发者ID:Kirushanr,项目名称:audacity,代码行数:18,代码来源:Sequence.cpp


示例8: FindBlock

status_t
Volume::FindBlock(off_t logical, fsblock_t &physicalBlock)
{
	off_t physical;
	status_t status = FindBlock(logical, physical);
	if (status != B_OK)
		return status;
	physicalBlock = physical / fBlockSize;
	return B_OK;
}
开发者ID:jiangxilong,项目名称:haiku,代码行数:10,代码来源:Volume.cpp


示例9: NewSamples

// Pass NULL to set silence
bool Sequence::Set(samplePtr buffer, sampleFormat format,
                   sampleCount start, sampleCount len)
{
   if (start < 0 || start > mNumSamples ||
       start+len > mNumSamples)
      return false;

   samplePtr temp = NULL;
   if (format != mSampleFormat) {
      temp = NewSamples(mMaxSamples, mSampleFormat);
      wxASSERT(temp);
   }

   samplePtr silence = NULL;
   if (!buffer) {
      silence = NewSamples(mMaxSamples, format);
      wxASSERT(silence);
      ClearSamples(silence, format, 0, mMaxSamples);
   }

   int b = FindBlock(start);

   while (len) {
      int blen = mBlock->Item(b)->start + mBlock->Item(b)->len - start;
      if (blen > len)
         blen = len;

      if (buffer) {
         if (format == mSampleFormat)
            CopyWrite(buffer, mBlock->Item(b), start - mBlock->Item(b)->start,
                      blen);
         else {
            CopySamples(buffer, format, temp, mSampleFormat, blen);
            CopyWrite(temp, mBlock->Item(b), start - mBlock->Item(b)->start,
                      blen);
         }
         buffer += (blen * SAMPLE_SIZE(format));
      } else
         CopyWrite(silence, mBlock->Item(b), start - mBlock->Item(b)->start,
                   blen);

      len -= blen;
      start += blen;
      b++;
   }

   if (!buffer)
      DeleteSamples(silence);

   if (format != mSampleFormat)
      DeleteSamples(temp);

   return ConsistencyCheck("Set");
}
开发者ID:ruthmagnus,项目名称:audacity,代码行数:55,代码来源:Sequence.cpp


示例10: FindBlock

void FIndirectLightingCache::UpdateCacheAllocation(
	const FBoxSphereBounds& Bounds, 
	int32 BlockSize,
	bool bOpaqueRelevance,
	FIndirectLightingCacheAllocation*& Allocation, 
	TMap<FIntVector, FBlockUpdateInfo>& BlocksToUpdate,
	TArray<FIndirectLightingCacheAllocation*>& TransitionsOverTimeToUpdate)
{
	if (Allocation && Allocation->IsValid())
	{
		FIndirectLightingCacheBlock& Block = FindBlock(Allocation->MinTexel);

		// Calculate a potentially new min and size based on the current bounds
		FVector NewMin;
		FVector NewSize;
		CalculateBlockPositionAndSize(Bounds, Block.TexelSize, NewMin, NewSize);

		// If the primitive has moved enough to change its block min and size, we need to interpolate it again
		if (Allocation->bIsDirty || GCacheUpdateEveryFrame || !Block.Min.Equals(NewMin) || !Block.Size.Equals(NewSize))
		{
			// Update the block and primitive allocation with the new bounds
			Block.Min = NewMin;
			Block.Size = NewSize;

			FVector NewScale;
			FVector NewAdd;
			FVector MinUV;
			FVector MaxUV;
			CalculateBlockScaleAndAdd(Allocation->MinTexel, Allocation->AllocationTexelSize, NewMin, NewSize, NewScale, NewAdd, MinUV, MaxUV);

			Allocation->SetParameters(Allocation->MinTexel, Allocation->AllocationTexelSize, NewScale, NewAdd, MinUV, MaxUV, bOpaqueRelevance);
			BlocksToUpdate.Add(Block.MinTexel, FBlockUpdateInfo(Block, Allocation));
		}

		if ((Allocation->SingleSamplePosition - Allocation->TargetPosition).SizeSquared() > DELTA)
		{
			TransitionsOverTimeToUpdate.AddUnique(Allocation);
		}
	}
	else
	{
		delete Allocation;
		Allocation = CreateAllocation(BlockSize, Bounds, bOpaqueRelevance);

		if (Allocation->IsValid())
		{
			// Must interpolate lighting for this new block
			BlocksToUpdate.Add(Allocation->MinTexel, FBlockUpdateInfo(VolumeBlocks.FindChecked(Allocation->MinTexel), Allocation));
		}
	}
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:51,代码来源:IndirectLightingCache.cpp


示例11: SetMappedBlockActive

/*
 * Set a channel data map block as active/inactive.
 */
void SetMappedBlockActive(char *blockName, int active) {
	if (OpenChannelControlMemoryMap() < 0)
		return;

	FPPChannelMemoryMapControlBlock *cb = FindBlock(blockName);

	if (cb) {
		cb->isActive = active;
	} else {
		printf( "ERROR: Could not find MAP %s\n", blockName);
	}

	CloseChannelControlMemoryMap();
}
开发者ID:bagumondigi,项目名称:fpp,代码行数:17,代码来源:fppmm.c


示例12: FreeObject

static int FreeObject(ContainerHeap *heap,void *element)
{
    ListElement *le = element;

    le->Next = INVALID_POINTER_VALUE;
#ifdef DEBUG_HEAP_FREELIST
    { size_t idx,blockNr;
        blockNr = FindBlock(heap,element,&idx);
        if (blockNr > heap->CurrentBlock) return -1;
    }
#endif
    memcpy(le->Data, &heap->FreeList,sizeof(ListElement *));
	le->Next = heap->FreeList;
    heap->FreeList = le;
    heap->timestamp++;
    return 1;
}
开发者ID:Renlor,项目名称:ccl,代码行数:17,代码来源:heap.c


示例13: CheckBlockList

bool CheckBlockList(struct in_addr* piaPeer)
{
	block_node* pBlock = FindBlock(piaPeer);

	// true means not blocked and can connect
	// false means block still in effect

	if (!pBlock)
		return true;

	if (pBlock->iExpires < 0)
		return false;

	if (pBlock->iExpires <= GetTime())
	{
		DeleteBlock(piaPeer);
		return true;
	}

	return false;
}
开发者ID:AlleyCat1976,项目名称:Meridian59_103,代码行数:21,代码来源:block.c


示例14: FillMappedBlock

/*
 * Fill a channel data block with a single specified value
 */
void FillMappedBlock(char *blockName, int channelData) {
	if (OpenChannelControlMemoryMap() < 0) {
		return;
	}

	if (OpenChannelMemoryMap() < 0) {
		CloseChannelControlMemoryMap();
		return;
	}

	FPPChannelMemoryMapControlBlock *cb = FindBlock(blockName);

	if (cb) {
		memset(dataMap + cb->startChannel - 1, channelData, cb->channelCount);
	} else {
		printf( "ERROR: Could not find MAP %s\n", blockName);
	}

	CloseChannelMemoryMap();
	CloseChannelControlMemoryMap();
}
开发者ID:bagumondigi,项目名称:fpp,代码行数:24,代码来源:fppmm.c


示例15: DumpMappedBlockInfo

/*
 * Display info on a named channel data block
 */
void DumpMappedBlockInfo(char *blockName) {
	if (OpenChannelControlMemoryMap() < 0) {
		return;
	}

	FPPChannelMemoryMapControlBlock *cb = FindBlock(blockName);

	if (cb) {
		printf( "Block Name: %s\n", cb->blockName);
		printf( "Channels  : %lld-%lld (%lld channels)\n",
			cb->startChannel, cb->startChannel + cb->channelCount - 1,
			cb->channelCount);

		printf( "Status    : ");
		switch (cb->isActive) {
			case 0: printf("Idle");
					break;
			case 1: printf("Active");
					break;
			case 2: printf("Active (Transparent)");
					break;
			case 3: printf("Active (Transparent RGB)");
					break;
		}
		printf( "\n");

		printf( "Is Locked : ");
		switch (cb->isLocked) {
			case 0: printf("No");
					break;
			case 1: printf("Yes");
					break;
		}
		printf("\n");
	} else {
		printf( "ERROR: Could not find MAP %s\n", blockName);
	}

	CloseChannelControlMemoryMap();
}
开发者ID:bagumondigi,项目名称:fpp,代码行数:43,代码来源:fppmm.c



注:本文中的FindBlock函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ FindBreakpoint函数代码示例发布时间:2022-05-30
下一篇:
C++ FindBaseMap函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap