Skip to content
12 changes: 10 additions & 2 deletions src/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,16 @@ bool CNetBuf::Put ( const CVector<uint8_t>& vecbyData, int iInSize )
return false;
}

// to get the number of input blocks we assume that the number of bytes for
// the sequence number is much smaller than the number of coded audio bytes
// This divide is exact if and only if iNumBlocks * iNumBytesSeqNum < iBlockSize,
// since the actual input is iNumBlocks * ( iBlockSize + iNumBytesSeqNum ) bytes. The
// sequence number merely being "much smaller" than the coded audio is not the
// condition: at iNumBlocks == iBlockSize the count comes out one too high whatever
// the ratio is. The bound is not enforced here but by the properties validator in
// protocol.cpp, EvaluateNetwTranspPropsMes, which rejects a base network packet size
// below CELT_MINIMUM_NUM_BYTES (10) and a block size factor outside
// { FRAME_SIZE_FACTOR_PREFERRED, _DEFAULT, _SAFE }. With iNumBytesSeqNum == 1 and
// iBlockSize == iBaseNetworkPacketSize - 1 (channel.cpp), the worst reachable case is
// a factor of 4 against a block size of 9.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above is far too verbose for anyone to read it clearly. Two lines looks like a good length. Ten lines isn't.

It needs to be short and to the point:

Intent:
Purpose of this section, including what the result is used for.

Inputs:

  • iInSize: where this comes from and what it means
  • iBlockSize: ...
  • ...

Method:
Explanation of why this method works. But only if it's not transparently obvious.

const int iNumBlocks = /* floor */ ( iInSize / iBlockSize );

// copy new data in internal buffer
Expand Down