Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorv0lt <v0lt@rambler.ru>2013-05-14 16:45:06 +0400
committerv0lt <v0lt@rambler.ru>2013-05-14 16:45:06 +0400
commit436f537dc0b9b66310fcedcca2ba74e4e22f2be5 (patch)
tree76ec1d3486c153176d31330d5eccf6ba6b3d4e8a /src
parent0ed181acb8914beb7becb5f4b63ca3db495761d4 (diff)
MatroskaSplitter: improved algorithm for calculating fps when it is incorrect.
Diffstat (limited to 'src')
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp
index 3c01c402f..70a81e82c 100644
--- a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp
+++ b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp
@@ -444,8 +444,8 @@ avcsuccess:
m_pCluster = m_pSegment->Child(0x1F43B675);
MatroskaReader::QWORD lastCueClusterPosition = (MatroskaReader::QWORD) - 1;
- UINT64 timecode1 = -1;
- UINT64 timecode2 = -1;
+ UINT64 timecode1 = 0;
+ UINT64 timecode2 = 0;
unsigned int framecount = 0;
bool readmore = true;
@@ -495,31 +495,32 @@ avcsuccess:
continue;
}
UINT64 tc = c.TimeCode + bg->Block.TimeCode;
- if (tc == timecode2) {
- continue;
- }
+ TRACE(_T("Frame: %d, TimeCode %I64d\n"), framecount, tc);
- if (timecode1 == -1) {
+ if (framecount == 0) {
timecode1 = tc;
- } else {
timecode2 = tc;
- ++framecount;
- }
+ } else if (tc == timecode2) { // hmm
+ continue;
+ } else if (tc > timecode2) { // I and P frames
+ if (framecount >= 24) {
+ // good for 23.976, 24, 25, 30, 50, 60 fps.
+ // for 29.97 and 59,94 can give a small inaccuracy
+ readmore = false;
+ break;
+ }
+ timecode2 = tc;
+ } //else if (tc < timecode2) {} // B-Frames
- if (framecount >= 24) {
- // good for 23.976, 24, 25, 30, 50, 60 fps.
- // for 29.97 and 59,94 can give a small inaccuracy
- readmore = false;
- break;
- }
+ framecount++;
}
} while (readmore && pBlock->NextBlock());
}
}
}
}
- if (framecount) {
- AvgTimePerFrame = m_pFile->m_segment.SegmentInfo.TimeCodeScale * (timecode2 - timecode1) / (100 * framecount);
+ if (framecount > 1) {
+ AvgTimePerFrame = m_pFile->m_segment.SegmentInfo.TimeCodeScale * (timecode2 - timecode1) / (100 * (framecount - 1));
}
m_pCluster.Free();