From eb95f00991c73a0228a2c7e347b034c63d05e6ab Mon Sep 17 00:00:00 2001 From: akallabeth Date: Thu, 28 Apr 2022 12:58:22 +0200 Subject: [PATCH] Move H264 subsystem variable to header --- include/freerdp/codec/h264.h | 2 +- libfreerdp/codec/h264.c | 11 ++---- libfreerdp/codec/h264.h | 57 +++++++++++++++++++++--------- libfreerdp/codec/h264_ffmpeg.c | 5 +-- libfreerdp/codec/h264_mediacodec.c | 5 +-- libfreerdp/codec/h264_mf.c | 4 +-- libfreerdp/codec/h264_openh264.c | 4 +-- 7 files changed, 54 insertions(+), 34 deletions(-) diff --git a/include/freerdp/codec/h264.h b/include/freerdp/codec/h264.h index b2dbc97f9..6dece7a9e 100644 --- a/include/freerdp/codec/h264.h +++ b/include/freerdp/codec/h264.h @@ -59,7 +59,7 @@ typedef struct UINT32 numSystemData; void* pSystemData; - H264_CONTEXT_SUBSYSTEM* subsystem; + const H264_CONTEXT_SUBSYSTEM* subsystem; YUV_CONTEXT* yuv; BOOL encodingBuffer; diff --git a/libfreerdp/codec/h264.c b/libfreerdp/codec/h264.c index 044350da8..257612c84 100644 --- a/libfreerdp/codec/h264.c +++ b/libfreerdp/codec/h264.c @@ -580,11 +580,7 @@ INT32 avc444_decompress(H264_CONTEXT* h264, BYTE op, const RECTANGLE_16* regionR #define MAX_SUBSYSTEMS 10 static INIT_ONCE subsystems_once = INIT_ONCE_STATIC_INIT; -static H264_CONTEXT_SUBSYSTEM* subSystems[MAX_SUBSYSTEMS] = { 0 }; - -#if defined(_WIN32) && defined(WITH_MEDIA_FOUNDATION) -extern H264_CONTEXT_SUBSYSTEM g_Subsystem_MF; -#endif +static const H264_CONTEXT_SUBSYSTEM* subSystems[MAX_SUBSYSTEMS] = { 0 }; static BOOL CALLBACK h264_register_subsystems(PINIT_ONCE once, PVOID param, PVOID* context) { @@ -592,7 +588,6 @@ static BOOL CALLBACK h264_register_subsystems(PINIT_ONCE once, PVOID param, PVOI #ifdef WITH_MEDIACODEC { - extern H264_CONTEXT_SUBSYSTEM g_Subsystem_mediacodec; subSystems[i] = &g_Subsystem_mediacodec; i++; } @@ -605,14 +600,12 @@ static BOOL CALLBACK h264_register_subsystems(PINIT_ONCE once, PVOID param, PVOI #endif #ifdef WITH_OPENH264 { - extern H264_CONTEXT_SUBSYSTEM g_Subsystem_OpenH264; subSystems[i] = &g_Subsystem_OpenH264; i++; } #endif #ifdef WITH_FFMPEG { - extern H264_CONTEXT_SUBSYSTEM g_Subsystem_libavcodec; subSystems[i] = &g_Subsystem_libavcodec; i++; } @@ -637,7 +630,7 @@ static BOOL h264_context_init(H264_CONTEXT* h264) for (i = 0; i < MAX_SUBSYSTEMS; i++) { - H264_CONTEXT_SUBSYSTEM* subsystem = subSystems[i]; + const H264_CONTEXT_SUBSYSTEM* subsystem = subSystems[i]; if (!subsystem || !subsystem->Init) break; diff --git a/libfreerdp/codec/h264.h b/libfreerdp/codec/h264.h index c4ff5d73d..8fa403a1a 100644 --- a/libfreerdp/codec/h264.h +++ b/libfreerdp/codec/h264.h @@ -22,25 +22,50 @@ #define FREERDP_LIB_CODEC_H264_H #include +#include #include -typedef BOOL (*pfnH264SubsystemInit)(H264_CONTEXT* h264); -typedef void (*pfnH264SubsystemUninit)(H264_CONTEXT* h264); - -typedef int (*pfnH264SubsystemDecompress)(H264_CONTEXT* h264, const BYTE* pSrcData, UINT32 SrcSize); -typedef int (*pfnH264SubsystemCompress)(H264_CONTEXT* h264, const BYTE** pSrcYuv, - const UINT32* pStride, BYTE** ppDstData, UINT32* pDstSize); - -struct S_H264_CONTEXT_SUBSYSTEM +#ifdef __cplusplus +extern "C" { - const char* name; - pfnH264SubsystemInit Init; - pfnH264SubsystemUninit Uninit; - pfnH264SubsystemDecompress Decompress; - pfnH264SubsystemCompress Compress; -}; +#endif -FREERDP_LOCAL BOOL avc420_ensure_buffer(H264_CONTEXT* h264, UINT32 stride, UINT32 width, - UINT32 height); + typedef BOOL (*pfnH264SubsystemInit)(H264_CONTEXT* h264); + typedef void (*pfnH264SubsystemUninit)(H264_CONTEXT* h264); + + typedef int (*pfnH264SubsystemDecompress)(H264_CONTEXT* h264, const BYTE* pSrcData, + UINT32 SrcSize); + typedef int (*pfnH264SubsystemCompress)(H264_CONTEXT* h264, const BYTE** pSrcYuv, + const UINT32* pStride, BYTE** ppDstData, + UINT32* pDstSize); + + struct S_H264_CONTEXT_SUBSYSTEM + { + const char* name; + pfnH264SubsystemInit Init; + pfnH264SubsystemUninit Uninit; + pfnH264SubsystemDecompress Decompress; + pfnH264SubsystemCompress Compress; + }; + + FREERDP_LOCAL BOOL avc420_ensure_buffer(H264_CONTEXT* h264, UINT32 stride, UINT32 width, + UINT32 height); + +#ifdef WITH_MEDIACODEC + extern const H264_CONTEXT_SUBSYSTEM g_Subsystem_mediacodec; +#endif +#if defined(_WIN32) && defined(WITH_MEDIA_FOUNDATION) + extern const H264_CONTEXT_SUBSYSTEM g_Subsystem_MF; +#endif +#ifdef WITH_OPENH264 + extern const H264_CONTEXT_SUBSYSTEM g_Subsystem_OpenH264; +#endif +#ifdef WITH_FFMPEG + extern const H264_CONTEXT_SUBSYSTEM g_Subsystem_libavcodec; +#endif + +#ifdef __cplusplus +} +#endif #endif /* FREERDP_LIB_CODEC_H264_H */ diff --git a/libfreerdp/codec/h264_ffmpeg.c b/libfreerdp/codec/h264_ffmpeg.c index 0a6a4ee46..23569d077 100644 --- a/libfreerdp/codec/h264_ffmpeg.c +++ b/libfreerdp/codec/h264_ffmpeg.c @@ -692,5 +692,6 @@ EXCEPTION: return FALSE; } -H264_CONTEXT_SUBSYSTEM g_Subsystem_libavcodec = { "libavcodec", libavcodec_init, libavcodec_uninit, - libavcodec_decompress, libavcodec_compress }; +const H264_CONTEXT_SUBSYSTEM g_Subsystem_libavcodec = { "libavcodec", libavcodec_init, + libavcodec_uninit, libavcodec_decompress, + libavcodec_compress }; diff --git a/libfreerdp/codec/h264_mediacodec.c b/libfreerdp/codec/h264_mediacodec.c index 842f0bbc2..ae6d76a2f 100644 --- a/libfreerdp/codec/h264_mediacodec.c +++ b/libfreerdp/codec/h264_mediacodec.c @@ -522,5 +522,6 @@ EXCEPTION: return FALSE; } -H264_CONTEXT_SUBSYSTEM g_Subsystem_mediacodec = { "MediaCodec", mediacodec_init, mediacodec_uninit, - mediacodec_decompress, mediacodec_compress }; +const H264_CONTEXT_SUBSYSTEM g_Subsystem_mediacodec = { "MediaCodec", mediacodec_init, + mediacodec_uninit, mediacodec_decompress, + mediacodec_compress }; diff --git a/libfreerdp/codec/h264_mf.c b/libfreerdp/codec/h264_mf.c index 113ffab42..40ee73527 100644 --- a/libfreerdp/codec/h264_mf.c +++ b/libfreerdp/codec/h264_mf.c @@ -592,5 +592,5 @@ error: return FALSE; } -H264_CONTEXT_SUBSYSTEM g_Subsystem_MF = { "MediaFoundation", mf_init, mf_uninit, mf_decompress, - mf_compress }; +const H264_CONTEXT_SUBSYSTEM g_Subsystem_MF = { "MediaFoundation", mf_init, mf_uninit, + mf_decompress, mf_compress }; diff --git a/libfreerdp/codec/h264_openh264.c b/libfreerdp/codec/h264_openh264.c index 17dbda692..5a140dfec 100644 --- a/libfreerdp/codec/h264_openh264.c +++ b/libfreerdp/codec/h264_openh264.c @@ -633,5 +633,5 @@ EXCEPTION: return FALSE; } -H264_CONTEXT_SUBSYSTEM g_Subsystem_OpenH264 = { "OpenH264", openh264_init, openh264_uninit, - openh264_decompress, openh264_compress }; +const H264_CONTEXT_SUBSYSTEM g_Subsystem_OpenH264 = { "OpenH264", openh264_init, openh264_uninit, + openh264_decompress, openh264_compress };