Skip to content

Commit 0b92767

Browse files
Merge pull request #8 from ReferenceType/develop
Develop
2 parents 0092d65 + e45c709 commit 0b92767

40 files changed

+1935
-1571
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.

Examples/CrossPlatformTest/Program.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ namespace CrossPlatformTest
66
{
77
internal class Program
88
{
9+
//TODO test on linux with the opt none removal
10+
911
/*
10-
* Loads a raw rgba and encodes - decodes.
11-
* I publish this for linux and add ncessary .so files on executable dir.
12+
* Loads a raw rgba and encodes -> decodes.
13+
* I publish this for linux and add ncessary .so files on out dir.
1214
*/
1315
static void Main(string[] args)
1416
{
@@ -70,13 +72,6 @@ static void Main(string[] args)
7072
decoder.Dispose();
7173
Console.ReadLine();
7274
}
73-
74-
75-
76-
77-
78-
79-
8075
}
8176

8277
}
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/Converter.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ public class Converter
2929

3030
private readonly bool x64 = Environment.Is64BitProcess;
3131

32+
/// <summary>
33+
/// Downslales image by given factor efficiently
34+
/// i.e multiplier 2 gives w/2,h/2.
35+
/// </summary>
36+
/// <param name="from"></param>
37+
/// <param name="to"></param>
38+
/// <param name="multiplier"></param>
3239
public void Downscale(ImageData from, RgbImage to, int multiplier)
3340
{
3441
unsafe
@@ -94,19 +101,9 @@ public void Downscale(ImageData from, RgbImage to, int multiplier)
94101
DownscaleImgx86(ref ugi, ref t, multiplier);
95102
}
96103
}
97-
98-
99-
100104
}
101-
102105
}
103-
104-
105-
106-
107-
108106
}
109-
110107
}
111108

112109

0 commit comments

Comments
 (0)