Skip to content

Commit

Permalink
update pts conversion func
Browse files Browse the repository at this point in the history
  • Loading branch information
yezhan10 committed Oct 17, 2024
1 parent b4e640b commit 04e5732
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/AudioDecoderWorker.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "AudioDecoderWorker.h"
#include "media.h"
#include "aac/AACDecoder.h"
#include "mp3/MP3Decoder.h"
#include "AudioCodecFactory.h"

AudioDecoderWorker::~AudioDecoderWorker()
Expand Down
2 changes: 1 addition & 1 deletion src/AudioTransrater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ AudioBuffer::shared AudioTransrater::ProcessBuffer(const AudioBuffer::shared& au
auto ptsDiff = audioBuffer->GetTimestamp() - playPTSOffset.value();
// scale the pts based on recordRate which is the clockrate for encoded audio
// so that the pts stored in audio buffer is always in encoded audio time base
uint64_t scaledPTS = std::round<uint64_t>(ptsDiff * (outputRate / (double)inputRate)) + playPTSOffset.value();
uint64_t scaledPTS = playPTSOffset.value() + std::lround(ptsDiff * (outputRate / (double)audioBuffer->GetClockRate()));
resampledBuffer->SetTimestamp(scaledPTS);
resampledBuffer->SetClockRate(outputRate);
//OK
Expand Down
4 changes: 2 additions & 2 deletions src/mp3/MP3Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ class MP3Config
private:
MPEGAudioVersion audioVersion = MPEGAudioVersion::MPEGVersionReserved;
MPEGAudioLayer audioLayer = MPEGAudioLayer::MPEGLayerReserved;
bool padding;
BYTE paddingSize;
bool padding = false;
BYTE paddingSize = 0;
DWORD samplingRate = 0;
DWORD bitrate = 0;
BYTE channels = 0;
Expand Down

0 comments on commit 04e5732

Please sign in to comment.