From c5553f9187c6f16a4280e7299ec26328eaa0b398 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sat, 24 Jan 2009 13:16:43 +0100 Subject: [PATCH] Fixed editing PES recordings --- HISTORY | 4 ++++ recording.c | 17 ++++++++++++++++- recording.h | 3 ++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/HISTORY b/HISTORY index e3d7d4bd..b36651cc 100644 --- a/HISTORY +++ b/HISTORY @@ -5959,3 +5959,7 @@ Video Disk Recorder Revision History - Added an 'int' typecast to calculations involving FramesPerSecond() to avoid compiler warnings. - Fixed detecting frames for pure audio recordings. +- Fixed editing PES recordings. The frame type in the index.vdr file generated for + the edited PES recording is set to 1 for I-frames and 2 for all others (P- and + B-frames). The exact frame type doesn't matter for VDR, it only needs to know if + it's an I-frame or not. diff --git a/recording.c b/recording.c index 5dc1b308..9c7db99f 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.7 2009/01/24 11:31:16 kls Exp $ + * $Id: recording.c 2.8 2009/01/24 13:11:04 kls Exp $ */ #include "recording.h" @@ -1432,6 +1432,19 @@ void cIndexFile::ConvertFromPes(tIndexTs *IndexTs, int Count) } } +void cIndexFile::ConvertToPes(tIndexTs *IndexTs, int Count) +{ + tIndexPes IndexPes; + while (Count-- > 0) { + IndexPes.offset = uint32_t(IndexTs->offset); + IndexPes.type = IndexTs->independent ? 1 : 2; // I_FRAME : "not I_FRAME" (exact frame type doesn't matter) + IndexPes.number = IndexTs->number; + IndexPes.reserved = 0; + memcpy(IndexTs, &IndexPes, sizeof(*IndexTs)); + IndexTs++; + } +} + bool cIndexFile::CatchUp(int Index) { // returns true unless something really goes wrong, so that 'index' becomes NULL @@ -1491,6 +1504,8 @@ bool cIndexFile::Write(bool Independent, uint16_t FileNumber, off_t FileOffset) { if (f >= 0) { tIndexTs i(FileOffset, Independent, FileNumber); + if (isPesRecording) + ConvertToPes(&i, 1); if (safe_write(f, &i, sizeof(i)) < 0) { LOG_ERROR_STR(fileName); close(f); diff --git a/recording.h b/recording.h index 3a9b7154..119dd46e 100644 --- a/recording.h +++ b/recording.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: recording.h 2.2 2009/01/18 11:02:00 kls Exp $ + * $Id: recording.h 2.3 2009/01/24 13:05:03 kls Exp $ */ #ifndef __RECORDING_H @@ -229,6 +229,7 @@ private: cResumeFile resumeFile; cMutex mutex; void ConvertFromPes(tIndexTs *IndexTs, int Count); + void ConvertToPes(tIndexTs *IndexTs, int Count); bool CatchUp(int Index = -1); public: cIndexFile(const char *FileName, bool Record, bool IsPesRecording = false);