summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2015-01-17 13:52:34 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2015-01-17 13:52:34 +0100
commitfe5bb7c5e06e4e5479766e81c8800dc48ed31d09 (patch)
tree08cb6cd3f5a1d7932c15ebe8ff5181ef3b344fab
parent1c9cd049b4c3d6e8989b3f3c0312f90f788106c5 (diff)
downloadvdr-fe5bb7c5e06e4e5479766e81c8800dc48ed31d09.tar.gz
vdr-fe5bb7c5e06e4e5479766e81c8800dc48ed31d09.tar.bz2
Fixed generating the index file of an existing recording
-rw-r--r--HISTORY8
-rw-r--r--recording.c26
2 files changed, 29 insertions, 5 deletions
diff --git a/HISTORY b/HISTORY
index 90fddfdb..c4ca8cf9 100644
--- a/HISTORY
+++ b/HISTORY
@@ -7926,3 +7926,11 @@ Video Disk Recorder Revision History
- Now returning from removing deleted recordings after at most 10 seconds, or if the
user presses a remote control key, to keep the system from getting unresponsive
when removing a huge number of files (reported by Dieter Ferdinand).
+- Fixed generating the index file of an existing recording in case at the of a TS file
+ there is less data in the buffer than needed by the frame detector. In such a case
+ it was possible that frames were missed, and there was most likely a distortion
+ when replaying that part of a recording. This is mostly a problem for recordings that
+ consist of more than one *.ts file. Single file recordings could only lose some
+ frames at their very end, which probably doesn't matter. At any rate, if you have
+ generated an index file with VDR version 2.0.6 you may want to do so again with this
+ version to make sure the index is OK.
diff --git a/recording.c b/recording.c
index 460a1107..3e680fc0 100644
--- a/recording.c
+++ b/recording.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: recording.c 2.91.1.8 2015/01/17 10:54:16 kls Exp $
+ * $Id: recording.c 2.91.1.9 2015/01/17 13:50:38 kls Exp $
*/
#include "recording.h"
@@ -1746,6 +1746,7 @@ void cIndexFileGenerator::Action(void)
off_t FileSize = 0;
off_t FrameOffset = -1;
Skins.QueueMessage(mtInfo, tr("Regenerating index file"));
+ bool Stuffed = false;
while (Running()) {
// Rewind input file:
if (Rewind) {
@@ -1809,10 +1810,25 @@ void cIndexFileGenerator::Action(void)
else if (ReplayFile) {
int Result = Buffer.Read(ReplayFile, BufferChunks);
if (Result == 0) { // EOF
- ReplayFile = FileName.NextFile();
- FileSize = 0;
- FrameOffset = -1;
- Buffer.Clear();
+ if (Buffer.Available() > 0 && !Stuffed) {
+ // So the last call to Buffer.Get() returned NULL, but there is still
+ // data in the buffer, and we're at the end of the current TS file.
+ // The remaining data in the buffer is less than what's needed for the
+ // frame detector to analyze frames, so we need to put some stuffing
+ // packets into the buffer to flush out the rest of the data (otherwise
+ // any frames within the remaining data would not be seen here):
+ uchar StuffingPacket[TS_SIZE] = { TS_SYNC_BYTE, 0xFF };
+ for (int i = 0; i <= MIN_TS_PACKETS_FOR_FRAME_DETECTOR; i++)
+ Buffer.Put(StuffingPacket, sizeof(StuffingPacket));
+ Stuffed = true;
+ }
+ else {
+ ReplayFile = FileName.NextFile();
+ FileSize = 0;
+ FrameOffset = -1;
+ Buffer.Clear();
+ Stuffed = false;
+ }
}
}
// Recording has been processed: