MythTV master
ClassicCommDetector.h
Go to the documentation of this file.
1#ifndef CLASSIC_COMMDETECTOR_H
2#define CLASSIC_COMMDETECTOR_H
3
4// C++ headers
5#include <cstdint>
6
7// Qt headers
8#include <QObject>
9#include <QMap>
10#include <QDateTime>
11#include <QElapsedTimer>
12
13// MythTV headers
15#include "libmythtv/mythframe.h"
16
17// Commercial Flagging headers
18#include "CommDetectorBase.h"
19
23
24enum frameMaskValues : std::uint8_t {
31};
32
34{
35 public:
40 int aspect;
41 int format;
43 static QString GetHeader(void);
44 QString toString(uint64_t frame, bool verbose) const;
45};
46
48{
49 Q_OBJECT
50
51 public:
52 ClassicCommDetector(SkipType commDetectMethod, bool showProgress,
53 bool fullSpeed, MythCommFlagPlayer* player,
54 QDateTime startedAt_in,
55 QDateTime stopsAt_in,
56 QDateTime recordingStartedAt_in,
57 QDateTime recordingStopsAt_in);
58 virtual void deleteLater(void);
59
60 bool go() override; // CommDetectorBase
61 void GetCommercialBreakList(frm_dir_map_t &marks) override; // CommDetectorBase
62 void recordingFinished(long long totalFileSize) override; // CommDetectorBase
63 void requestCommBreakMapUpdate(void) override; // CommDetectorBase
64
65 void PrintFullMap(
66 std::ostream &out, const frm_dir_map_t *comm_breaks,
67 bool verbose) const override; // CommDetectorBase
68
70
71 friend class ClassicLogoDetector;
72
73 protected:
74 ~ClassicCommDetector() override = default;
75
76 private:
78 {
79 long start;
80 long end;
81 long frames;
82 double length;
87 double scRate;
90 int score;
91 };
92
93 template <typename T>
94 QString FormatMsg(T first, const FrameBlock *fbp)
95 {
96 QString msgformat("%1 %2:%3 %4 %5 %6 %7 %8 %9 %10 %11 %12 %13 %14 %15");
97 return msgformat.arg(first, 5)
98 .arg((int)(fbp->start / m_fps) / 60, 3)
99 .arg((int)((fbp->start / m_fps )) % 60, 2, 10, QChar('0'))
100 .arg(fbp->start, 6)
101 .arg(fbp->end, 6)
102 .arg(fbp->frames, 6)
103 .arg(fbp->length, 7, 'f', 2)
104 .arg(fbp->bfCount, 3)
105 .arg(fbp->logoCount, 6)
106 .arg(fbp->ratingCount, 6)
107 .arg(fbp->scCount, 6)
108 .arg(fbp->scRate, 5, 'f', 2)
109 .arg(fbp->formatMatch, 6)
110 .arg(fbp->aspectMatch, 6)
111 .arg(fbp->score, 5);
112 }
113
114 void ClearAllMaps(void);
115 void GetBlankCommMap(frm_dir_map_t &comms);
117 void GetSceneChangeMap(frm_dir_map_t &scenes,
118 int64_t start_frame);
120 const frm_dir_map_t &a, const frm_dir_map_t &b) const;
121 static void UpdateFrameBlock(FrameBlock *fbp, const FrameInfoEntry& finfo,
122 int format, int aspect);
123 void BuildAllMethodsCommList(void);
124 void BuildBlankFrameCommList(void);
125 void BuildSceneChangeCommList(void);
126 void BuildLogoCommList();
127 void MergeBlankCommList(void);
128 bool FrameIsInBreakMap(uint64_t f, const frm_dir_map_t &breakMap) const;
129 void DumpMap(frm_dir_map_t &map) const;
130 static void CondenseMarkMap(show_map_t &map, int spacing, int length);
131 static void ConvertShowMapToCommMap(
132 frm_dir_map_t &out, const show_map_t &in);
133 void CleanupFrameInfo(void);
135
140
152
153 bool m_verboseDebugging {false};
154
155 long long m_lastFrameNumber {0};
156 long long m_curFrameNumber {0};
157
158 int m_width {0};
159 int m_height {0};
162 bool m_blankFramesOnly {false};
165
166
168
171
179
180 bool m_frameIsBlank {false};
182
184
186
187protected:
189 QDateTime m_startedAt;
190 QDateTime m_stopsAt;
194 bool m_stillRecording {false};
195 bool m_fullSpeed {false};
196 bool m_showProgress {false};
197 double m_fps {0.0};
198 uint64_t m_framesProcessed {0};
199 long long m_preRoll {0};
200 long long m_postRoll {0};
201
202
203 void Init();
204 void SetVideoParams(float aspect);
205 void ProcessFrame(MythVideoFrame *frame, long long frame_number);
206 QMap<long long, FrameInfoEntry> m_frameInfo;
207
208public slots:
209 void sceneChangeDetectorHasNewInformation(unsigned int framenum, bool isSceneChange,float debugValue);
210};
211
212#endif // CLASSIC_COMMDETECTOR_H
213
214/* vim: set expandtab tabstop=4 shiftwidth=4: */
frameMaskValues
@ COMM_FRAME_RATING_SYMBOL
@ COMM_FRAME_SKIPPED
@ COMM_FRAME_LOGO_PRESENT
@ COMM_FRAME_BLANK
@ COMM_FRAME_ASPECT_CHANGE
@ COMM_FRAME_SCENE_CHANGE
QMap< uint64_t, CommMapValue > show_map_t
frm_dir_map_t m_blankFrameMap
static void ConvertShowMapToCommMap(frm_dir_map_t &out, const show_map_t &in)
ClassicCommDetector(SkipType commDetectMethod, bool showProgress, bool fullSpeed, MythCommFlagPlayer *player, QDateTime startedAt_in, QDateTime stopsAt_in, QDateTime recordingStartedAt_in, QDateTime recordingStopsAt_in)
QMap< long long, FrameInfoEntry > m_frameInfo
void GetCommercialBreakList(frm_dir_map_t &marks) override
frm_dir_map_t m_commBreakMap
static void CondenseMarkMap(show_map_t &map, int spacing, int length)
frm_dir_map_t m_sceneCommBreakMap
void GetLogoCommBreakMap(show_map_t &map)
void GetBlankCommMap(frm_dir_map_t &comms)
void sceneChangeDetectorHasNewInformation(unsigned int framenum, bool isSceneChange, float debugValue)
void ProcessFrame(MythVideoFrame *frame, long long frame_number)
void PrintFullMap(std::ostream &out, const frm_dir_map_t *comm_breaks, bool verbose) const override
virtual void deleteLater(void)
frm_dir_map_t m_blankCommMap
frm_dir_map_t m_blankCommBreakMap
void requestCommBreakMapUpdate(void) override
frm_dir_map_t m_logoCommBreakMap
void SetVideoParams(float aspect)
void GetBlankCommBreakMap(frm_dir_map_t &comms)
LogoDetectorBase * m_logoDetector
frm_dir_map_t m_lastSentCommBreakMap
void DumpMap(frm_dir_map_t &map) const
QString FormatMsg(T first, const FrameBlock *fbp)
void recordingFinished(long long totalFileSize) override
void GetSceneChangeMap(frm_dir_map_t &scenes, int64_t start_frame)
~ClassicCommDetector() override=default
static void UpdateFrameBlock(FrameBlock *fbp, const FrameInfoEntry &finfo, int format, int aspect)
MythCommFlagPlayer * m_player
SceneChangeDetectorBase * m_sceneChangeDetector
frm_dir_map_t Combine2Maps(const frm_dir_map_t &a, const frm_dir_map_t &b) const
bool FrameIsInBreakMap(uint64_t f, const frm_dir_map_t &breakMap) const
Abstract base class for all CommDetectors.
static QString GetHeader(void)
QString toString(uint64_t frame, bool verbose) const
SkipType
This is used as a bitmask.
Definition: programtypes.h:127
QMap< uint64_t, MarkTypes > frm_dir_map_t
Frame # -> Mark map.
Definition: programtypes.h:117