G
Guest
Hi,
In my C# video streaming app, I have to write a video frame to a socket. In
the socket I write video packet, which are composed of a 5 bytes header,
followed by the video frame bytes. My question is all about how to create
the packet (adding the 5 bytes header to the bytes of the frame) the most
efficiently.
The video frame is a ushort[], precisely : ushort[19200]
And I need the packet : byte[38405], with the byte 0-5 being the header,
and the rest being the frame data.
So I have 2 issues : adding the header, converting the ushort to bytes.
I am doing the copy of the ushort to the right place of the packet, by using
memory pointers (in unsage block) which I cast to bytes.
It is working good, but it is taking approximately 7 ms.
I would like to reduce this time... so I have two questios :
- How can I "cast", "convert", or "copy" the ushort[] frame data to the
byte[] packet ? Faster than what I already do
- Is it possible to add/insert the header bytes at the begining of the
ushort[] so that I do not need to copy the entire frame data.. ?
I find it stupid to copy the whole video data, simply to add a small
header... but I can't see how I can do it differently.... do you ?
Thanks a lot!
Lionel Reyero
In my C# video streaming app, I have to write a video frame to a socket. In
the socket I write video packet, which are composed of a 5 bytes header,
followed by the video frame bytes. My question is all about how to create
the packet (adding the 5 bytes header to the bytes of the frame) the most
efficiently.
The video frame is a ushort[], precisely : ushort[19200]
And I need the packet : byte[38405], with the byte 0-5 being the header,
and the rest being the frame data.
So I have 2 issues : adding the header, converting the ushort to bytes.
I am doing the copy of the ushort to the right place of the packet, by using
memory pointers (in unsage block) which I cast to bytes.
It is working good, but it is taking approximately 7 ms.
I would like to reduce this time... so I have two questios :
- How can I "cast", "convert", or "copy" the ushort[] frame data to the
byte[] packet ? Faster than what I already do
- Is it possible to add/insert the header bytes at the begining of the
ushort[] so that I do not need to copy the entire frame data.. ?
I find it stupid to copy the whole video data, simply to add a small
header... but I can't see how I can do it differently.... do you ?
Thanks a lot!
Lionel Reyero