コード例 #1
0
ファイル: KaxCluster.cpp プロジェクト: DINKIN/libmatroska
bool KaxCluster::AddFrameInternal(const KaxTrackEntry & track, uint64 timecode, DataBuffer & buffer, KaxBlockGroup * & MyNewBlock, const KaxBlockGroup * PastBlock, const KaxBlockGroup * ForwBlock, LacingType lacing)
{
  if (!bFirstFrameInside) {
    bFirstFrameInside = true;
    MinTimecode = MaxTimecode = timecode;
  } else {
    if (timecode < MinTimecode)
      MinTimecode = timecode;
    if (timecode > MaxTimecode)
      MaxTimecode = timecode;
  }

  MyNewBlock = NULL;

  if (lacing == LACING_NONE || !track.LacingEnabled()) {
    currentNewBlock = NULL;
  }

  // force creation of a new block
  if (currentNewBlock == NULL || uint32(track.TrackNumber()) != uint32(currentNewBlock->TrackNumber()) || PastBlock != NULL || ForwBlock != NULL) {
    KaxBlockGroup & aNewBlock = GetNewBlock();
    MyNewBlock = currentNewBlock = &aNewBlock;
  }

  if (PastBlock != NULL) {
    if (ForwBlock != NULL) {
      if (currentNewBlock->AddFrame(track, timecode, buffer, *PastBlock, *ForwBlock, lacing)) {
        // more data are allowed in this Block
        return true;
      } else {
        currentNewBlock = NULL;
        return false;
      }
    } else {
      if (currentNewBlock->AddFrame(track, timecode, buffer, *PastBlock, lacing)) {
        // more data are allowed in this Block
        return true;
      } else {
        currentNewBlock = NULL;
        return false;
      }
    }
  } else {
    if (currentNewBlock->AddFrame(track, timecode, buffer, lacing)) {
      // more data are allowed in this Block
      return true;
    } else {
      currentNewBlock = NULL;
      return false;
    }
  }
}
コード例 #2
0
ファイル: KaxBlock.cpp プロジェクト: ares89/vlc
/*!
	\todo handle flags
	\todo hardcoded limit of the number of frames in a lace should be a parameter
	\return true if more frames can be added to this Block
*/
bool KaxInternalBlock::AddFrame(const KaxTrackEntry & track, uint64 timecode, DataBuffer & buffer, LacingType lacing, bool invisible)
{
	SetValueIsSet();
	if (myBuffers.size() == 0) {
		// first frame
		Timecode = timecode;
		TrackNumber = track.TrackNumber();
		mInvisible = invisible;
		mLacing = lacing;
	}
	myBuffers.push_back(&buffer);

	// we don't allow more than 8 frames in a Block because the overhead improvement is minimal
	if (myBuffers.size() >= 8 || lacing == LACING_NONE)
		return false;

	if (lacing == LACING_XIPH)
		// decide wether a new frame can be added or not
		// a frame in a lace is not efficient when the place necessary to code it in a lace is bigger 
		// than the size of a simple Block. That means more than 6 bytes (4 in struct + 2 for EBML) to code the size
		return (buffer.Size() < 6*0xFF);
	else
		return true;
}