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 typedef struct AVFrame AVFrame;
13 class PGMConverter;
14 class BorderDetector;
15 class TemplateFinder;
16 
18 {
19 public:
20  /* Ctor/dtor. */
22  const QString& debugdir);
24 
26  MythPlayer *player, long long nframes);
27  void setLogoState(TemplateFinder *finder);
28  static const long long UNCACHED = -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  typedef unsigned char Histogram[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:
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  int m_histval[UCHAR_MAX + 1] {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_debug_histval {false};
74  bool m_histval_done {false};
75  struct timeval m_analyze_time {0,0};
76 };
77 
78 #endif /* !__HISTOGRAMANALYZER_H__ */
79 
80 /* vim: set expandtab tabstop=4 shiftwidth=4: */
unsigned char * m_buf
const Histogram * getHistograms(void) const
Histogram * m_histogram
const unsigned char * getMonochromatics(void) const
int finished(long long nframes, bool final)
struct AVFrame AVFrame
const float * getMeans(void) const
PGMConverter * m_pgmConverter
int reportTime(void) const
TemplateFinder * m_logoFinder
int m_histval[UCHAR_MAX+1]
HistogramAnalyzer(PGMConverter *pgmc, BorderDetector *bd, const QString &debugdir)
const struct AVFrame * m_logo
static const long long UNCACHED
void setLogoState(TemplateFinder *finder)
unsigned char * m_monochromatic
enum FrameAnalyzer::analyzeFrameResult analyzeFrame(const VideoFrame *frame, long long frameno)
BorderDetector * m_borderDetector
const unsigned char * getMedians(void) const
enum FrameAnalyzer::analyzeFrameResult MythPlayerInited(MythPlayer *player, long long nframes)
const float * getStdDevs(void) const
unsigned char * m_median