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