summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGavin Hurlbut <ghurlbut@mythtv.org>2010-11-25 00:28:19 (GMT)
committer Gavin Hurlbut <ghurlbut@mythtv.org>2010-11-25 00:28:19 (GMT)
commit9317b10f70d3699718ca4391ee2aade823e35105 (patch)
tree28d4e40a7dcad9336208b8a45bf041e6e76f6447
parentba0e1ac2998fb742e12c040a1ffd7907169c1f34 (diff)
Backport [27338] from trunk.
Should make the black/glitched-out previews not happen anymore. Fixes in-recording seektable generation for MPEG2-TS, and gets MPEG2-PS nearly fixed. Refs #9256 git-svn-id: http://svn.mythtv.org/svn/branches/release-0-24-fixes@27339 7dbf422c-18fa-0310-86e9-fd20926502f2
-rw-r--r--mythtv/libs/libmythtv/dtvrecorder.cpp30
-rw-r--r--mythtv/libs/libmythtv/dtvrecorder.h2
2 files changed, 19 insertions, 13 deletions
diff --git a/mythtv/libs/libmythtv/dtvrecorder.cpp b/mythtv/libs/libmythtv/dtvrecorder.cpp
index cd29039..f043b64 100644
--- a/mythtv/libs/libmythtv/dtvrecorder.cpp
+++ b/mythtv/libs/libmythtv/dtvrecorder.cpp
@@ -11,6 +11,7 @@
#include "mpegstreamdata.h"
#include "dtvrecorder.h"
#include "tv_rec.h"
+#include "mythverbose.h"
extern "C" {
extern const uint8_t *ff_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state);
@@ -329,7 +330,7 @@ bool DTVRecorder::FindMPEG2Keyframes(const TSPacket* tspacket)
if (hasKeyFrame)
{
_last_keyframe_seen = _frames_seen_count;
- HandleKeyframe();
+ HandleKeyframe(_frames_written_count, TSPacket::SIZE);
}
if (hasFrame)
@@ -388,7 +389,7 @@ bool DTVRecorder::FindAudioKeyframes(const TSPacket*)
if (1 == (_frames_seen_count & 0x7))
{
_last_keyframe_seen = _frames_seen_count;
- HandleKeyframe();
+ HandleKeyframe(_frames_written_count);
hasKeyFrame = true;
}
@@ -416,7 +417,7 @@ bool DTVRecorder::FindOtherKeyframes(const TSPacket *tspacket)
_frames_written_count++;
_last_keyframe_seen = _frames_seen_count;
- HandleKeyframe();
+ HandleKeyframe(_frames_written_count);
_has_written_other_keyframe = true;
@@ -451,12 +452,14 @@ void DTVRecorder::SetNextRecording(const ProgramInfo *progInf, RingBuffer *rb)
* \brief This save the current frame to the position maps
* and handles ringbuffer switching.
*/
-void DTVRecorder::HandleKeyframe(uint64_t extra)
+void DTVRecorder::HandleKeyframe(uint64_t frameNum, int64_t extra)
{
if (!ringBuffer)
return;
+#if 0
unsigned long long frameNum = _frames_written_count;
+#endif
_first_keyframe = (_first_keyframe < 0) ? frameNum : _first_keyframe;
@@ -466,7 +469,7 @@ void DTVRecorder::HandleKeyframe(uint64_t extra)
{
long long startpos = ringBuffer->GetWritePosition();
// FIXME: handle keyframes with start code spanning over two ts packets
- startpos += _payload_buffer.size() + extra;
+ startpos += _payload_buffer.size() - extra;
// Don't put negative offsets into the database, they get munged into
// MAX_INT64 - offset, which is an exceedingly large number, and
@@ -773,19 +776,19 @@ void DTVRecorder::FindPSKeyFrames(const uint8_t *buffer, uint len)
hasKeyFrame &= (_last_seq_seen + maxKFD) < _frames_seen_count;
}
- if (hasKeyFrame)
- {
- _last_keyframe_seen = _frames_seen_count;
- HandleKeyframe(bufptr - bufstart);
- }
-
if (hasFrame)
{
_frames_seen_count++;
- if (!_wait_for_keyframe_option || _first_keyframe>=0)
+ if (!_wait_for_keyframe_option || _first_keyframe >= 0)
_frames_written_count++;
}
+ if (hasKeyFrame)
+ {
+ _last_keyframe_seen = _frames_seen_count;
+ HandleKeyframe(_frames_written_count, bufptr - bufstart);
+ }
+
if ((aspectRatio > 0) && (aspectRatio != m_videoAspect))
{
m_videoAspect = aspectRatio;
@@ -846,6 +849,9 @@ void DTVRecorder::FindPSKeyFrames(const uint8_t *buffer, uint len)
uint64_t rem = (bufend - bufstart);
_payload_buffer.resize(idx + rem);
memcpy(&_payload_buffer[idx], bufstart, rem);
+#if 0
+VERBOSE(VB_GENERAL, QString("idx: %1, rem: %2").arg(idx).arg(rem) );
+#endif
}
/* vim: set expandtab tabstop=4 shiftwidth=4: */
diff --git a/mythtv/libs/libmythtv/dtvrecorder.h b/mythtv/libs/libmythtv/dtvrecorder.h
index aa3b173..55da6ec 100644
--- a/mythtv/libs/libmythtv/dtvrecorder.h
+++ b/mythtv/libs/libmythtv/dtvrecorder.h
@@ -51,7 +51,7 @@ class DTVRecorder: public RecorderBase
void FinishRecording(void);
void ResetForNewFile(void);
- void HandleKeyframe(uint64_t extra = 0);
+ void HandleKeyframe(uint64_t frameNum, int64_t extra = 0);
void BufferedWrite(const TSPacket &tspacket);