You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PayloadAPP/Src/VideoGL/ffmpeginclude.h

58 lines
1.4 KiB
C

#ifndef FFMPEGINCLUDE_H
#define FFMPEGINCLUDE_H
extern "C" {
#include <libavformat/avformat.h>
#include <libavutil/channel_layout.h>
#include <libavutil/common.h>
#include <libavutil/frame.h>
#include <libavutil/imgutils.h>
#include <libavutil/mem.h>
#include <libavutil/opt.h>
#include <libavutil/parseutils.h>
#include <libavutil/samplefmt.h>
#include <libavutil/time.h>
#include <libswscale/swscale.h>
#include "libavcodec/avcodec.h"
}
#include <QCoreApplication>
#include <QDebug>
#include <QElapsedTimer>
#include <QEventLoop>
#include "global.h"
#define PRINT_LOG 1
#define ERROR_LEN 1024 // 异常信息数组长度
/**
* @brief ffmpeg
* @param err
*/
inline void showError(int err) {
char *m_error = new char[ERROR_LEN]; // 保存异常信息
#if PRINT_LOG
memset(m_error, 0, ERROR_LEN); // 将数组置零
av_strerror(err, m_error, ERROR_LEN);
qWarning() << "DecodeVideo Error" << m_error;
#else
Q_UNUSED(err)
#endif
delete[] m_error; // 释放内存
}
// void highPrecisionSleep(qint64 microseconds) {
// QElapsedTimer timer;
// timer.start();
// QEventLoop loop;
// while (timer.nsecsElapsed() < microseconds * 1000) {
// QCoreApplication::processEvents(QEventLoop::AllEvents,
// 1); // 处理事件并短暂阻塞
// }
// }
#endif // FFMPEGINCLUDE_H