Why my Key frame not in the first with H264 encoder

Why my Key frame not in the first with H264 encoder

I set a Encoder with GOP = 3 to generate the h264 stream, then I check the frame type with checking the mfxStream.FrameType flag, but I get the weird order like:  P, P, K, P ,P, K, P , P , K    ( P is p frame and K is key frame).

I just wonder why the encoder didnt generate  the h264 stream start with K frame?   like  K, P ,P, K, P , P , K , P, P

 

Here is my parameter:  

    encodepara.mfx.GopPicSize = 3;

    encodepara.mfx.GopRefDist = 1;

    encodepara.mfx.GopOptFlag  =  MFX_FRAMETYPE_I | MFX_FRAMETYPE_REF;

    encodepara.mfx.IdrInterval = 0;

    encodepara.mfx.NumRefFrame = 1;

1 post / 0 new
For more complete information about compiler optimizations, see our Optimization Notice.