2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
11 #include "ServiceBroker.h"
12 #include "utils/CPUInfo.h"
13 #include "utils/StringUtils.h"
16 #include <libavcodec/avcodec.h>
17 #include <libavformat/avformat.h>
18 #include <libavutil/avutil.h>
19 #include <libavutil/log.h>
20 #include <libavutil/ffversion.h>
21 #include <libavfilter/avfilter.h>
22 #include <libpostproc/postprocess.h>
27 namespace FFMPEG_HELP_TOOLS
30 struct FFMpegException
: public std::exception
33 template<typename
... Args
>
34 FFMpegException(const std::string
& fmt
, Args
&&... args
)
35 : s(StringUtils::Format(fmt
, std::forward
<Args
>(args
)...))
38 const char* what() const noexcept override
{ return s
.c_str(); }
41 std::string
FFMpegErrorToString(int err
);
43 } // namespace FFMPEG_HELP_TOOLS
45 inline int PPCPUFlags()
47 unsigned int cpuFeatures
= CServiceBroker::GetCPUInfo()->GetCPUFeatures();
50 if (cpuFeatures
& CPU_FEATURE_MMX
)
51 flags
|= PP_CPU_CAPS_MMX
;
52 if (cpuFeatures
& CPU_FEATURE_MMX2
)
53 flags
|= PP_CPU_CAPS_MMX2
;
54 if (cpuFeatures
& CPU_FEATURE_3DNOW
)
55 flags
|= PP_CPU_CAPS_3DNOW
;
56 if (cpuFeatures
& CPU_FEATURE_ALTIVEC
)
57 flags
|= PP_CPU_CAPS_ALTIVEC
;
62 // callback used for logging
63 void ff_avutil_log(void* ptr
, int level
, const char* format
, va_list va
);
64 void ff_flush_avutil_log_buffers(void);
69 static void SetLogLevel(int level
);
70 static int GetLogLevel();
71 static void ClearLogLevel();
78 FFmpegExtraData() = default;
79 explicit FFmpegExtraData(size_t size
);
80 FFmpegExtraData(const uint8_t* data
, size_t size
);
81 FFmpegExtraData(const FFmpegExtraData
& other
);
82 FFmpegExtraData(FFmpegExtraData
&& other
) noexcept
;
86 FFmpegExtraData
& operator=(const FFmpegExtraData
& other
);
87 FFmpegExtraData
& operator=(FFmpegExtraData
&& other
) noexcept
;
89 bool operator==(const FFmpegExtraData
& other
) const;
90 bool operator!=(const FFmpegExtraData
& other
) const;
92 operator bool() const { return m_data
!= nullptr && m_size
!= 0; }
93 uint8_t* GetData() { return m_data
; }
94 const uint8_t* GetData() const { return m_data
; }
95 size_t GetSize() const { return m_size
; }
97 * \brief Take ownership over the extra data buffer
99 * It's in the responsibility of the caller to free the buffer with av_free. After the call
100 * FFmpegExtraData is empty.
102 * \return The extra data buffer or nullptr if FFmpegExtraData is empty.
107 uint8_t* m_data
{nullptr};
111 FFmpegExtraData
GetPacketExtradata(const AVPacket
* pkt
, const AVCodecParameters
* codecPar
);