Skip to content

Commit e45c709

Browse files
committed
added parallelisation support for linux. Added Trace level option for encoder/decoder. minor improvements
1 parent 881c5b5 commit e45c709

34 files changed

+1496
-1201
lines changed

Examples/AVRecord/AVRecord.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
<None Update="openh264-2.4.1-win64.dll">
3131
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
3232
</None>
33+
<None Update="openh264-2.5.0-win64.dll">
34+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
35+
</None>
3336
</ItemGroup>
3437

3538
</Project>
13.5 KB
Binary file not shown.

Examples/AVRecord/MainWindow.xaml.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,23 +153,24 @@ private void CaptureCam()
153153
capture.FrameHeight = h;
154154
capture.Fps = 30;
155155
capture.Open(0);
156-
capture.FrameWidth = w;
157-
capture.FrameHeight = h;
158-
capture.Fps = 30;
159-
Mat frame = new Mat(); ;
160-
Task.Run(() =>
156+
//capture.FrameWidth = w;
157+
//capture.FrameHeight = h;
158+
//capture.Fps = 30;
159+
Mat frame = new Mat();
160+
Thread t = new Thread(() =>
161161
{
162162
while (!stopCam)
163163
{
164164
if (capture.Read(frame))
165165
MatAvailable(frame);
166-
Thread.Sleep(1);
166+
//Thread.Sleep(1);
167167
}
168168

169169
capture.Release();
170170
capture.Dispose();
171171

172172
});
173+
t.Start();
173174
}
174175

175176

@@ -229,7 +230,10 @@ class EncodedData
229230
double perSecCtr = 0;
230231
int byteCnt = 0;
231232
int frameCnt = 0;
233+
232234
bool enableJitter = false;
235+
bool enablecv = false;
236+
private bool enableloss = false;
233237
Stopwatch sw = Stopwatch.StartNew();
234238
SLTRRecoverRequest recoverRequest = new SLTRRecoverRequest();
235239
byte[] dataBuffer = new byte[250000];
@@ -578,8 +582,7 @@ private void SSEUnChecked(object sender, RoutedEventArgs e)
578582
decoder.EnableSSEYUVConversion = ((CheckBox)sender).IsChecked ?? false;
579583

580584
}
581-
bool enablecv = false;
582-
private bool enableloss;
585+
583586

584587
private void CVChecked(object sender, RoutedEventArgs e)
585588
{
964 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Examples/H264SharpNativePInvoke/H264SharpNativePInvoke.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,8 @@
4444
<None Update="openh264-2.4.1-win64.dll">
4545
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
4646
</None>
47+
<None Update="openh264-2.5.0-win64.dll">
48+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
49+
</None>
4750
</ItemGroup>
4851
</Project>

Examples/H264SharpNativePInvoke/Program.cs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,32 @@
11
using H264Sharp;
2-
using System;
32
using System.Diagnostics;
43
using System.Drawing;
54
using System.Drawing.Imaging;
6-
using System.Runtime.CompilerServices;
7-
using System.Runtime.InteropServices;
8-
using System.Security.Cryptography;
9-
using System.Text;
105

116
namespace H264PInvoke
127
{
138
#pragma warning disable CA1416 // Validate platform compatibility
14-
9+
1510
internal class Program
1611
{
1712
static void Main(string[] args)
1813
{
1914
// You can change version or specify the path for cisco dll.
2015

21-
//Defines.CiscoDllName64bit = "openh264-2.4.0-win64.dll";
16+
//Defines.CiscoDllName64bit = "openh264-2.5.0-win64.dll";
2217
//Defines.CiscoDllName32bit = "openh264-2.4.0-win32.dll";
2318

2419
H264Encoder encoder = new H264Encoder();
2520
H264Decoder decoder = new H264Decoder();
26-
21+
2722
encoder.ConverterNumberOfThreads = 4;
2823
decoder.ConverterNumberOfThreads = 4;
2924
decoder.EnableSSEYUVConversion = true;
3025

3126
decoder.Initialize();
32-
33-
var img = System.Drawing.Image.FromFile("ocean 1920x1080.jpg");
34-
int w = img.Width;
27+
var img = System.Drawing.Image.FromFile("ocean 1920x1080.jpg");
28+
//var img = System.Drawing.Image.FromFile("ocean 3840x2160.jpg");
29+
int w = img.Width;
3530
int h = img.Height;
3631
var bmp = new Bitmap(img);
3732
Console.WriteLine($"{w}x{h}");
@@ -47,21 +42,21 @@ static void Main(string[] args)
4742
//converter.Downscale(data,to,2);
4843
//var bb = RgbToBitmap(to);
4944
//bb.Save("Dowmscaled.bmp");
50-
45+
5146
RgbImage rgbb = new RgbImage(w, h);
5247
for (int j = 0; j < 1000; j++)
5348
{
54-
55-
if(!encoder.Encode(data, out EncodedData[] ec))
49+
50+
if (!encoder.Encode(data, out EncodedData[] ec))
5651
{
5752
Console.WriteLine("skipped");
5853
continue;
5954
}
60-
55+
6156
//encoder.ForceIntraFrame();
6257
//encoder.SetMaxBitrate(2000000);
6358
//encoder.SetTargetFps(16.9f);
64-
59+
6560
foreach (var encoded in ec)
6661
{
6762
bool keyframe = encoded.FrameType == FrameType.I || encoded.FrameType == FrameType.IDR;
Binary file not shown.

H264Sharp/Data.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public ImageData(ImageType imgType, int width, int height, int stride, IntPtr im
131131

132132
/// <summary>
133133
/// Represents an RGB image stored on inner buffer of decoder.
134-
/// only used for short lived operations because next decode will overwite this data
134+
/// Next decode will overwite this data
135135
/// use with caution.
136136
/// </summary>
137137
[StructLayout(LayoutKind.Sequential)]
@@ -181,6 +181,9 @@ public void CopyTo(byte[] buffer, int startIndex)
181181
}
182182
};
183183

184+
/// <summary>
185+
/// Unsafe YUV420P pointer struct
186+
/// </summary>
184187
[StructLayout(LayoutKind.Sequential)]
185188
public unsafe readonly ref struct YUVImagePointer
186189
{
@@ -831,7 +834,18 @@ public enum SliceModeEnum
831834
SM_RESERVED = 4
832835
}
833836
;
834-
837+
public enum TRACE_LEVEL
838+
{
839+
WELS_LOG_QUIET = 0x00,
840+
WELS_LOG_ERROR = 1 << 0,
841+
WELS_LOG_WARNING = 1 << 1,
842+
WELS_LOG_INFO = 1 << 2,
843+
WELS_LOG_DEBUG = 1 << 3,
844+
WELS_LOG_DETAIL = 1 << 4,
845+
WELS_LOG_RESV = 1 << 5,
846+
WELS_LOG_LEVEL_COUNT = 6,
847+
WELS_LOG_DEFAULT = WELS_LOG_WARNING
848+
}
835849
public enum ESampleAspectRatio
836850
{
837851
ASP_UNSPECIFIED = 0,

0 commit comments

Comments
 (0)