diff --git a/modules/video_coding/inter_frame_delay.cc b/modules/video_coding/inter_frame_delay.cc index b34f9f5ae6..d0c21aa771 100644 --- a/modules/video_coding/inter_frame_delay.cc +++ b/modules/video_coding/inter_frame_delay.cc @@ -16,7 +16,7 @@ VCMInterFrameDelay::VCMInterFrameDelay(int64_t currentWallClock) { Reset(currentWallClock); } -// Resets the delay estimate +// Resets the delay estimate. void VCMInterFrameDelay::Reset(int64_t currentWallClock) { _zeroWallClock = currentWallClock; _wrapArounds = 0; @@ -31,7 +31,7 @@ bool VCMInterFrameDelay::CalculateDelay(uint32_t timestamp, int64_t* delay, int64_t currentWallClock) { if (_prevWallClock == 0) { - // First set of data, initialization, wait for next frame + // First set of data, initialization, wait for next frame. _prevWallClock = currentWallClock; _prevTimestamp = timestamp; *delay = 0; @@ -41,30 +41,29 @@ bool VCMInterFrameDelay::CalculateDelay(uint32_t timestamp, int32_t prevWrapArounds = _wrapArounds; CheckForWrapArounds(timestamp); - // This will be -1 for backward wrap arounds and +1 for forward wrap arounds + // This will be -1 for backward wrap arounds and +1 for forward wrap arounds. int32_t wrapAroundsSincePrev = _wrapArounds - prevWrapArounds; // Account for reordering in jitter variance estimate in the future? - // Note that this also captures incomplete frames which are grabbed - // for decoding after a later frame has been complete, i.e. real - // packet losses. + // Note that this also captures incomplete frames which are grabbed for + // decoding after a later frame has been complete, i.e. real packet losses. if ((wrapAroundsSincePrev == 0 && timestamp < _prevTimestamp) || wrapAroundsSincePrev < 0) { *delay = 0; return false; } - // Compute the compensated timestamp difference and convert it to ms and - // round it to closest integer. + // Compute the compensated timestamp difference and convert it to ms and round + // it to closest integer. _dTS = static_cast( (timestamp + wrapAroundsSincePrev * (static_cast(1) << 32) - _prevTimestamp) / 90.0 + 0.5); - // frameDelay is the difference of dT and dTS -- i.e. the difference of - // the wall clock time difference and the timestamp difference between - // two following frames. + // frameDelay is the difference of dT and dTS -- i.e. the difference of the + // wall clock time difference and the timestamp difference between two + // following frames. *delay = static_cast(currentWallClock - _prevWallClock - _dTS); _prevTimestamp = timestamp; @@ -73,34 +72,22 @@ bool VCMInterFrameDelay::CalculateDelay(uint32_t timestamp, return true; } -// Returns the current difference between incoming timestamps -uint32_t VCMInterFrameDelay::CurrentTimeStampDiffMs() const { - if (_dTS < 0) { - return 0; - } - return static_cast(_dTS); -} - // Investigates if the timestamp clock has overflowed since the last timestamp -// and -// keeps track of the number of wrap arounds since reset. +// and keeps track of the number of wrap arounds since reset. void VCMInterFrameDelay::CheckForWrapArounds(uint32_t timestamp) { if (timestamp < _prevTimestamp) { // This difference will probably be less than -2^31 if we have had a wrap - // around - // (e.g. timestamp = 1, _previousTimestamp = 2^32 - 1). Since it is cast to - // a Word32, - // it should be positive. + // around (e.g. timestamp = 1, _prevTimestamp = 2^32 - 1). Since it is cast + // to a int32_t, it should be positive. if (static_cast(timestamp - _prevTimestamp) > 0) { - // Forward wrap around + // Forward wrap around. _wrapArounds++; } // This difference will probably be less than -2^31 if we have had a - // backward - // wrap around. - // Since it is cast to a Word32, it should be positive. + // backward wrap around. Since it is cast to a int32_t, it should be + // positive. } else if (static_cast(_prevTimestamp - timestamp) > 0) { - // Backward wrap around + // Backward wrap around. _wrapArounds--; } } diff --git a/modules/video_coding/inter_frame_delay.h b/modules/video_coding/inter_frame_delay.h index c66b1c5177..f121c61498 100644 --- a/modules/video_coding/inter_frame_delay.h +++ b/modules/video_coding/inter_frame_delay.h @@ -26,30 +26,23 @@ class VCMInterFrameDelay { // This method is called when the frame is complete. // // Input: - // - timestamp : RTP timestamp of a received frame + // - timestamp : RTP timestamp of a received frame. // - *delay : Pointer to memory where the result should be - // stored + // stored. // - currentWallClock : The current time in milliseconds. // Should be -1 for normal operation, only used // for testing. - // Return value : true if OK, false when reordered timestamps + // Return value : true if OK, false when reordered timestamps. bool CalculateDelay(uint32_t timestamp, int64_t* delay, int64_t currentWallClock); - // Returns the current difference between incoming timestamps - // - // Return value : Wrap-around compensated difference between - // incoming - // timestamps. - uint32_t CurrentTimeStampDiffMs() const; - private: - // Controls if the RTP timestamp counter has had a wrap around - // between the current and the previously received frame. + // Controls if the RTP timestamp counter has had a wrap around between the + // current and the previously received frame. // // Input: - // - timestmap : RTP timestamp of the current frame. + // - timestamp : RTP timestamp of the current frame. void CheckForWrapArounds(uint32_t timestamp); int64_t _zeroWallClock; // Local timestamp of the first video packet received