Compliance: Add building option to disable x264 and ffmpeg
This commit is contained in:
@@ -8,28 +8,81 @@
|
||||
#include "ToolbarDlg.h"
|
||||
#include "2015RemoteDlg.h"
|
||||
|
||||
#include "common/config.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "libyuv\libyuv.h"
|
||||
}
|
||||
|
||||
#if DISABLE_FFMPEG_FOR_TEST
|
||||
|
||||
#define AV_CODEC_ID_H264 27
|
||||
#define AVERROR(e) (-(e))
|
||||
|
||||
// 伪装不涉及内部成员直接访问的上下文指针
|
||||
typedef void AVCodecContext;
|
||||
typedef void AVCodec;
|
||||
|
||||
// 伪装 AVPacket 结构体,补全被主程序访问的 data 和 size 成员
|
||||
struct AVPacket {
|
||||
unsigned char* data;
|
||||
int size;
|
||||
long long pts;
|
||||
long long dts;
|
||||
int flags;
|
||||
};
|
||||
|
||||
// 伪装 AVFrame 结构体,补全被主程序访问的 data 和 linesize 成员
|
||||
struct AVFrame {
|
||||
unsigned char* data[8];
|
||||
int linesize[8];
|
||||
int width;
|
||||
int height;
|
||||
int format;
|
||||
};
|
||||
|
||||
// 使用 extern "C" __inline 或者是 inline 关键字,直接就地实现函数体
|
||||
extern "C" {
|
||||
__inline void av_frame_unref(AVFrame* frame) {
|
||||
if (frame) {
|
||||
for (int i = 0; i < 8; i++) { frame->data[i] = nullptr; frame->linesize[i] = 0; }
|
||||
}
|
||||
}
|
||||
__inline AVCodec* avcodec_find_decoder(int id) { return nullptr; }
|
||||
__inline void av_init_packet(AVPacket* pkt) { if (pkt) { pkt->data = nullptr; pkt->size = 0; } }
|
||||
__inline AVCodecContext* avcodec_alloc_context3(const AVCodec* codec) { return nullptr; }
|
||||
__inline void avcodec_free_context(AVCodecContext** avctx) { if (avctx) *avctx = nullptr; }
|
||||
__inline int avcodec_open2(AVCodecContext* avctx, const AVCodec* codec, void** options) { return -1; }
|
||||
__inline int avcodec_send_packet(AVCodecContext* avctx, const AVPacket* avpkt) { return -1; }
|
||||
__inline int avcodec_receive_frame(AVCodecContext* avctx, AVFrame* frame) { return -1; }
|
||||
__inline void avcodec_flush_buffers(AVCodecContext* avctx) { /* 空白实现 */ }
|
||||
}
|
||||
|
||||
#else
|
||||
extern "C"
|
||||
{
|
||||
#include "libavcodec\avcodec.h"
|
||||
#include "libavutil\avutil.h"
|
||||
#include "libyuv\libyuv.h"
|
||||
}
|
||||
|
||||
#ifndef _WIN64
|
||||
// https://github.com/Terodee/FFMpeg-windows-static-build/releases
|
||||
#pragma comment(lib,"ffmpeg/libavcodec.lib")
|
||||
#pragma comment(lib,"ffmpeg/libavutil.lib")
|
||||
#pragma comment(lib,"ffmpeg/libswresample.lib")
|
||||
|
||||
#pragma comment(lib,"libyuv/libyuv.lib")
|
||||
#else
|
||||
#pragma comment(lib,"x264/libx264_x64.lib")
|
||||
#pragma comment(lib,"libyuv/libyuv_x64.lib")
|
||||
// https://github.com/ShiftMediaProject/FFmpeg
|
||||
#pragma comment(lib,"ffmpeg/libavcodec_x64.lib")
|
||||
#pragma comment(lib,"ffmpeg/libavutil_x64.lib")
|
||||
#pragma comment(lib,"ffmpeg/libswresample_x64.lib")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef _WIN64
|
||||
#pragma comment(lib,"libyuv/libyuv.lib")
|
||||
#else
|
||||
#pragma comment(lib,"libyuv/libyuv_x64.lib")
|
||||
#endif
|
||||
|
||||
#pragma comment(lib, "Mfplat.lib")
|
||||
#pragma comment(lib, "Mfuuid.lib")
|
||||
|
||||
Reference in New Issue
Block a user