Skip to content

Commit

Permalink
Add a new 'commercial' flagger "Pre & Post Roll" that is
Browse files Browse the repository at this point in the history
DESIGNED TO FLAG -=-=-=ONLY=-=-=- THE PRE/POST ROLL PARTS

of a recording so that they can be easily skipped.  This is meant to be
used on channels without commercials such as movie channels that have
their own 'commercials' prior to and following a movie.  This flagger
will attempt to highlight those areas so that they can be easily skipped
during playback.

Closes #6889 using patch by Paul ?Turpin?.



git-svn-id: http://svn.mythtv.org/svn/trunk@21446 7dbf422c-18fa-0310-86e9-fd20926502f2
  • Loading branch information
cpinkham committed Aug 23, 2009
1 parent 2fdeb3f commit 9f5ee51
Show file tree
Hide file tree
Showing 8 changed files with 527 additions and 36 deletions.
5 changes: 5 additions & 0 deletions mythtv/libs/libmyth/programinfo.cpp
Expand Up @@ -3499,6 +3499,7 @@ QString SkipTypeToString(int flags)
bool scene = COMM_DETECT_SCENE & flags;
bool logo = COMM_DETECT_LOGO & flags;
bool exp = COMM_DETECT_2 & flags;
bool prePst= COMM_DETECT_PREPOSTROLL & flags;

if (blank && scene && logo)
ret = QObject::tr("All Available Methods");
Expand All @@ -3517,6 +3518,8 @@ QString SkipTypeToString(int flags)

if (exp)
ret = QObject::tr("Experimental") + ": " + ret;
else if(prePst)
ret = QObject::tr("Pre & Post Roll") + ": " + ret;

return ret;
}
Expand All @@ -3530,6 +3533,8 @@ deque<int> GetPreferredSkipTypeCombinations(void)
tmp.push_back(COMM_DETECT_SCENE);
tmp.push_back(COMM_DETECT_LOGO);
tmp.push_back(COMM_DETECT_2 | COMM_DETECT_BLANK | COMM_DETECT_LOGO);
tmp.push_back(COMM_DETECT_PREPOSTROLL | COMM_DETECT_BLANK |
COMM_DETECT_SCENE);
return tmp;
}

Expand Down
5 changes: 5 additions & 0 deletions mythtv/libs/libmyth/programinfo.h
Expand Up @@ -83,6 +83,11 @@ typedef enum SkipTypes {
/* Scene detection doesn't seem to be too useful (in the USA); there *
* are just too many false positives from non-commercial cut scenes. */
COMM_DETECT_2_ALL = (COMM_DETECT_2_LOGO | COMM_DETECT_2_BLANK),

COMM_DETECT_PREPOSTROLL = 0x00000200,
COMM_DETECT_PREPOSTROLL_ALL = (COMM_DETECT_PREPOSTROLL
| COMM_DETECT_BLANKS
| COMM_DETECT_SCENE)
} SkipType;

MPUBLIC QString SkipTypeToString(int);
Expand Down
36 changes: 15 additions & 21 deletions mythtv/programs/mythcommflag/ClassicCommDetector.cpp
Expand Up @@ -22,15 +22,6 @@ using namespace std;
#include "ClassicLogoDetector.h"
#include "ClassicSceneChangeDetector.h"

enum frameMaskValues {
COMM_FRAME_SKIPPED = 0x0001,
COMM_FRAME_BLANK = 0x0002,
COMM_FRAME_SCENE_CHANGE = 0x0004,
COMM_FRAME_LOGO_PRESENT = 0x0008,
COMM_FRAME_ASPECT_CHANGE = 0x0010,
COMM_FRAME_RATING_SYMBOL = 0x0020
} FrameMaskValues;

enum frameAspects {
COMM_ASPECT_NORMAL = 0,
COMM_ASPECT_WIDE
Expand Down Expand Up @@ -132,28 +123,31 @@ ClassicCommDetector::ClassicCommDetector(SkipType commDetectMethod_in,
const QDateTime& stopsAt_in,
const QDateTime& recordingStartedAt_in,
const QDateTime& recordingStopsAt_in) :
commDetectMethod(commDetectMethod_in), showProgress(showProgress_in),
fullSpeed(fullSpeed_in), nvp(nvp_in),
startedAt(startedAt_in), stopsAt(stopsAt_in),
recordingStartedAt(recordingStartedAt_in),
recordingStopsAt(recordingStopsAt_in),
stillRecording(recordingStopsAt > QDateTime::currentDateTime()),


commDetectMethod(commDetectMethod_in),
commBreakMapUpdateRequested(false), sendCommBreakMapUpdates(false),
aggressiveDetection(false), verboseDebugging(false),
verboseDebugging(false),
lastFrameNumber(0), curFrameNumber(0),
width(0), height(0),
horizSpacing(0), vertSpacing(0),
fps(0.0), fpm(0.0),
blankFramesOnly(false), blankFrameCount(0),
currentAspect(0), framesProcessed(0),
preRoll(0), postRoll(0),
fpm(0.0), blankFramesOnly(false),
blankFrameCount(0), currentAspect(0),
totalMinBrightness(0), detectBlankFrames(false),
detectSceneChanges(false), detectStationLogo(false),
logoInfoAvailable(false), logoDetector(0),
framePtr(0), frameIsBlank(false),
sceneHasChanged(false), stationLogoPresent(false),
lastFrameWasBlank(false), lastFrameWasSceneChange(false),
decoderFoundAspectChanges(false), sceneChangeDetector(0)
decoderFoundAspectChanges(false), sceneChangeDetector(0),
nvp(nvp_in),
startedAt(startedAt_in), stopsAt(stopsAt_in),
recordingStartedAt(recordingStartedAt_in),
recordingStopsAt(recordingStopsAt_in), aggressiveDetection(false),
stillRecording(recordingStopsAt > QDateTime::currentDateTime()),
fullSpeed(fullSpeed_in), showProgress(showProgress_in),
fps(0.0), framesProcessed(0),
preRoll(0), postRoll(0)
{
commDetectBorder =
gContext->GetNumSetting("CommDetectBorder", 20);
Expand Down
43 changes: 28 additions & 15 deletions mythtv/programs/mythcommflag/ClassicCommDetector.h
Expand Up @@ -20,6 +20,15 @@ class NuppelVideoPlayer;
class LogoDetectorBase;
class SceneChangeDetectorBase;

enum frameMaskValues {
COMM_FRAME_SKIPPED = 0x0001,
COMM_FRAME_BLANK = 0x0002,
COMM_FRAME_SCENE_CHANGE = 0x0004,
COMM_FRAME_LOGO_PRESENT = 0x0008,
COMM_FRAME_ASPECT_CHANGE = 0x0010,
COMM_FRAME_RATING_SYMBOL = 0x0020
};

class FrameInfoEntry
{
public:
Expand Down Expand Up @@ -82,9 +91,6 @@ class ClassicCommDetector : public CommDetectorBase
}
FrameBlock;

void Init();
void SetVideoParams(float aspect);
void ProcessFrame(VideoFrame *frame, long long frame_number);
void ClearAllMaps(void);
void GetBlankCommMap(comm_map_t &comms);
void GetBlankCommBreakMap(comm_map_t &comms);
Expand All @@ -106,17 +112,10 @@ class ClassicCommDetector : public CommDetectorBase
void GetLogoCommBreakMap(comm_map_t &map);

enum SkipTypes commDetectMethod;
bool showProgress;
bool fullSpeed;
NuppelVideoPlayer *nvp;
QDateTime startedAt, stopsAt;
QDateTime recordingStartedAt, recordingStopsAt;
bool stillRecording;
QMap<long long,int> lastSentCommBreakMap;
bool commBreakMapUpdateRequested;
bool sendCommBreakMapUpdates;

bool aggressiveDetection;
int commDetectBorder;
int commDetectBlankFrameMaxDiff;
int commDetectDarkBrightness;
Expand All @@ -138,15 +137,11 @@ class ClassicCommDetector : public CommDetectorBase
int height;
int horizSpacing;
int vertSpacing;
double fps;
double fpm;
bool blankFramesOnly;
int blankFrameCount;
int currentAspect;

long long framesProcessed;
long long preRoll;
long long postRoll;

int totalMinBrightness;

Expand All @@ -161,7 +156,6 @@ class ClassicCommDetector : public CommDetectorBase

unsigned char *framePtr;

QMap<long long, FrameInfoEntry> frameInfo;
comm_map_t blankFrameMap;
comm_map_t blankCommMap;
comm_map_t blankCommBreakMap;
Expand All @@ -180,6 +174,25 @@ class ClassicCommDetector : public CommDetectorBase

SceneChangeDetectorBase* sceneChangeDetector;

protected:
NuppelVideoPlayer *nvp;
QDateTime startedAt, stopsAt;
QDateTime recordingStartedAt, recordingStopsAt;
bool aggressiveDetection;
bool stillRecording;
bool fullSpeed;
bool showProgress;
double fps;
long long framesProcessed;
long long preRoll;
long long postRoll;


void Init();
void SetVideoParams(float aspect);
void ProcessFrame(VideoFrame *frame, long long frame_number);
QMap<long long, FrameInfoEntry> frameInfo;

public slots:
void sceneChangeDetectorHasNewInformation(unsigned int framenum, bool isSceneChange,float debugValue);
};
Expand Down
8 changes: 8 additions & 0 deletions mythtv/programs/mythcommflag/CommDetectorFactory.cpp
@@ -1,6 +1,7 @@
#include "CommDetectorFactory.h"
#include "ClassicCommDetector.h"
#include "CommDetector2.h"
#include "PrePostRollFlagger.h"

class NuppelVideoPlayer;
class RemoteEncoder;
Expand All @@ -17,6 +18,13 @@ CommDetectorFactory::makeCommDetector(
const QDateTime& recordingStopsAt,
bool useDB)
{
if(commDetectMethod & COMM_DETECT_PREPOSTROLL)
{
return new PrePostRollFlagger(commDetectMethod, showProgress, fullSpeed,
nvp, startedAt, stopsAt,
recordingStartedAt, recordingStopsAt);
}

if ((commDetectMethod & COMM_DETECT_2))
{
return new CommDetector2(
Expand Down

0 comments on commit 9f5ee51

Please sign in to comment.