Skip to content

H264Decoder incorrect offset #20

@follyfoxe

Description

@follyfoxe

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions