Skip to content

Commit d00f84e

Browse files
committed
linux compatibility changes
1 parent f96f3a9 commit d00f84e

File tree

9 files changed

+365
-183
lines changed

9 files changed

+365
-183
lines changed
5 KB
Binary file not shown.
512 Bytes
Binary file not shown.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"profiles": {
3+
"H264SharpNativePInvoke": {
4+
"commandName": "Project",
5+
"nativeDebugging": true
6+
}
7+
}
8+
}

H264SharpNative/ConverterLocal.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "pch.h"
33

44

5-
extern "C" __declspec(dllexport) void Yuv420P2RGB(unsigned char* dst_ptr,
5+
void Yuv420P2RGB(unsigned char* dst_ptr,
66
const unsigned char* y_ptr,
77
const unsigned char* u_ptr,
88
const unsigned char* v_ptr,
@@ -12,14 +12,14 @@ extern "C" __declspec(dllexport) void Yuv420P2RGB(unsigned char* dst_ptr,
1212
signed int uv_span,
1313
signed int dst_span,
1414
bool useSSE,
15-
int threadCount);
15+
int numThreads);
1616

17-
extern "C" __declspec(dllexport) void BGRAtoYUV420Planar(const unsigned char* bgra, unsigned char* dst, int width, int height, int stride, int threadCount);
18-
extern "C" __declspec(dllexport) void BGRtoYUV420Planar(unsigned char* bgr, unsigned char* dst, int width, int height, int stride, int threadCount);
19-
extern "C" __declspec(dllexport) void RGBAtoYUV420Planar(unsigned char* bgr, unsigned char* dst, int width, int height, int stride, int threadCount);
20-
extern "C" __declspec(dllexport) void RGBtoYUV420Planar(unsigned char* bgr, unsigned char* dst, int width, int height, int stride, int threadCount);
21-
extern "C" __declspec(dllexport) void Downscale24(unsigned char* rgbSrc, int width, int height, int stride, unsigned char* dst, int multiplier);
22-
extern "C" __declspec(dllexport) void Downscale32(unsigned char* rgbSrc, int width, int height, int stride, unsigned char* dst, int multiplier);
17+
void BGRAtoYUV420Planar(const unsigned char* bgra, unsigned char* dst, int width, int height, int stride, int threadCount);
18+
void BGRtoYUV420Planar(unsigned char* bgr, unsigned char* dst, int width, int height, int stride, int threadCount);
19+
void RGBAtoYUV420Planar(unsigned char* bgr, unsigned char* dst, int width, int height, int stride, int threadCount);
20+
void RGBtoYUV420Planar(unsigned char* bgr, unsigned char* dst, int width, int height, int stride, int threadCount);
21+
void Downscale24(unsigned char* rgbSrc, int width, int height, int stride, unsigned char* dst, int multiplier);
22+
void Downscale32(unsigned char* rgbSrc, int width, int height, int stride, unsigned char* dst, int multiplier);
2323

2424
//void __cdecl BGRAtoYUV420Planar_(unsigned char* bgra, unsigned char* dst, int width, int height, int stride);
2525

H264SharpNative/Decoder.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "pch.h"
22
#include <chrono>
33
#include "Decoder.h"
4+
#include <stdexcept>
45

56
namespace H264Sharp {
67

@@ -69,9 +70,7 @@ namespace H264Sharp {
6970
throw std::runtime_error("Failed to create decoder");
7071
}
7172

72-
#ifndef _WIN32
73-
// No need to close library handle on Linux
74-
#endif
73+
7574
}
7675

7776
//void Decoder::Create(const wchar_t* dllname)

H264SharpNative/Decoder.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22
#include "pch.h"
33
#include <string>
4-
#include <ppl.h>
4+
55

66

77
namespace H264Sharp
@@ -53,7 +53,7 @@ namespace H264Sharp
5353
{
5454
useSSEConverter = isSSE;
5555
};
56-
int threadCount = ((4) < (std::thread::hardware_concurrency())) ? (4) : (std::thread::hardware_concurrency());
56+
int threadCount = 4;
5757

5858

5959
private:
@@ -62,9 +62,9 @@ namespace H264Sharp
6262
ISVCDecoder* decoder= nullptr;
6363
bool useSSEConverter = true;
6464

65-
typedef int(__cdecl* WelsCreateDecoderFunc)(ISVCDecoder** ppDecoder);
65+
typedef int(*WelsCreateDecoderFunc)(ISVCDecoder** ppDecoder);
6666
WelsCreateDecoderFunc CreateDecoderFunc= nullptr;
67-
typedef void(__cdecl* WelsDestroyDecoderFunc)(ISVCDecoder* ppDecoder);
67+
typedef void(*WelsDestroyDecoderFunc)(ISVCDecoder* ppDecoder);
6868
WelsDestroyDecoderFunc DestroyDecoderFunc= nullptr;
6969

7070
void Create(const wchar_t* dllName);

H264SharpNative/Encoder.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ namespace H264Sharp {
1313
const wchar_t* dllName = is64Bit() ? L"openh264-2.3.1-win64.dll" : L"openh264-2.3.1-win32.dll";
1414
Create(dllName);
1515
}
16+
Encoder::Encoder(std::string dllName)
17+
{
18+
auto s = std::wstring(dllName.begin(), dllName.end());
19+
const wchar_t* dllname = s.c_str();
20+
Create(dllname);
21+
}
1622
Encoder::Encoder(const wchar_t* dllname)
1723
{
1824
/*auto s = std::wstring(dllName.begin(),dllName.end());
@@ -26,6 +32,8 @@ namespace H264Sharp {
2632
EncodedFrame* ef5;
2733
void Encoder::Create(const wchar_t* dllname)
2834
{
35+
std::cout << "New Version " << " loading\n";
36+
2937
std::cout << dllname << " loading\n";
3038

3139
// Load dynamic library
@@ -72,7 +80,7 @@ namespace H264Sharp {
7280

7381
// Close library handle
7482
#ifdef _WIN32
75-
DLL_CLOSE_FUNCTION(handle);
83+
//DLL_CLOSE_FUNCTION(handle);
7684
#else
7785
// No need to close on Linux
7886
#endif

H264SharpNative/Encoder.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#include "pch.h"
33
#include <string>
44

5-
#include <ppl.h>
65

76
namespace H264Sharp {
87

@@ -13,6 +12,8 @@ namespace H264Sharp {
1312
{
1413
public:
1514
Encoder(const wchar_t* dllname);
15+
Encoder(std::string dllName);
16+
1617
Encoder();
1718
~Encoder();
1819

@@ -31,7 +32,7 @@ namespace H264Sharp {
3132
int ForceIntraFrame();
3233
void SetMaxBitrate(int target);
3334
void SetTargetFps(float target);
34-
int threadCount = ((4) < (std::thread::hardware_concurrency())) ? (4) : (std::thread::hardware_concurrency());
35+
int threadCount = 4;
3536

3637

3738
private:
@@ -43,9 +44,9 @@ namespace H264Sharp {
4344
SSourcePicture* pic = nullptr;
4445
SFrameBSInfo* bsi = nullptr;
4546

46-
typedef int(__cdecl* WelsCreateSVCEncoder)(ISVCEncoder** ppEncoder);
47+
typedef int(* WelsCreateSVCEncoder)(ISVCEncoder** ppEncoder);
4748
WelsCreateSVCEncoder CreateEncoderFunc;
48-
typedef void(__cdecl* WelsDestroySVCEncoder)(ISVCEncoder* ppEncoder);
49+
typedef void(* WelsDestroySVCEncoder)(ISVCEncoder* ppEncoder);
4950
WelsDestroySVCEncoder DestroyEncoderFunc;
5051

5152
void Create(const wchar_t* dllName);

0 commit comments

Comments
 (0)