Skip to content

Commit

Permalink
Excptions for error handling, now we're C++98
Browse files Browse the repository at this point in the history
  • Loading branch information
myrsloik committed Apr 8, 2024
1 parent 278d130 commit 59d6d1e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/videosource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1545,16 +1545,18 @@ bool BestVideoSource::GetFrameIsTFF(int64_t N, bool RFF) {
}
}

bool BestVideoSource::WriteTimecodes(const std::filesystem::path &TimecodeFile) const {
void BestVideoSource::WriteTimecodes(const std::filesystem::path &TimecodeFile) const {
for (const auto &Iter : TrackIndex.Frames)
if (Iter.PTS == AV_NOPTS_VALUE)
throw BestSourceException("Cannot write valid timecode file, track contains frames with unknown timestamp");

file_ptr_t F(OpenNormalFile(TimecodeFile, true));
if (!F)
return false;
throw BestSourceException("Couldn't open timecode file for writing");

fprintf(F.get(), "# timecode format v2\n");
for (const auto &Iter : TrackIndex.Frames)
fprintf(F.get(), "%.02f\n", (Iter.PTS * VP.TimeBase.Num) / (double)VP.TimeBase.Den);

return true;
}

const BestVideoSource::FrameInfo &BestVideoSource::GetFrameInfo(int64_t N) const {
Expand Down
2 changes: 1 addition & 1 deletion src/videosource.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class BestVideoSource {
[[nodiscard]] BestVideoFrame *GetFrameWithRFF(int64_t N, bool Linear = false);
[[nodiscard]] BestVideoFrame *GetFrameByTime(double Time, bool Linear = false);
[[nodiscard]] bool GetFrameIsTFF(int64_t N, bool RFF = false);
bool WriteTimecodes(const std::filesystem::path &TimecodeFile) const;
void WriteTimecodes(const std::filesystem::path &TimecodeFile) const;
[[nodiscard]] const FrameInfo &GetFrameInfo(int64_t N) const;
[[nodiscard]] bool GetLinearDecodingState() const;
};
Expand Down

0 comments on commit 59d6d1e

Please sign in to comment.