Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 49bbb2d7 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

LIB: Revert commit 4cdb4e9d

Revert the commit because the std::function was not appy and a bad_call
was thrown when attempting to delete the unique_ptr...
parent c4e327b9
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!18Implement the VivyDocument specification
...@@ -17,20 +17,28 @@ extern "C" { ...@@ -17,20 +17,28 @@ extern "C" {
namespace Vivy namespace Vivy
{ {
static inline Utils::DeleterFunctionType<double> dataDeleter = static inline constexpr auto codecContexteleter = [](AVCodecContext *ptr) noexcept -> void {
std::bind_front(Utils::freePtrIfNotNull<double>, av_free); if (ptr)
avcodec_free_context(&ptr);
static inline Utils::DeleterFunctionType<AVCodecContext> codecContexteleter = };
std::bind_front(Utils::freePPtrIfNotNull<AVCodecContext>, avcodec_free_context); static constexpr inline auto dataDeleter = [](double *ptr) noexcept -> void {
if (ptr)
static inline Utils::DeleterFunctionType<AVFrame> avFrameDeleter = av_free(ptr);
std::bind_front(Utils::freePPtrIfNotNull<AVFrame>, av_frame_free); };
static constexpr inline auto avFrameDeleter = [](AVFrame *ptr) noexcept -> void {
if (ptr)
av_frame_free(&ptr);
};
static inline Utils::DeleterFunctionType<SwrContext> swrContenxtDeleter = static constexpr inline auto swrContenxtDeleter = [](SwrContext *swr) noexcept -> void {
std::bind_front(Utils::freePPtrIfNotNull<SwrContext>, swr_free); if (swr)
swr_free(&swr);
};
static inline Utils::DeleterFunctionType<AVFormatContext> avFormatContextDeleter = static inline constexpr auto avFormatContextDeleter = [](AVFormatContext *ptr) noexcept -> void {
std::bind_front(Utils::freePtrIfNotNull<AVFormatContext>, avformat_free_context); if (ptr)
avformat_free_context(ptr);
};
using AVFormatContextPtr = std::unique_ptr<AVFormatContext, decltype(avFormatContextDeleter)>; using AVFormatContextPtr = std::unique_ptr<AVFormatContext, decltype(avFormatContextDeleter)>;
using AVCodecContextPtr = std::unique_ptr<AVCodecContext, decltype(codecContexteleter)>; using AVCodecContextPtr = std::unique_ptr<AVCodecContext, decltype(codecContexteleter)>;
......
...@@ -68,9 +68,6 @@ public: ...@@ -68,9 +68,6 @@ public:
private: private:
// Regarding the format // Regarding the format
static inline Utils::DeleterFunctionType<AVFormatContext> avFormatContextDeleter =
std::bind_front(Utils::freePtrIfNotNull<AVFormatContext>, avformat_free_context);
using AVFormatContextPtr = std::unique_ptr<AVFormatContext, decltype(avFormatContextDeleter)>; using AVFormatContextPtr = std::unique_ptr<AVFormatContext, decltype(avFormatContextDeleter)>;
AVFormatContextPtr format{ avformat_alloc_context(), avFormatContextDeleter }; AVFormatContextPtr format{ avformat_alloc_context(), avFormatContextDeleter };
}; };
......
...@@ -162,22 +162,6 @@ QString getBaseName(const QString &) noexcept; ...@@ -162,22 +162,6 @@ QString getBaseName(const QString &) noexcept;
void writeAssertLocation(const char *msg); void writeAssertLocation(const char *msg);
template <typename T> using DeleterFunctionType = const std::function<void(T *)>;
template <typename Type> static inline void
freePtrIfNotNull(DeleterFunctionType<Type> callback, Type *ptr) noexcept
{
if (ptr != nullptr)
callback(ptr);
}
template <typename Type> static inline void
freePPtrIfNotNull(DeleterFunctionType<Type *> callback, Type *ptr) noexcept
{
if (ptr != nullptr)
callback(&ptr);
}
struct OsSpecificAspects final { struct OsSpecificAspects final {
private: private:
OsSpecificAspects() {} OsSpecificAspects() {}
......
...@@ -23,11 +23,6 @@ public: ...@@ -23,11 +23,6 @@ public:
double getFramesPerSecond() const noexcept; double getFramesPerSecond() const noexcept;
QJsonObject getProperties() const noexcept override; QJsonObject getProperties() const noexcept override;
static inline Utils::DeleterFunctionType<AVCodecContext> codecContexteleter =
std::bind_front(Utils::freePPtrIfNotNull<AVCodecContext>, avcodec_free_context);
private:
}; };
// Like an audio context, but for videos. // Like an audio context, but for videos.
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter