MythTV  master
mythavutil.h
Go to the documentation of this file.
1 #ifndef MYTHAVUTIL_H
2 #define MYTHAVUTIL_H
3 
4 // Qt
5 #include <QMap>
6 #include <QMutex>
7 #include <QVector>
8 
9 // MythTV
10 #include "mythframe.h"
11 
12 // FFmpeg
13 extern "C" {
14 #include "libavcodec/avcodec.h"
15 }
16 
17 struct SwsContext;
18 struct AVStream;
19 struct AVCodecContext;
20 
22 {
23  public:
24  MythCodecMap() = default;
25  ~MythCodecMap();
26  AVCodecContext* GetCodecContext(const AVStream* Stream,
27  const AVCodec* Codec = nullptr,
28  bool NullCodec = false);
29  AVCodecContext* FindCodecContext(const AVStream* Stream);
30  void FreeCodecContext(const AVStream* Stream);
31  void FreeAllContexts();
32 
33  private:
34  QMap<const AVStream*, AVCodecContext*> m_streamMap;
35  QMutex m_mapLock { QMutex::Recursive };
36 };
37 
39 {
40  public:
41  MythAVCopy() = default;
42  ~MythAVCopy();
43  int Copy(AVFrame* To, const MythVideoFrame* From, unsigned char* Buffer,
44  AVPixelFormat Fmt = AV_PIX_FMT_YUV420P);
45  int Copy(AVFrame* To, AVPixelFormat ToFmt, const AVFrame* From, AVPixelFormat FromFmt,
46  int Width, int Height);
47 
48  private:
49  Q_DISABLE_COPY(MythAVCopy)
50  int SizeData(int Width, int Height, AVPixelFormat Fmt);
51 
52  AVPixelFormat m_format { AV_PIX_FMT_NONE };
53  SwsContext* m_swsctx { nullptr };
54  int m_width { 0 };
55  int m_height { 0 };
56  int m_size { 0 };
57 };
58 
60 {
61  public:
62  static void DeinterlaceAVFrame(AVFrame* Frame);
63  static int FillAVFrame(AVFrame* Frame, const MythVideoFrame* From, AVPixelFormat Fmt = AV_PIX_FMT_NONE);
64  static AVPixelFormat FrameTypeToPixelFormat(VideoFrameType Type);
65  static VideoFrameType PixelFormatToFrameType(AVPixelFormat Fmt);
66 };
67 
69 public:
70  // These are for All types
71  char m_codecType {' '}; // V=video, A=audio, S=subtitle
72  QString m_codecName;
73  int64_t m_duration {0};
74  // These are for Video only
75  int m_width {0};
76  int m_height {0};
77  float m_SampleAspectRatio {0.0};
78  // AV_FIELD_TT, //< Top coded_first, top displayed first
79  // AV_FIELD_BB, //< Bottom coded first, bottom displayed first
80  // AV_FIELD_TB, //< Top coded first, bottom displayed first
81  // AV_FIELD_BT, //< Bottom coded first, top displayed first
82  QString m_fieldOrder {"UN"}; // UNknown, PRogressive, TT, BB, TB, BT
83  float m_frameRate {0.0};
84  float m_avgFrameRate {0.0};
85  // This is for audio only
86  int m_channels {0};
87 };
88 
89 
90 /*
91 * Class to get stream info, used by service Video/GetStreamInfo
92 */
94 public:
95  explicit MythStreamInfoList(const QString& filename);
96  int m_errorCode {0};
97  QString m_errorMsg;
98  QVector<MythStreamInfo> m_streamInfoList;
99 };
100 
101 #endif
MythStreamInfoList::m_errorMsg
QString m_errorMsg
Definition: mythavutil.h:97
MythStreamInfo::m_codecName
QString m_codecName
Definition: mythavutil.h:72
Frame
Definition: zmdefines.h:93
MythStreamInfo
Definition: mythavutil.h:68
MythStreamInfoList
Definition: mythavutil.h:93
mythframe.h
AVFrame
struct AVFrame AVFrame
Definition: BorderDetector.h:15
filename
QString filename
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:637
MythAVUtil
Definition: mythavutil.h:59
MythCodecMap
Definition: mythavutil.h:21
MTV_PUBLIC
#define MTV_PUBLIC
Definition: mythtvexp.h:15
Buffer
Definition: MythExternControl.h:36
MythAVCopy
Definition: mythavutil.h:38
VideoFrameType
VideoFrameType
Definition: mythframe.h:18
MythCodecMap::m_streamMap
QMap< const AVStream *, AVCodecContext * > m_streamMap
Definition: mythavutil.h:34
MythVideoFrame
Definition: mythframe.h:85
MythStreamInfoList::m_streamInfoList
QVector< MythStreamInfo > m_streamInfoList
Definition: mythavutil.h:98