Skip to content

Decoded B-frame buffer can be overwritten by next decoding frame #3079

@xiaotiansf

Description

@xiaotiansf

In ffmpeg, it calls DecodeFrame2 once for each frame. However the decoded picture may not be ready immediately after the call (pDstInfo->iBufferStatus = 0). This is not a problem when B-frame decoding is not supported.

The problem comes when B-frame decoding is supported:
The last decoded non-reference B-frame (pDstInfo->iBufferStatus = 0 after the call DecodeFrame2 ) (so it is disposable) buffer could be overwritten by next decoding frame because decoder thinks no-body refers to the B-frame.

So the correct way to do in ffmpeg is to call DecodeFrameNoDelay which contains two calls of DecodeFrame2. The second call allows to release the ready non-reference B-frame to be released immediately to prevent its buffer to be overwritten by next decoding frame.

Could someone provide help regarding this issue? Maybe there is a better solution?

@mstorsjo I am wondering that the issue in your test asset https://download.blender.org/peach/bigbuckbunny_movies/big_buck_bunny_480p_h264.mov. has something to do with this.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions