rendered paste bodyIndex: libs/libmythtv/nuppeldecoder.cpp
===================================================================
--- libs/libmythtv/nuppeldecoder.cpp (revision 23193)
+++ libs/libmythtv/nuppeldecoder.cpp (working copy)
@@ -1007,11 +1007,7 @@
}
}
-// avignore = 0 : get audio and video
-// = 1 : video only
-// = -1 : neither, just parse
-
-bool NuppelDecoder::GetFrame(int avignore)
+bool NuppelDecoder::GetFrame(DecodeType decodetype)
{
bool gotvideo = false;
bool ret = false;
@@ -1148,7 +1144,7 @@
if (frameheader.frametype == 'V')
{
- if (avignore == -1)
+ if (!(kDecodeVideo & decodetype))
{
framesPlayed++;
gotvideo = 1;
@@ -1198,7 +1194,7 @@
continue;
}
- if (frameheader.frametype=='A' && avignore == 0)
+ if (frameheader.frametype=='A' && (kDecodeAudio & decodetype))
{
if ((frameheader.comptype == '3') || (frameheader.comptype == 'A'))
{
@@ -1264,7 +1260,7 @@
}
}
- if (frameheader.frametype == 'T' && avignore >= 0)
+ if (frameheader.frametype == 'T' && (kDecodeVideo & decodetype))
{
if (getrawframes)
StoreRawData(strm);
@@ -1342,7 +1338,7 @@
for (;(skipFrames > 0) && !ateof; skipFrames--)
{
- GetFrame(0);
+ GetFrame(kDecodeAV);
if (decoded_video_frame)
GetNVP()->DiscardVideoFrame(decoded_video_frame);
}
Index: libs/libmythtv/NuppelVideoPlayer.cpp
===================================================================
--- libs/libmythtv/NuppelVideoPlayer.cpp (revision 23193)
+++ libs/libmythtv/NuppelVideoPlayer.cpp (working copy)
@@ -89,48 +89,6 @@
#define LOC_WARN QString("NVP(%1), Warning: ").arg(dbg_ident(this),0,36)
#define LOC_ERR QString("NVP(%1), Error: ").arg(dbg_ident(this),0,36)
-QString track_type_to_string(uint type)
-{
- QString str = QObject::tr("Track");
-
- if (kTrackTypeAudio == type)
- str = QObject::tr("Audio track");
- else if (kTrackTypeSubtitle == type)
- str = QObject::tr("Subtitle track");
- else if (kTrackTypeCC608 == type)
- str = QObject::tr("CC", "EIA-608 closed captions");
- else if (kTrackTypeCC708 == type)
- str = QObject::tr("ATSC CC", "EIA-708 closed captions");
- else if (kTrackTypeTeletextCaptions == type)
- str = QObject::tr("TT CC", "Teletext closed captions");
- else if (kTrackTypeTeletextMenu == type)
- str = QObject::tr("TT Menu", "Teletext Menu");
- else if (kTrackTypeTextSubtitle == type)
- str = QObject::tr("TXT File", "Text File");
- return str;
-}
-
-int type_string_to_track_type(const QString &str)
-{
- int ret = -1;
-
- if (str.left(5) == "AUDIO")
- ret = kTrackTypeAudio;
- else if (str.left(8) == "SUBTITLE")
- ret = kTrackTypeSubtitle;
- else if (str.left(5) == "CC608")
- ret = kTrackTypeCC608;
- else if (str.left(5) == "CC708")
- ret = kTrackTypeCC708;
- else if (str.left(3) == "TTC")
- ret = kTrackTypeTeletextCaptions;
- else if (str.left(3) == "TTM")
- ret = kTrackTypeTeletextMenu;
- else if (str.left(3) == "TFL")
- ret = kTrackTypeTextSubtitle;
- return ret;
-}
-
uint track_type_to_display_mode[kTrackTypeCount+2] =
{
kDisplayNone,
@@ -1524,9 +1482,9 @@
#endif
}
-bool NuppelVideoPlayer::GetFrameNormal(int onlyvideo)
+bool NuppelVideoPlayer::GetFrameNormal(DecodeType decodetype)
{
- if (!GetDecoder()->GetFrame(onlyvideo))
+ if (!GetDecoder()->GetFrame(decodetype))
return false;
CheckPrebuffering();
@@ -1580,12 +1538,12 @@
Play(stretch, true, true);
}
- bool ret = GetDecoder()->GetFrame(1);
+ bool ret = GetDecoder()->GetFrame(kDecodeVideo);
CheckPrebuffering();
return ret;
}
-bool NuppelVideoPlayer::GetFrame(int onlyvideo, bool unsafe)
+bool NuppelVideoPlayer::GetFrame(DecodeType decodetype, bool unsafe)
{
bool ret = false;
@@ -1612,7 +1570,7 @@
if (!GetDecoder())
VERBOSE(VB_IMPORTANT, LOC + "GetFrame() called with NULL decoder.");
else if (ffrew_skip == 1)
- ret = GetFrameNormal(onlyvideo);
+ ret = GetFrameNormal(decodetype);
else
ret = GetFrameFFREW();
@@ -3417,7 +3375,8 @@
void NuppelVideoPlayer::RefreshPauseFrame(void)
{
- GetFrame(audioOutput == NULL || !normal_speed);
+ DecodeType dt = (audioOutput && normal_speed) ? kDecodeAV : kDecodeVideo;
+ GetFrame(dt);
resetvideo = true;
while (resetvideo)
@@ -3533,7 +3492,9 @@
if (bookmarkseek > 30)
{
- GetFrame(audioOutput == NULL || !normal_speed);
+ DecodeType dt = (audioOutput && normal_speed) ?
+ kDecodeAV : kDecodeVideo;
+ GetFrame(dt);
bool seeks = exactseeks;
@@ -3779,7 +3740,9 @@
continue;
}
- GetFrame(audioOutput == NULL || !normal_speed);
+ DecodeType dt = (audioOutput && normal_speed) ?
+ kDecodeAV : kDecodeVideo;
+ GetFrame(dt);
if (using_null_videoout)
GetDecoder()->UpdateFramesPlayed();
@@ -5848,7 +5811,7 @@
else if (player_ctx->buffer->DVD()->GetTotalTimeOfTitle() < 60)
{
GoToDVDProgram(1);
- GetFrame(1);
+ GetFrame(kDecodeVideo);
number = frameNum;
if (number >= totalFrames)
@@ -5908,7 +5871,7 @@
// Only do seek if we have position map
if (hasFullPositionMap && !player_ctx->buffer->isDVD())
{
- GetFrame(1);
+ GetFrame(kDecodeVideo);
DiscardVideoFrame(videoOutput->GetLastDecodedFrame());
fftime = number;
@@ -5916,7 +5879,7 @@
fftime = 0;
}
- GetFrame(1);
+ GetFrame(kDecodeVideo);
if (!(frame = videoOutput->GetLastDecodedFrame()))
{
@@ -5979,7 +5942,7 @@
ClearAfterSeek();
}
- GetFrame(1,true);
+ GetFrame(kDecodeVideo,true);
return videoOutput->GetLastDecodedFrame();
}
@@ -6061,7 +6024,7 @@
if ((lastDecodedFrameNumber == 0) && honorCutList)
dm_iter = deleteMap.begin();
- if (!GetDecoder()->GetFrame(0))
+ if (!GetDecoder()->GetFrame(kDecodeAV))
return false;
if (eof)
return false;
@@ -6088,7 +6051,7 @@
GetDecoder()->DoFastForward(dm_iter.key());
GetDecoder()->ClearStoredData();
ClearAfterSeek();
- GetDecoder()->GetFrame(0);
+ GetDecoder()->GetFrame(kDecodeAV);
*did_ff = 1;
}
while(((*dm_iter) == 0) && (dm_iter != deleteMap.end()))
@@ -6236,7 +6199,7 @@
inuse_timer.start();
save_timer.start();
- GetFrame(-1,true);
+ GetFrame(kDecodeNothing,true);
if (showPercentage)
{
if (totalFrames)
@@ -6306,7 +6269,7 @@
}
}
- GetFrame(-1,true);
+ GetFrame(kDecodeNothing,true);
}
if (showPercentage)
@@ -6613,7 +6576,7 @@
UnpauseVideo(true);
}
- GetFrame(1, true);
+ GetFrame(kDecodeVideo, true);
}
else
{
@@ -6982,7 +6945,7 @@
{
QString msg = "";
- //msg = track_type_to_string(type);
+ //msg = toString((TrackType)type);
msg = GetDecoder()->GetTrackDesc(type, GetTrack(type));
Index: libs/libmythtv/decoderbase.h
===================================================================
--- libs/libmythtv/decoderbase.h (revision 23193)
+++ libs/libmythtv/decoderbase.h (working copy)
@@ -5,7 +5,6 @@
#include <stdint.h>
#include "RingBuffer.h"
-#include "NuppelVideoPlayer.h"
#include "remoteencoder.h"
#include "mythcontext.h"
#include "mythdbcon.h"
@@ -14,9 +13,34 @@
class RingBuffer;
class TeletextViewer;
+class NuppelVideoPlayer;
const int kDecoderProbeBufferSize = 65536;
+/// Track types
+typedef enum TrackTypes
+{
+ kTrackTypeAudio = 0,
+ kTrackTypeSubtitle,
+ kTrackTypeCC608,
+ kTrackTypeCC708,
+ kTrackTypeTeletextCaptions,
+ kTrackTypeCount,
+
+ kTrackTypeTeletextMenu,
+ kTrackTypeTextSubtitle,
+} TrackType;
+QString toString(TrackType type);
+int to_track_type(const QString &str);
+
+typedef enum DecodeTypes
+{
+ kDecodeNothing = 0x00, // Demux and preprocess only.
+ kDecodeVideo = 0x01,
+ kDecodeAudio = 0x02,
+ kDecodeAV = 0x03,
+} DecodeType;
+
class StreamInfo
{
public:
@@ -75,10 +99,8 @@
virtual void SetDisablePassThrough(bool disable) { (void)disable; }
virtual void setWatchingRecording(bool mode);
- /// Decode a frame of video/audio. If onlyvideo is +1,
- /// decodes the video portion, if it is -1 only decodes
- /// the audio portion, if it is 0 it decodes audio and video
- virtual bool GetFrame(int onlyvideo) = 0;
+ /// Demux, preprocess and possibly decode a frame of video/audio.
+ virtual bool GetFrame(DecodeType) = 0;
NuppelVideoPlayer *GetNVP() { return m_parent; }
virtual bool DoRewind(long long desiredFrame, bool doflush = true);
Index: libs/libmythtv/avformatdecoder.cpp
===================================================================
--- libs/libmythtv/avformatdecoder.cpp (revision 23193)
+++ libs/libmythtv/avformatdecoder.cpp (working copy)
@@ -775,7 +775,7 @@
// Skip all the desired number of skipFrames
for (;skipFrames > 0 && !ateof; skipFrames--)
{
- GetFrame(0);
+ GetFrame(kDecodeVideo);
if (decoded_video_frame)
GetNVP()->DiscardVideoFrame(decoded_video_frame);
}
@@ -3305,7 +3305,7 @@
}
// documented in decoderbase.h
-bool AvFormatDecoder::GetFrame(int onlyvideo)
+bool AvFormatDecoder::GetFrame(DecodeType decodetype)
{
AVPacket *pkt = NULL;
AC3HeaderInfo hdr;
@@ -3331,10 +3331,10 @@
bool has_video = HasVideo(ic);
- if (!has_video && (onlyvideo >= 0))
+ if (!has_video && (decodetype & kDecodeVideo))
{
gotvideo = GenerateDummyVideoFrame();
- onlyvideo = -1;
+ decodetype = (DecodeType)((int)decodetype & ~kDecodeVideo);
skipaudio = false;
}
@@ -3342,19 +3342,19 @@
if (GetNVP()->GetAudioBufferStatus(ofill, ototal))
{
othresh = ((ototal>>1) + (ototal>>2));
- allowedquit = (onlyvideo < 0) && (ofill > othresh);
+ allowedquit = (!(decodetype & kDecodeAudio)) && (ofill > othresh);
}
while (!allowedquit)
{
- if ((onlyvideo == 0) &&
+ if ((decodetype & kDecodeAudio) &&
((currentTrack[kTrackTypeAudio] < 0) ||
(selectedTrack[kTrackTypeAudio].av_stream_index < 0)))
{
// disable audio request if there are no audio streams anymore
// and we have video, otherwise allow decoding to stop
if (has_video)
- onlyvideo = 1;
+ decodetype = (DecodeType)((int)decodetype & ~kDecodeAudio);
else
allowedquit = true;
}
@@ -3433,21 +3433,21 @@
if (gotvideo)
{
- if (onlyvideo < 0)
+ if (decodetype == kDecodeNothing)
{
// no need to buffer audio or video if we
// only care about building a keyframe map.
allowedquit = true;
continue;
}
- else if (lowbuffers && onlyvideo == 0 &&
+ else if (lowbuffers && ((decodetype & kDecodeAV) == kDecodeAV) &&
storedPackets.count() < max_video_queue_size &&
lastapts < lastvpts + 100 &&
!ringBuffer->InDVDMenuOrStillFrame())
{
storevideoframes = true;
}
- else
+ else if (decodetype & kDecodeVideo)
{
if (storedPackets.count() >= max_video_queue_size)
VERBOSE(VB_IMPORTANT,
@@ -3688,7 +3688,7 @@
// Have to return regularly to ensure that the OSD is updated.
// This applies both to MHEG and also channel browsing.
- if (onlyvideo < 0)
+ if (!(decodetype & kDecodeVideo))
{
allowedquit |= (itv && itv->ImageHasChanged());
OSD *osd = NULL;
@@ -3817,7 +3817,8 @@
.av_substream_index;
}
- if ((onlyvideo > 0) || (pkt->stream_index != audIdx))
+ if (!(decodetype & kDecodeAudio) ||
+ (pkt->stream_index != audIdx))
{
ptr += len;
len = 0;
@@ -3975,11 +3976,11 @@
total_decoded_audio += data_size;
allowedquit |= ringBuffer->InDVDMenuOrStillFrame();
- allowedquit |= (onlyvideo < 0) &&
+ allowedquit |= !(decodetype & kDecodeVideo) &&
(ofill + total_decoded_audio > othresh);
// top off audio buffers initially in audio only mode
- if (!allowedquit && (onlyvideo < 0))
+ if (!allowedquit && !(decodetype & kDecodeVideo))
{
uint fill, total;
if (GetNVP()->GetAudioBufferStatus(fill, total))
@@ -4015,11 +4016,9 @@
lastccptsu = (long long)
(av_q2d(curstream->time_base)*pkt->pts*1000000);
}
- if (onlyvideo < 0)
+
+ if (!(decodetype & kDecodeVideo))
{
- // if onlyvideo < 0 we really just want
- // to find the keyframes, we don't care
- // about decoding the actual video content.
framesPlayed++;
gotvideo = 1;
ptr += pkt->size;
Index: libs/libmythtv/nuppeldecoder.h
===================================================================
--- libs/libmythtv/nuppeldecoder.h (revision 23193)
+++ libs/libmythtv/nuppeldecoder.h (working copy)
@@ -40,8 +40,9 @@
int OpenFile(RingBuffer *rbuffer, bool novideo,
char testbuf[kDecoderProbeBufferSize],
int testbufsize = kDecoderProbeBufferSize);
- bool GetFrame(int onlyvideo);
+ virtual bool GetFrame(DecodeType); // DecoderBase
+
// lastFrame is really (framesPlayed - 1) since we increment after getting
bool isLastFrameKey(void) { return (lastKey == framesPlayed); }
void WriteStoredData(RingBuffer *rb, bool writevid, long timecodeOffset);
Index: libs/libmythtv/NuppelVideoPlayer.h
===================================================================
--- libs/libmythtv/NuppelVideoPlayer.h (revision 23193)
+++ libs/libmythtv/NuppelVideoPlayer.h (working copy)
@@ -16,6 +16,7 @@
#include "cc608decoder.h"
#include "cc708decoder.h"
#include "cc708window.h"
+#include "decoderbase.h"
#include "mythexp.h"
@@ -68,22 +69,6 @@
};
#define TCTYPESMAX 4
-/// Track types
-enum
-{
- kTrackTypeAudio = 0,
- kTrackTypeSubtitle,
- kTrackTypeCC608,
- kTrackTypeCC708,
- kTrackTypeTeletextCaptions,
- kTrackTypeCount,
-
- kTrackTypeTeletextMenu,
- kTrackTypeTextSubtitle,
-};
-QString track_type_to_string(uint type);
-int type_string_to_track_type(const QString &str);
-
// Caption Display modes
enum
{
@@ -467,9 +452,9 @@
bool PrebufferEnoughFrames(void);
void CheckPrebuffering(void);
- bool GetFrameNormal(int onlyvideo);
+ bool GetFrameNormal(DecodeType);
bool GetFrameFFREW(void);
- bool GetFrame(int onlyvideo, bool unsafe = false);
+ bool GetFrame(DecodeType, bool unsafe = false);
// These actually execute commands requested by public members
void DoPause(void);
Index: libs/libmythtv/tv_play.cpp
===================================================================
--- libs/libmythtv/tv_play.cpp (revision 23193)
+++ libs/libmythtv/tv_play.cpp (working copy)
@@ -3458,7 +3458,7 @@
}
else if (action.left(6) == "TOGGLE")
{
- int type = type_string_to_track_type(action.mid(6));
+ int type = to_track_type(action.mid(6));
if (type == kTrackTypeTeletextMenu)
{
handled = true;
@@ -3472,7 +3472,7 @@
}
else if (action.left(6) == "SELECT")
{
- int type = type_string_to_track_type(action.mid(6));
+ int type = to_track_type(action.mid(6));
int mid = (kTrackTypeSubtitle == type) ? 15 : 12;
if (type >= kTrackTypeAudio)
{
@@ -3483,7 +3483,7 @@
else if (action.left(4) == "NEXT" || action.left(4) == "PREV")
{
int dir = (action.left(4) == "NEXT") ? +1 : -1;
- int type = type_string_to_track_type(action.mid(4));
+ int type = to_track_type(action.mid(4));
if (type >= kTrackTypeAudio)
{
handled = true;
Index: libs/libmythtv/remoteencoder.h
===================================================================
--- libs/libmythtv/remoteencoder.h (revision 23193)
+++ libs/libmythtv/remoteencoder.h (working copy)
@@ -3,6 +3,7 @@
#include <QString>
#include <QMutex>
+#include <QHash>
#include <QMap>
#include "mythexp.h"
Index: libs/libmythtv/decoderbase.cpp
===================================================================
--- libs/libmythtv/decoderbase.cpp (revision 23193)
+++ libs/libmythtv/decoderbase.cpp (working copy)
@@ -653,7 +653,7 @@
exitafterdecoded = true; // don't actualy get a frame
while ((desiredFrame > last_frame) && !ateof)
{
- GetFrame(-1); // don't need to return frame...
+ GetFrame(kDecodeNothing); // don't need to return frame...
last_frame = GetLastFrameInPosMap();
}
exitafterdecoded = false; // allow frames to be returned again
@@ -874,7 +874,7 @@
QMutexLocker locker(avcodeclock);
- QString type_msg = track_type_to_string(type);
+ QString type_msg = toString((TrackType)type);
int lang = tracks[type][trackNo].language;
int hnum = trackNo + 1;
if (kTrackTypeCC608 == type)
@@ -1035,4 +1035,46 @@
return selTrack;
}
+QString toString(TrackType type)
+{
+ QString str = QObject::tr("Track");
+
+ if (kTrackTypeAudio == type)
+ str = QObject::tr("Audio track");
+ else if (kTrackTypeSubtitle == type)
+ str = QObject::tr("Subtitle track");
+ else if (kTrackTypeCC608 == type)
+ str = QObject::tr("CC", "EIA-608 closed captions");
+ else if (kTrackTypeCC708 == type)
+ str = QObject::tr("ATSC CC", "EIA-708 closed captions");
+ else if (kTrackTypeTeletextCaptions == type)
+ str = QObject::tr("TT CC", "Teletext closed captions");
+ else if (kTrackTypeTeletextMenu == type)
+ str = QObject::tr("TT Menu", "Teletext Menu");
+ else if (kTrackTypeTextSubtitle == type)
+ str = QObject::tr("TXT File", "Text File");
+ return str;
+}
+
+int to_track_type(const QString &str)
+{
+ int ret = -1;
+
+ if (str.left(5) == "AUDIO")
+ ret = kTrackTypeAudio;
+ else if (str.left(8) == "SUBTITLE")
+ ret = kTrackTypeSubtitle;
+ else if (str.left(5) == "CC608")
+ ret = kTrackTypeCC608;
+ else if (str.left(5) == "CC708")
+ ret = kTrackTypeCC708;
+ else if (str.left(3) == "TTC")
+ ret = kTrackTypeTeletextCaptions;
+ else if (str.left(3) == "TTM")
+ ret = kTrackTypeTeletextMenu;
+ else if (str.left(3) == "TFL")
+ ret = kTrackTypeTextSubtitle;
+ return ret;
+}
+
/* vim: set expandtab tabstop=4 shiftwidth=4: */
Index: libs/libmythtv/avformatdecoder.h
===================================================================
--- libs/libmythtv/avformatdecoder.h (revision 23193)
+++ libs/libmythtv/avformatdecoder.h (working copy)
@@ -96,7 +96,7 @@
char testbuf[kDecoderProbeBufferSize],
int testbufsize = kDecoderProbeBufferSize);
- bool GetFrame(int onlyvideo);
+ virtual bool GetFrame(DecodeType); // DecoderBase
bool isLastFrameKey(void) { return false; }
Index: libs/libmythtv/dummydecoder.h
===================================================================
--- libs/libmythtv/dummydecoder.h (revision 23193)
+++ libs/libmythtv/dummydecoder.h (working copy)
@@ -19,7 +19,7 @@
virtual ~DummyDecoder() {}
virtual int OpenFile(RingBuffer *, bool, char *, int) { return 0; }
- virtual bool GetFrame(int) { usleep(10000); return false; }
+ virtual bool GetFrame(DecodeType) { usleep(10000); return false; }
virtual bool isLastFrameKey(void) { return true; }
virtual void WriteStoredData(RingBuffer *, bool, long) {}