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