GNOME Bugzilla – Bug 768652
vaapidecode: improvements for flush and drain
Last modified: 2016-07-11 17:43:24 UTC
several improvements for flush and drain vmethods
Created attachment 331187 [details] [review] vaapidecode: call purge at flush() Calling flush() vmethod means "to flush all remaining data from the decoder without pushing it downstream". Nonetheless flush() is calling gst_vaapidecode_internal_flush(), which calls gst_video_decoder_have_frame() if there is still something in the input adapter, which may push buffers to downstream by calling handle_frame(). This patch changes this behavior by calling gst_vaapidecode_purge() rather than gst_vaapidecode_internal_flush(), which does what we want: flushes the VA decoder and releases all the rest of decoded frames.
Created attachment 331188 [details] [review] vaapidecode: flush output adapter at drain() Calling drain() vmethod means "decode any data it can at this point, but that more data may arrive after". Hence, vaapidecode should check if there is data in the output adapter and process them, without destroying the decoded picture buffer (dpb). Since this operation is done by gst_vaapidecode_internal_flush(), the operation was refactored into a new function gst_vaapidecode_flush_output_adapter().
Created attachment 331189 [details] [review] vaapidecode: remove gst_vaapidecode_internal_flush() As gst_vaapidecode_finish() is the only callee of gst_vaapidecode_internal_flush(), it is better to inline it.
Created attachment 331190 [details] [review] vaapidecode: unref output frame earlier The queue in GstVaapiDecode adds an extra reference to the frames. This patch unref that extra reference earlier making the code simpler to follow.
Attachment 331187 [details] pushed as 03e85bb - vaapidecode: call purge at flush() Attachment 331188 [details] pushed as b392b4f - vaapidecode: flush output adapter at drain() Attachment 331189 [details] pushed as cb0ec6b - vaapidecode: remove gst_vaapidecode_internal_flush() Attachment 331190 [details] pushed as c9a5801 - vaapidecode: unref output frame earlier