Skip to content

Commit

Permalink
Fix issue with PTS/DTS calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohkr committed Nov 30, 2024
1 parent f219956 commit 45f03b5
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 15 deletions.
8 changes: 7 additions & 1 deletion src/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
x64
dantto4k.vcxproj.user
dantto4k_dll.vcxproj.user
dantto4k_dll.vcxproj.user
dantto4k_dev.vcxproj
dantto4k_dll_dev.vcxproj
dantto4k_dev.vcxproj.user
dantto4k_dll_dev.vcxproj.user
dantto4k_dev.vcxproj.filters
dantto4k_dll_dev.vcxproj.filters
2 changes: 1 addition & 1 deletion src/accessControlDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class AccessControlDescriptor
public:
bool unpack(Common::ReadStream& stream) override;

uint8_t caSystemId;
uint16_t caSystemId;
MmtGeneralLocationInfo locationInfo;
std::vector<uint8_t> privateData;
};
Expand Down
2 changes: 1 addition & 1 deletion src/dantto4k.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ int main(int argc, char* argv[]) {
std::cerr << "\t--disableADTSConversion: Uses the raw LATM format without converting to ADTS." << std::endl;
return 1;
}

auto start = std::chrono::high_resolution_clock::now();

std::string inputPath, outputPath;
Expand Down
8 changes: 5 additions & 3 deletions src/mfuDataProcessorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ namespace AssetType {
constexpr int32_t aapp = makeAssetType('a', 'a', 'p', 'p');
}

constexpr uint64_t NOPTS_VALUE = 0x8000000000000000;

struct MfuData {
std::vector<uint8_t> data;
int64_t pts;
int64_t dts;
int streamIndex;
uint64_t pts{NOPTS_VALUE};
uint64_t dts{NOPTS_VALUE};
int streamIndex{};
};

class MfuDataProcessorBase {
Expand Down
2 changes: 1 addition & 1 deletion src/mmtStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ std::pair<int64_t, int64_t> MmtStream::getNextPtsDts()
}

int64_t dts = ptime - timestamp.second.mpuDecodingTimeOffset;
for (int j = 0; j < auIndex; ++j) {
for (uint32_t j = 0; j < auIndex; ++j) {
dts += timestamp.second.ptsOffsets[j];
}

Expand Down
2 changes: 1 addition & 1 deletion src/mmtStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MhAudioComponentDescriptor;
class MmtStream final {
public:
MmtStream(uint16_t pid)
: pid(pid), timeBase({1, 1}) {}
: pid(pid) {}

MmtStream(const MmtStream&) = delete;
MmtStream& operator=(const MmtStream&) = delete;
Expand Down
10 changes: 5 additions & 5 deletions src/remuxerHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ void RemuxerHandler::writeStream(const std::shared_ptr<MmtTlv::MmtStream> mmtStr
{
const AVRational tsTimeBase = { 1, 90000 };
AVRational timeBase = { mmtStream->timeBase.num, mmtStream->timeBase.den };

uint64_t tsPts = 0;
uint64_t tsDts = 0;

if(mfuData->pts && mfuData->dts && timeBase.den > 0) {
uint64_t tsPts = MmtTlv::NOPTS_VALUE;
uint64_t tsDts = MmtTlv::NOPTS_VALUE;
if ((mfuData->pts != MmtTlv::NOPTS_VALUE && mfuData->dts != MmtTlv::NOPTS_VALUE) && timeBase.den > 0) {
tsPts = av_rescale_q(mfuData->pts, timeBase, tsTimeBase);
tsDts = av_rescale_q(mfuData->dts, timeBase, tsTimeBase);
}
Expand Down
4 changes: 2 additions & 2 deletions src/timebase.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include <cstdint>

typedef struct AVRational{
int num; ///< Numerator
int den; ///< Denominator
int num{1};
int den{1};
} AVRational;

enum AVRounding {
Expand Down

0 comments on commit 45f03b5

Please sign in to comment.