Multi-Frame problem implementing NvDec with GstVideoDecoder
I've written a plugin to implement Nvidia cuvid decoding based on the GstVideoDecoder base. I've gotten a few test files to play, but have run into a problem with the old standby of BigBuckBunny (specifically bbb_sunflower_2160p_60fps_normal.mp4).
My code gets called in gst_nv_dec_parse by the base GstVideoDecode, and I pass the information on to cuvidParseVideoData() to parse the input data into frames. It finds TWO frames and so calls my cuvid_frame_parsed callback twice in a row.
On the first call, I record the frame that I was given in gst_nv_dec_parse (for later use as an output frame) and call gst_video_decoder_have_frame.
On the second call, I've already used the input frame, and now don't know where I'm going to get a second output frame. There doesn't seem to be any way to request one.
Technically, I could simply call gst_video_decoder_have_frame twice in a row, but looking at its code, this seems likely to cause a crash as it relies on there being a valid current_frame, and it sets the current_frame to NULL at the end of processing.