MythTV  master
HistogramAnalyzer.h
Go to the documentation of this file.
1 /*
2  * HistogramAnalyzer
3  *
4  * Detect frame-to-frame changes in histograms.
5  */
6 
7 #ifndef HISTOGRAMANALYZER_H
8 #define HISTOGRAMANALYZER_H
9 
10 #include "FrameAnalyzer.h"
11 
12 class PGMConverter;
13 class BorderDetector;
14 class TemplateFinder;
15 
17 {
18 public:
19  /* Ctor/dtor. */
20  HistogramAnalyzer(std::shared_ptr<PGMConverter> pgmc,
21  std::shared_ptr<BorderDetector> bd,
22  const QString& debugdir);
24 
26  MythPlayer *player, long long nframes);
27  void setLogoState(TemplateFinder *finder);
28  static const long long kUncached = -1;
30  long long frameno);
31  int finished(long long nframes, bool final);
32  int reportTime(void) const;
33 
34  /* Each color 0-255 gets a scaled frequency counter 0-255. */
35  using Histogram = std::array<uint8_t,UCHAR_MAX+1>;
36 
37  const float *getMeans(void) const { return m_mean; }
38  const unsigned char *getMedians(void) const { return m_median; }
39  const float *getStdDevs(void) const { return m_stddev; }
40  const Histogram *getHistograms(void) const { return m_histogram; }
41  const unsigned char *getMonochromatics(void) const { return m_monochromatic; }
42 
43 private:
44  std::shared_ptr<PGMConverter> m_pgmConverter {nullptr};
45  std::shared_ptr<BorderDetector> m_borderDetector {nullptr};
46 
48  const struct AVFrame *m_logo {nullptr};
49  int m_logoWidth {-1};
50  int m_logoHeight {-1};
51  int m_logoRr1 {-1};
52  int m_logoCc1 {-1};
53  int m_logoRr2 {-1};
54  int m_logoCc2 {-1};
55 
56  /* Per-frame info. */
57  float *m_mean {nullptr}; /* mean pixel value */
58  unsigned char *m_median {nullptr}; /* median pixel value */
59  float *m_stddev {nullptr}; /* standard deviation */
60  int *m_fRow {nullptr}; /* position of borders */
61  int *m_fCol {nullptr}; /* position of borders */
62  int *m_fWidth {nullptr}; /* area of borders */
63  int *m_fHeight {nullptr}; /* area of borders */
64  Histogram *m_histogram {nullptr}; /* histogram */
65  unsigned char *m_monochromatic {nullptr}; /* computed boolean */
66  std::array<int,UCHAR_MAX+1> m_histVal {0}; /* temporary buffer */
67  unsigned char *m_buf {nullptr}; /* temporary buffer */
68  long long m_lastFrameNo {-1};
69 
70  /* Debugging */
71  int m_debugLevel {0};
72  QString m_debugdata; /* filename */
73  bool m_debugHistVal {false};
74  bool m_histValDone {false};
75  std::chrono::microseconds m_analyzeTime {0us};
76 };
77 
78 #endif /* !HISTOGRAMANALYZER_H */
79 
80 /* vim: set expandtab tabstop=4 shiftwidth=4: */
HistogramAnalyzer::m_logoRr1
int m_logoRr1
Definition: HistogramAnalyzer.h:51
HistogramAnalyzer::m_logoCc1
int m_logoCc1
Definition: HistogramAnalyzer.h:52
HistogramAnalyzer::m_logoHeight
int m_logoHeight
Definition: HistogramAnalyzer.h:50
HistogramAnalyzer::m_debugHistVal
bool m_debugHistVal
Definition: HistogramAnalyzer.h:73
HistogramAnalyzer::m_histogram
Histogram * m_histogram
Definition: HistogramAnalyzer.h:64
HistogramAnalyzer::finished
int finished(long long nframes, bool final)
Definition: HistogramAnalyzer.cpp:412
HistogramAnalyzer::getHistograms
const Histogram * getHistograms(void) const
Definition: HistogramAnalyzer.h:40
HistogramAnalyzer
Definition: HistogramAnalyzer.h:16
BorderDetector
Definition: BorderDetector.h:19
MythPlayer
Definition: mythplayer.h:83
HistogramAnalyzer::getMonochromatics
const unsigned char * getMonochromatics(void) const
Definition: HistogramAnalyzer.h:41
HistogramAnalyzer::m_pgmConverter
std::shared_ptr< PGMConverter > m_pgmConverter
Definition: HistogramAnalyzer.h:44
HistogramAnalyzer::reportTime
int reportTime(void) const
Definition: HistogramAnalyzer.cpp:430
HistogramAnalyzer::analyzeFrame
enum FrameAnalyzer::analyzeFrameResult analyzeFrame(const MythVideoFrame *frame, long long frameno)
Definition: HistogramAnalyzer.cpp:266
HistogramAnalyzer::m_logoRr2
int m_logoRr2
Definition: HistogramAnalyzer.h:53
HistogramAnalyzer::getMeans
const float * getMeans(void) const
Definition: HistogramAnalyzer.h:37
AVFrame
struct AVFrame AVFrame
Definition: BorderDetector.h:15
TemplateFinder
Definition: TemplateFinder.h:30
HistogramAnalyzer::m_fCol
int * m_fCol
Definition: HistogramAnalyzer.h:61
HistogramAnalyzer::m_logoFinder
TemplateFinder * m_logoFinder
Definition: HistogramAnalyzer.h:47
HistogramAnalyzer::m_fRow
int * m_fRow
Definition: HistogramAnalyzer.h:60
HistogramAnalyzer::m_histVal
std::array< int, UCHAR_MAX+1 > m_histVal
Definition: HistogramAnalyzer.h:66
FrameAnalyzer::analyzeFrameResult
analyzeFrameResult
Definition: FrameAnalyzer.h:36
FrameAnalyzer.h
HistogramAnalyzer::m_logo
const struct AVFrame * m_logo
Definition: HistogramAnalyzer.h:48
HistogramAnalyzer::m_logoWidth
int m_logoWidth
Definition: HistogramAnalyzer.h:49
HistogramAnalyzer::m_fWidth
int * m_fWidth
Definition: HistogramAnalyzer.h:62
HistogramAnalyzer::setLogoState
void setLogoState(TemplateFinder *finder)
Definition: HistogramAnalyzer.cpp:258
HistogramAnalyzer::m_debugLevel
int m_debugLevel
Definition: HistogramAnalyzer.h:71
HistogramAnalyzer::m_monochromatic
unsigned char * m_monochromatic
Definition: HistogramAnalyzer.h:65
HistogramAnalyzer::m_fHeight
int * m_fHeight
Definition: HistogramAnalyzer.h:63
HistogramAnalyzer::m_borderDetector
std::shared_ptr< BorderDetector > m_borderDetector
Definition: HistogramAnalyzer.h:45
HistogramAnalyzer::m_histValDone
bool m_histValDone
Definition: HistogramAnalyzer.h:74
HistogramAnalyzer::Histogram
std::array< uint8_t, UCHAR_MAX+1 > Histogram
Definition: HistogramAnalyzer.h:35
PGMConverter
Definition: PGMConverter.h:30
HistogramAnalyzer::m_analyzeTime
std::chrono::microseconds m_analyzeTime
Definition: HistogramAnalyzer.h:75
HistogramAnalyzer::m_stddev
float * m_stddev
Definition: HistogramAnalyzer.h:59
HistogramAnalyzer::m_debugdata
QString m_debugdata
Definition: HistogramAnalyzer.h:72
HistogramAnalyzer::m_logoCc2
int m_logoCc2
Definition: HistogramAnalyzer.h:54
HistogramAnalyzer::m_median
unsigned char * m_median
Definition: HistogramAnalyzer.h:58
HistogramAnalyzer::getMedians
const unsigned char * getMedians(void) const
Definition: HistogramAnalyzer.h:38
HistogramAnalyzer::m_mean
float * m_mean
Definition: HistogramAnalyzer.h:57
HistogramAnalyzer::m_lastFrameNo
long long m_lastFrameNo
Definition: HistogramAnalyzer.h:68
HistogramAnalyzer::m_buf
unsigned char * m_buf
Definition: HistogramAnalyzer.h:67
MythVideoFrame
Definition: mythframe.h:88
HistogramAnalyzer::~HistogramAnalyzer
~HistogramAnalyzer()
Definition: HistogramAnalyzer.cpp:167
HistogramAnalyzer::getStdDevs
const float * getStdDevs(void) const
Definition: HistogramAnalyzer.h:39
HistogramAnalyzer::MythPlayerInited
enum FrameAnalyzer::analyzeFrameResult MythPlayerInited(MythPlayer *player, long long nframes)
Definition: HistogramAnalyzer.cpp:182
HistogramAnalyzer::HistogramAnalyzer
HistogramAnalyzer(std::shared_ptr< PGMConverter > pgmc, std::shared_ptr< BorderDetector > bd, const QString &debugdir)
Definition: HistogramAnalyzer.cpp:141
HistogramAnalyzer::kUncached
static const long long kUncached
Definition: HistogramAnalyzer.h:28