Fix: Make the x264 opt-out real, and unchain libyuv from it
DISABLE_X264_FOR_TEST never actually removed the x264 dependency. Two separate reasons: 1. X264Encoder.h included <x264/x264.h> unconditionally and only pulled in common/config.h afterwards, so the macro was not even visible at the point where it mattered. The class also carried x264_t / x264_picture_t / x264_param_t members, so the header was required to compile regardless of the switch. Moving the config.h include to the top and splitting the class declaration in two fixes it: with the switch on, the class is a stub with no x264 types at all, and open() returns false so EncoderFactory falls through. The open(x264_param_t*) overload is dropped in that branch; it had no callers outside X264Encoder.cpp. 2. libyuv was collateral damage. Its only #pragma comment(lib) lived inside the #else branch of the x264 switch, but CFFmpegAV1Encoder.cpp and CFFmpegH264Encoder.cpp both call libyuv::RGB24ToI420 / ARGBToNV12 / I420ToNV12 without carrying a pragma of their own. Turning x264 off therefore dropped libyuv too and the link failed with LNK2001 on those three symbols. libyuv is BSD-3 and unrelated to x264: the pragma is now unconditional in X264Encoder.cpp, and CFFmpegH264Encoder.cpp declares it alongside its ffmpeg libs so the encoder pair is self-sufficient. Verified with Release x64 builds of both ServerDll and ghost: switches 0/0, compress/ intact -> builds switch x264=1, compress/x264 deleted -> builds (was LNK2001 before) switches 1/1, both dirs deleted -> builds So a compliant build needs neither the x264 library nor its headers. Note for anyone flipping these switches: do a full rebuild, not an incremental one. config.h reaches X264Encoder.cpp indirectly through X264Encoder.h, which the .tlog dependency tracking does not record, so an incremental build happily links a stale object against a freshly compiled one and reports bogus LNK2001 errors.
This commit is contained in:
1 parent
1d875ddbd1
commit
82f59b2469
3 files changed
+61
-6
No files matched your search
@@ -21,6 +21,10 @@ extern "C" {
|
||||
#pragma comment(lib,"ffmpeg/libavcodec_x64.lib")
|
||||
#pragma comment(lib,"ffmpeg/libavutil_x64.lib")
|
||||
#pragma comment(lib,"ffmpeg/libswresample_x64.lib")
|
||||
// libyuv 不属于 ffmpeg:硬编前要把 BGRA/RGB24 转成 I420/NV12。以前这条链接声明
|
||||
// 只写在 X264Encoder.cpp 里,一旦 DISABLE_X264_FOR_TEST=1 关掉 x264 就跟着消失,
|
||||
// 硬编 obj 会报 LNK2001。CFFmpegAV1Encoder.cpp 复用本文件的 pragma,这里补上即可。
|
||||
#pragma comment(lib,"libyuv/libyuv_x64.lib")
|
||||
// dav1d (AV1 软解,C 项目) —— 不分 Debug/Release。
|
||||
// build 时启用了 --enable-libdav1d,libavcodec 内部 av1 decoder 引用了 dav1d 符号。
|
||||
#pragma comment(lib,"ffmpeg/dav1d_x64.lib")
|
||||
|
||||
Reference in new issue
Block a user