Beispiel #1
0
MediaBlock*
MediaBlockMap::LastBlock() const
{
    if (CountBlocks() == 0)
        return NULL;

    return BlockAt(CountBlocks()-1);
}
Beispiel #2
0
// TODO various optimizations possible
int64
MediaBlockMap::CountFrames() const
{
    int64 ret = 0;
    for (int32 i = 0; i < CountBlocks(); i++) {
        MediaBlock* block = BlockAt(i);
        ret += block->CountFrames();
    }

    return ret;
}
Beispiel #3
0
int64
MediaBlockMap::PreviewFrames() const
{
    int64 frames = 0;
    for (int32 i = 0; i < CountBlocks(); i++) {
        MediaBlock* block = BlockAt(i);
        frames += block->PreviewFrames();
    }

    return frames;
}
Beispiel #4
0
int64
MediaBlockMap::BlockPlacement(int32 index) const
{
    if (index >= CountBlocks())
        return -1;

    int64 ret = 0;
    for (int32 i = 0; i < index; i++) {
        MediaBlock* block = BlockAt(i);
        ret += block->CountFrames();
    }

    return ret;
}
Beispiel #5
0
Heap::Heap(void)
{
    Block &super = BlockAt(kSuperBlockOffset);
    super.SetSize(kSuperBlockSize);

    Block &first = BlockRight(super);
    first.SetSize(kFirstBlockSize);

    Block &guard = BlockRight(first);
    guard.SetSize(Block::kGuardBlockSize);

    super.SetNext(BlockOffset(first));
    first.SetNext(BlockOffset(guard));
}
Beispiel #6
0
int32
MediaBlockMap::BlockForFrame(int64 frame, int64* startFrame) const
{
    int64 count = 0;
    for (int32 i = 0; i < CountBlocks(); i++) {
        MediaBlock* block = BlockAt(i);
        int64 nextCount = count+block->CountFrames();
        if (frame >= count && frame < nextCount) {
            *startFrame = count;
            return i;
        }
        count = nextCount;
    }

    return -1;
}
void GoRegionBoard::UpdateBlock(int move, SgBlackWhite moveColor)
{
    SgPoint anchor = Board().Anchor(move); // board is already up to date.
    bool done = false;
    const int size = Board().Size();
    if (! Board().IsSingleStone(move)) // find old neighbor blocks
    {
        SgVectorOf<GoBlock> old;
        for (GoNbIterator it(Board(), move); it; ++it)
        {
            if (IsColor(*it, moveColor))
                old.Include(BlockAt(*it));
        }
        if (old.IsLength(1)) // append to single neighbor block
        {
            GoBlock* b = old.Front();
            AppendStone(b, move);
            done = true;
        }
        else // delete old, recompute
        {
            for (SgVectorIteratorOf<GoBlock> it(old); it; ++it)
                RemoveBlock(*it, true, true);
        }
    }

    if (! done) // create new block.
    {
        GoBlock* b = GenBlock(anchor, moveColor);
        SgPointSet area(b->Stones().Border(size));
        // link it to neighbor regions
        SgVectorOf<GoRegion> regions;
        RegionsAt(area, moveColor, &regions);
        for (SgVectorIteratorOf<GoRegion> it(regions); it; ++it)
            (*it)->BlocksNonConst().PushBack(b);
    }
}
void GoRegionBoard::SetToSafe(SgPoint p) const
{
    BlockAt(p)->SetToSafe();
}
bool GoRegionBoard::IsSafeBlock(SgPoint p) const
{
    return BlockAt(p)->IsSafe();
}
Beispiel #10
0
 /**
  * This method returns the block on the right side of @p aBlock.
  *
  * @param[in]   aBlock  A reference to the block.
  *
  * @returns Reference to the block on the right side.
  *
  */
 Block &BlockRight(const Block &aBlock) { return BlockAt(BlockOffset(aBlock) + sizeof(Block) + aBlock.GetSize()); }
Beispiel #11
0
 /**
  * This method returns the free block after @p aBlock in the free block list.
  *
  * @param[in]   aBlock  A reference to the block.
  *
  * @returns Reference to the free block after this block.
  *
  */
 Block &BlockNext(const Block &aBlock) { return BlockAt(aBlock.GetNext()); }
Beispiel #12
0
 /**
  * This method returns the super block.
  *
  * @returns Reference to the super block.
  *
  */
 Block &BlockSuper(void) { return BlockAt(kSuperBlockOffset); }
Beispiel #13
0
 /**
  * This method returns the block of @p aPointer.
  *
  * @param[in]   aPointer     The pointer returned by CAlloc().
  *
  * @returns A reference to the block.
  *
  */
 Block &BlockOf(void *aPointer)
 {
     uint16_t offset = static_cast<uint16_t>(reinterpret_cast<uint8_t *>(aPointer) - mMemory.m8);
     offset -= sizeof(uint16_t);
     return BlockAt(offset);
 }