MythTV  master
SceneChangeDetector.h
Go to the documentation of this file.
1 /*
2  * SceneChangeDetector
3  *
4  * Detect scene changes based on histogram analysis.
5  */
6 
7 #ifndef SCENECHANGEDETECTOR_H
8 #define SCENECHANGEDETECTOR_H
9 
10 #include <QString>
11 
12 #include "FrameAnalyzer.h"
13 
14 using AVFrame = struct AVFrame;
15 class HistogramAnalyzer;
16 
18 {
19 public:
20  SceneChangeDetector(std::shared_ptr<HistogramAnalyzer> ha, const QString& debugdir);
21  virtual void deleteLater(void);
22 
23  /* FrameAnalyzer interface. */
24  const char *name(void) const override // FrameAnalyzer
25  { return "SceneChangeDetector"; }
27  long long nframes) override; // FrameAnalyzer
28  enum analyzeFrameResult analyzeFrame(const VideoFrame *frame,
29  long long frameno, long long *pNextFrame) override; // FrameAnalyzer
30  int finished(long long nframes, bool final) override; // FrameAnalyzer
31  int reportTime(void) const override; // FrameAnalyzer
32  FrameMap GetMap(unsigned int /*index*/) const override // FrameAnalyzer
33  { return m_changeMap; }
34 
35  /* SceneChangeDetector interface. */
36  const FrameAnalyzer::FrameMap *getChanges(void) const { return &m_changeMap; }
37 
39  unsigned char color;
40  unsigned char frequency;
41  };
42  using SceneChangeData = scenechange_data[UCHAR_MAX + 1];
43 
44  protected:
45  ~SceneChangeDetector(void) override = default;
46 
47  private:
48  std::shared_ptr<HistogramAnalyzer> m_histogramAnalyzer {nullptr};
49  float m_fps {0.0F};
50 
51  /* per-frame info */
53  unsigned short *m_scDiff {nullptr};
54 
56 
57  /* Debugging */
58  int m_debugLevel {0};
59  QString m_debugData; /* filename */
60  bool m_debugSceneChange {false};
61  bool m_sceneChangeDone {false};
62 };
63 
64 #endif /* !SCENECHANGEDETECTOR_H */
65 
66 /* vim: set expandtab tabstop=4 shiftwidth=4: */
SceneChangeDetector::m_scDiff
unsigned short * m_scDiff
Definition: SceneChangeDetector.h:53
SceneChangeDetector::m_histogramAnalyzer
std::shared_ptr< HistogramAnalyzer > m_histogramAnalyzer
Definition: SceneChangeDetector.h:48
SceneChangeDetector
Definition: SceneChangeDetector.h:18
SceneChangeDetector::scenechange_data::frequency
unsigned char frequency
Definition: SceneChangeDetector.h:40
FrameAnalyzer::FrameMap
QMap< long long, long long > FrameMap
Definition: FrameAnalyzer.h:45
HistogramAnalyzer
Definition: HistogramAnalyzer.h:17
SceneChangeDetector::deleteLater
virtual void deleteLater(void)
Definition: SceneChangeDetector.cpp:117
MythPlayer
Definition: mythplayer.h:165
VideoFrame
Definition: mythframe.h:138
SceneChangeDetector::scenechange_data
Definition: SceneChangeDetector.h:38
SceneChangeDetector::analyzeFrame
enum analyzeFrameResult analyzeFrame(const VideoFrame *frame, long long frameno, long long *pNextFrame) override
Definition: SceneChangeDetector.cpp:149
SceneChangeDetector::getChanges
const FrameAnalyzer::FrameMap * getChanges(void) const
Definition: SceneChangeDetector.h:36
AVFrame
struct AVFrame AVFrame
Definition: BorderDetector.h:15
FrameAnalyzer
Definition: FrameAnalyzer.h:29
SceneChangeDetector::finished
int finished(long long nframes, bool final) override
Definition: SceneChangeDetector.cpp:165
SceneChangeDetector::reportTime
int reportTime(void) const override
Definition: SceneChangeDetector.cpp:210
FrameAnalyzer::analyzeFrameResult
analyzeFrameResult
Definition: FrameAnalyzer.h:36
FrameAnalyzer.h
SceneChangeDetector::MythPlayerInited
enum analyzeFrameResult MythPlayerInited(MythPlayer *player, long long nframes) override
Definition: SceneChangeDetector.cpp:124
SceneChangeDetector::m_debugData
QString m_debugData
Definition: SceneChangeDetector.h:59
SceneChangeDetector::m_scData
SceneChangeData * m_scData
Definition: SceneChangeDetector.h:52
SceneChangeDetector::~SceneChangeDetector
~SceneChangeDetector(void) override=default
SceneChangeDetector::m_sceneChangeDone
bool m_sceneChangeDone
Definition: SceneChangeDetector.h:61
SceneChangeDetector::SceneChangeDetector
SceneChangeDetector(std::shared_ptr< HistogramAnalyzer > ha, const QString &debugdir)
Definition: SceneChangeDetector.cpp:95
SceneChangeDetector::GetMap
FrameMap GetMap(unsigned int) const override
Definition: SceneChangeDetector.h:32
SceneChangeDetector::m_fps
float m_fps
Definition: SceneChangeDetector.h:49
SceneChangeDetector::SceneChangeData
scenechange_data[UCHAR_MAX+1] SceneChangeData
Definition: SceneChangeDetector.h:42
SceneChangeDetector::m_changeMap
FrameAnalyzer::FrameMap m_changeMap
Definition: SceneChangeDetector.h:55
SceneChangeDetector::scenechange_data::color
unsigned char color
Definition: SceneChangeDetector.h:39
SceneChangeDetector::name
const char * name(void) const override
Definition: SceneChangeDetector.h:24
SceneChangeDetector::m_debugLevel
int m_debugLevel
Definition: SceneChangeDetector.h:58
SceneChangeDetector::m_debugSceneChange
bool m_debugSceneChange
Definition: SceneChangeDetector.h:60