Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimisations required for 1080p #384

Closed
sipsorcery opened this issue Dec 21, 2020 · 1 comment
Closed

Optimisations required for 1080p #384

sipsorcery opened this issue Dec 21, 2020 · 1 comment

Comments

@sipsorcery
Copy link
Member

Attempting to receive a VP8 encoded video stream at 1080p (1920x1080) will quickly degrade to become very laggy and then corrupted. The sipsorcery library is not able to decode the video stream fast enough which results in the network buffer filling up and then dropping packets. The library is able to keep up with 720p (1280x720) on a Win10 i7 CPU.

The main bottleneck is the I420toBGR function.

1080p_hotpath

1080p_hotpath_diags

@jvakos
Copy link

jvakos commented Nov 2, 2021

I don't have any experience in video enc/dec but in past I had to do some image processing (pixel by pixel processing). Back then, I gave a performance boost by using unsafe code block.

`BitmapData data = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height),
ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);

int scaledPercent = percent * 255;
unsafe {
byte* prevLine = (byte*)data.Scan0;
byte* currLine = prevLine + data.Stride;
byte* nextLine = currLine + data.Stride;

for (int y=1; y < bitmap.Height - 1; y++) {

   byte* pp = prevLine + 3;
   byte* cp = currLine + 3;
   byte* np = nextLine + 3;
   for (int x = 1; x < bitmap.Width - 1; x++) {
       //here goes the proceccing
       pp += 3; cp += 3; np += 3;
   }
   prevLine = currLine;
   currLine = nextLine;
   nextLine += data.Stride;
}

}
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants