rendered paste bodydiff --git a/mythtv/libs/libmyth/programinfo.cpp b/mythtv/libs/libmyth/programinfo.cpp
index 8793940..e09f5fb 100644
--- a/mythtv/libs/libmyth/programinfo.cpp
+++ b/mythtv/libs/libmyth/programinfo.cpp
@@ -3559,7 +3559,7 @@ void ProgramInfo::SaveTotalFrames(int64_t frames)
query.bindValue(":DATA", (uint)(frames));
if (!query.exec())
- MythDB::DBError("Frames insert", query);
+ MythDB::DBError("Total Frames insert", query);
}
/// \brief Store the Resolution at frame in the recordedmarkup table
diff --git a/mythtv/libs/libmythtv/dtvrecorder.cpp b/mythtv/libs/libmythtv/dtvrecorder.cpp
index e0a5335..4ea842a 100644
--- a/mythtv/libs/libmythtv/dtvrecorder.cpp
+++ b/mythtv/libs/libmythtv/dtvrecorder.cpp
@@ -75,13 +75,18 @@ DTVRecorder::DTVRecorder(TVRec *rec) :
// statistics
_packet_count(0),
_continuity_error_count(0),
- _frames_seen_count(0), _frames_written_count(0)
+ _frames_seen_count(0), _frames_written_count(0),
+ _duration(0)
{
SetPositionMapType(MARK_GOP_BYFRAME);
_payload_buffer.reserve(TSPacket::kSize * (50 + 1));
memset(_stream_id, 0, sizeof(_stream_id));
memset(_pid_status, 0, sizeof(_pid_status));
memset(_continuity_counter, 0, sizeof(_continuity_counter));
+ pc = new ParseContext1;
+ memset(pc, 0, sizeof(struct ParseContext1));
+ s = new AVCodecParserContext;
+ memset(s, 0, sizeof(struct AVCodecParserContext));
}
DTVRecorder::~DTVRecorder()
@@ -101,6 +106,12 @@ DTVRecorder::~DTVRecorder()
delete _input_pmt;
_input_pmt = NULL;
}
+
+ if (pc)
+ {
+ delete pc;
+ pc = NULL;
+ }
}
void DTVRecorder::SetOption(const QString &name, const QString &value)
@@ -155,6 +166,9 @@ void DTVRecorder::FinishRecording(void)
if (ringBuffer)
curRecording->SaveFilesize(ringBuffer->GetRealFileSize());
SavePositionMap(true);
+ LOG(VB_RECORD, LOG_INFO, LOC + "Storing duration and total frames");
+ SetDuration(_duration);
+ SetTotalFrames(_frames_written_count);
}
// positionMapLock.lock();
// positionMap.clear();
@@ -339,7 +353,6 @@ bool DTVRecorder::FindMPEG2Keyframes(const TSPacket* tspacket)
// (there are others that we don't care about)
const uint8_t *bufptr = tspacket->data() + tspacket->AFCOffset();
const uint8_t *bufend = tspacket->data() + TSPacket::kSize;
- int progressive_sequence = 0;
int ext_type, bytes_left;
int picture_structure, top_field_first, repeat_first_field, progressive_frame;
int repeat_pict = 0;
@@ -384,7 +397,7 @@ bool DTVRecorder::FindMPEG2Keyframes(const TSPacket* tspacket)
case 0x1: /* sequence extension */
if (bytes_left >= 6)
{
- progressive_sequence = bufptr[1] & (1 << 3);
+ pc->progressive_sequence = bufptr[1] & (1 << 3);
}
break;
case 0x8: /* picture coding extension */
@@ -399,7 +412,7 @@ bool DTVRecorder::FindMPEG2Keyframes(const TSPacket* tspacket)
repeat_pict = 1;
if (repeat_first_field)
{
- if (progressive_sequence)
+ if (pc->progressive_sequence)
{
if (top_field_first)
repeat_pict = 5;
@@ -441,6 +454,11 @@ bool DTVRecorder::FindMPEG2Keyframes(const TSPacket* tspacket)
_frames_seen_count++;
if (!_wait_for_keyframe_option || _first_keyframe>=0)
_frames_written_count++;
+ _duration += (int64_t)((1.0f / frameRate / 1000.0f) +
+ (repeat_pict * 0.5) / (frameRate / 1000.0f)
+ * 1000000);
+ LOG(VB_RECORD, LOG_INFO, LOC + QString("Duration = %1 (%2 %3)")
+ .arg(_duration).arg(_frames_written_count).arg(frameRate));
}
if ((aspectRatio > 0) && (aspectRatio != m_videoAspect))
diff --git a/mythtv/libs/libmythtv/dtvrecorder.h b/mythtv/libs/libmythtv/dtvrecorder.h
index 25b8c7e..64d66df 100644
--- a/mythtv/libs/libmythtv/dtvrecorder.h
+++ b/mythtv/libs/libmythtv/dtvrecorder.h
@@ -18,6 +18,10 @@ using namespace std;
#include "recorderbase.h"
#include "H264Parser.h"
+extern "C" {
+#include "libavcodec/parser.h"
+}
+
class MPEGStreamData;
class TSPacket;
class QTime;
@@ -132,6 +136,10 @@ class DTVRecorder :
unsigned int _video_bytes_remaining;
unsigned int _other_bytes_remaining;
+ // used for storing sequence header information
+ ParseContext1 *pc;
+ AVCodecParserContext *s;
+
// H.264 support
bool _pes_synced;
bool _seen_sps;
@@ -169,6 +177,7 @@ class DTVRecorder :
mutable unsigned long long _continuity_error_count;
unsigned long long _frames_seen_count;
unsigned long long _frames_written_count;
+ unsigned long long _duration;
// constants
/// If the number of regular frames detected since the last
diff --git a/mythtv/libs/libmythtv/mythcommflagplayer.cpp b/mythtv/libs/libmythtv/mythcommflagplayer.cpp
index 4f104b4..dc1a1b7 100644
--- a/mythtv/libs/libmythtv/mythcommflagplayer.cpp
+++ b/mythtv/libs/libmythtv/mythcommflagplayer.cpp
@@ -186,6 +186,7 @@ bool MythCommFlagPlayer::RebuildSeekTable(
cout << "\r \r" << flush;
SaveTotalDuration();
+ SaveTotalFrames();
SetPlaying(false);
killdecoder = true;
diff --git a/mythtv/libs/libmythtv/mythplayer.cpp b/mythtv/libs/libmythtv/mythplayer.cpp
index 99fd103..297b478 100644
--- a/mythtv/libs/libmythtv/mythplayer.cpp
+++ b/mythtv/libs/libmythtv/mythplayer.cpp
@@ -4808,6 +4808,14 @@ void MythPlayer::ResetTotalDuration(void)
decoder->ResetTotalDuration();
}
+void MythPlayer::SaveTotalFrames(void)
+{
+ if (!decoder)
+ return;
+
+ decoder->SaveTotalFrames();
+}
+
static unsigned dbg_ident(const MythPlayer *player)
{
static QMutex dbg_lock;
diff --git a/mythtv/libs/libmythtv/mythplayer.h b/mythtv/libs/libmythtv/mythplayer.h
index 9434d7e..3cd8783 100644
--- a/mythtv/libs/libmythtv/mythplayer.h
+++ b/mythtv/libs/libmythtv/mythplayer.h
@@ -304,6 +304,8 @@ class MTV_PUBLIC MythPlayer
void SaveTotalDuration(void);
void ResetTotalDuration(void);
+ void SaveTotalFrames(void);
+
protected:
// Initialization
void OpenDummy(void);
diff --git a/mythtv/libs/libmythtv/recorderbase.cpp b/mythtv/libs/libmythtv/recorderbase.cpp
index ed7c0e0..90a95be 100644
--- a/mythtv/libs/libmythtv/recorderbase.cpp
+++ b/mythtv/libs/libmythtv/recorderbase.cpp
@@ -454,6 +454,13 @@ void RecorderBase::SetDuration(uint64_t duration)
curRecording->SaveTotalDuration(duration);
}
+void RecorderBase::SetTotalFrames(uint64_t total_frames)
+{
+ if (curRecording)
+ curRecording->SaveTotalFrames(total_frames);
+}
+
+
RecorderBase *RecorderBase::CreateRecorder(
diff --git a/mythtv/libs/libmythtv/recorderbase.h b/mythtv/libs/libmythtv/recorderbase.h
index 34a444d..c2f8635 100644
--- a/mythtv/libs/libmythtv/recorderbase.h
+++ b/mythtv/libs/libmythtv/recorderbase.h
@@ -248,6 +248,10 @@ class MTV_PUBLIC RecorderBase : public QRunnable
*/
void SetDuration(uint64_t duration);
+ /** \brief Note the total frames in the recordedmark table
+ */
+ void SetTotalFrames(uint64_t total_frames);
+
TVRec *tvrec;
RingBuffer *ringBuffer;
bool weMadeBuffer;