H264Sharp
H264Sharp copied to clipboard
H264Decoder incorrect offset
The Decode() overloads that take in a byte[] in H264Decoder apply the provided offset twice. Meaning that any offset other than zero gets applied incorrectly. (And therefore failing to decode the data properly in most cases)
public bool Decode(byte[] encoded, int offset, int count, bool noDelay, out DecodingState state, out YUVImagePointer yuv)
{
state = 0;
yuv = new YUVImagePointer();
int state_ = 0;
unsafe
{
fixed (byte* P = &encoded[offset]) // <- pointer gets offsetted here
{
int success = native.DecodeAsYUV(decoder, ref P[offset], count, noDelay, ref state_, ref yuv); // <- but oh no, it gets offsetted here too
state = (DecodingState)state_;
return success==0;
}
}
}
The solution is simple, just remove one of the offsets.
wow good catch, surprising how its missed until now. since I use either buffered frames or handing off to different thread, a copy into fresh buffer is involved so offset was always 0.
Good thing its on managed side so fix will be out quick. Thanks