Skip to content

Commit

Permalink
Merge pull request #8 from ReferenceType/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ReferenceType authored Jan 2, 2025
2 parents 0092d65 + e45c709 commit 0b92767
Show file tree
Hide file tree
Showing 40 changed files with 1,935 additions and 1,571 deletions.
3 changes: 3 additions & 0 deletions Examples/AVRecord/AVRecord.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
<None Update="openh264-2.4.1-win64.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="openh264-2.5.0-win64.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Binary file modified Examples/AVRecord/H264SharpNative-win64.dll
Binary file not shown.
19 changes: 11 additions & 8 deletions Examples/AVRecord/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,23 +153,24 @@ private void CaptureCam()
capture.FrameHeight = h;
capture.Fps = 30;
capture.Open(0);
capture.FrameWidth = w;
capture.FrameHeight = h;
capture.Fps = 30;
Mat frame = new Mat(); ;
Task.Run(() =>
//capture.FrameWidth = w;
//capture.FrameHeight = h;
//capture.Fps = 30;
Mat frame = new Mat();
Thread t = new Thread(() =>
{
while (!stopCam)
{
if (capture.Read(frame))
MatAvailable(frame);
Thread.Sleep(1);
//Thread.Sleep(1);
}

capture.Release();
capture.Dispose();

});
t.Start();
}


Expand Down Expand Up @@ -229,7 +230,10 @@ class EncodedData
double perSecCtr = 0;
int byteCnt = 0;
int frameCnt = 0;

bool enableJitter = false;
bool enablecv = false;
private bool enableloss = false;
Stopwatch sw = Stopwatch.StartNew();
SLTRRecoverRequest recoverRequest = new SLTRRecoverRequest();
byte[] dataBuffer = new byte[250000];
Expand Down Expand Up @@ -578,8 +582,7 @@ private void SSEUnChecked(object sender, RoutedEventArgs e)
decoder.EnableSSEYUVConversion = ((CheckBox)sender).IsChecked ?? false;

}
bool enablecv = false;
private bool enableloss;


private void CVChecked(object sender, RoutedEventArgs e)
{
Expand Down
Binary file added Examples/AVRecord/openh264-2.5.0-win64.dll
Binary file not shown.
13 changes: 4 additions & 9 deletions Examples/CrossPlatformTest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ namespace CrossPlatformTest
{
internal class Program
{
//TODO test on linux with the opt none removal

/*
* Loads a raw rgba and encodes - decodes.
* I publish this for linux and add ncessary .so files on executable dir.
* Loads a raw rgba and encodes -> decodes.
* I publish this for linux and add ncessary .so files on out dir.
*/
static void Main(string[] args)
{
Expand Down Expand Up @@ -70,13 +72,6 @@ static void Main(string[] args)
decoder.Dispose();
Console.ReadLine();
}







}

}
Binary file not shown.
Binary file not shown.
Binary file modified Examples/H264SharpNativePInvoke/H264SharpNative-win64.dll
Binary file not shown.
3 changes: 3 additions & 0 deletions Examples/H264SharpNativePInvoke/H264SharpNativePInvoke.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,8 @@
<None Update="openh264-2.4.1-win64.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="openh264-2.5.0-win64.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
27 changes: 11 additions & 16 deletions Examples/H264SharpNativePInvoke/Program.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,32 @@
using H264Sharp;
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;

namespace H264PInvoke
{
#pragma warning disable CA1416 // Validate platform compatibility

internal class Program
{
static void Main(string[] args)
{
// You can change version or specify the path for cisco dll.

//Defines.CiscoDllName64bit = "openh264-2.4.0-win64.dll";
//Defines.CiscoDllName64bit = "openh264-2.5.0-win64.dll";
//Defines.CiscoDllName32bit = "openh264-2.4.0-win32.dll";

H264Encoder encoder = new H264Encoder();
H264Decoder decoder = new H264Decoder();

encoder.ConverterNumberOfThreads = 4;
decoder.ConverterNumberOfThreads = 4;
decoder.EnableSSEYUVConversion = true;

decoder.Initialize();

var img = System.Drawing.Image.FromFile("ocean 1920x1080.jpg");
int w = img.Width;
var img = System.Drawing.Image.FromFile("ocean 1920x1080.jpg");
//var img = System.Drawing.Image.FromFile("ocean 3840x2160.jpg");
int w = img.Width;
int h = img.Height;
var bmp = new Bitmap(img);
Console.WriteLine($"{w}x{h}");
Expand All @@ -47,21 +42,21 @@ static void Main(string[] args)
//converter.Downscale(data,to,2);
//var bb = RgbToBitmap(to);
//bb.Save("Dowmscaled.bmp");

RgbImage rgbb = new RgbImage(w, h);
for (int j = 0; j < 1000; j++)
{
if(!encoder.Encode(data, out EncodedData[] ec))

if (!encoder.Encode(data, out EncodedData[] ec))
{
Console.WriteLine("skipped");
continue;
}

//encoder.ForceIntraFrame();
//encoder.SetMaxBitrate(2000000);
//encoder.SetTargetFps(16.9f);

foreach (var encoded in ec)
{
bool keyframe = encoded.FrameType == FrameType.I || encoded.FrameType == FrameType.IDR;
Expand Down
Binary file not shown.
17 changes: 7 additions & 10 deletions H264Sharp/Converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ public class Converter

private readonly bool x64 = Environment.Is64BitProcess;

/// <summary>
/// Downslales image by given factor efficiently
/// i.e multiplier 2 gives w/2,h/2.
/// </summary>
/// <param name="from"></param>
/// <param name="to"></param>
/// <param name="multiplier"></param>
public void Downscale(ImageData from, RgbImage to, int multiplier)
{
unsafe
Expand Down Expand Up @@ -94,19 +101,9 @@ public void Downscale(ImageData from, RgbImage to, int multiplier)
DownscaleImgx86(ref ugi, ref t, multiplier);
}
}



}

}





}

}


Expand Down
Loading

0 comments on commit 0b92767

Please sign in to comment.