vaapidecode: parse source data until a frame is obtained.

Parse any pending data until a complete frame is obtained. This is a
memory optimization to avoid expansion of video packets stuffed into
the GstAdapter, and a fix to EOS condition to detect there is actually
pending data that needs to be decoded, and subsequently output.

https://bugzilla.gnome.org/show_bug.cgi?id=731831
This commit is contained in:
Gwenole Beauchesne 2014-06-18 13:47:36 +02:00
parent 781abad2c7
commit abfb5dd06c

View file

@ -54,6 +54,8 @@
#define GST_PLUGIN_NAME "vaapidecode" #define GST_PLUGIN_NAME "vaapidecode"
#define GST_PLUGIN_DESC "A VA-API based video decoder" #define GST_PLUGIN_DESC "A VA-API based video decoder"
#define GST_VAAPI_DECODE_FLOW_PARSE_DATA GST_FLOW_CUSTOM_SUCCESS_2
GST_DEBUG_CATEGORY_STATIC(gst_debug_vaapidecode); GST_DEBUG_CATEGORY_STATIC(gst_debug_vaapidecode);
#define GST_CAT_DEFAULT gst_debug_vaapidecode #define GST_CAT_DEFAULT gst_debug_vaapidecode
@ -785,7 +787,7 @@ gst_vaapidecode_set_format(GstVideoDecoder *vdec, GstVideoCodecState *state)
} }
static GstFlowReturn static GstFlowReturn
gst_vaapidecode_parse(GstVideoDecoder *vdec, gst_vaapidecode_parse_frame(GstVideoDecoder *vdec,
GstVideoCodecFrame *frame, GstAdapter *adapter, gboolean at_eos) GstVideoCodecFrame *frame, GstAdapter *adapter, gboolean at_eos)
{ {
GstVaapiDecode * const decode = GST_VAAPIDECODE(vdec); GstVaapiDecode * const decode = GST_VAAPIDECODE(vdec);
@ -808,7 +810,7 @@ gst_vaapidecode_parse(GstVideoDecoder *vdec,
decode->current_frame_size = 0; decode->current_frame_size = 0;
} }
else else
ret = GST_FLOW_OK; ret = GST_VAAPI_DECODE_FLOW_PARSE_DATA;
break; break;
case GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA: case GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA:
ret = GST_VIDEO_DECODER_FLOW_NEED_DATA; ret = GST_VIDEO_DECODER_FLOW_NEED_DATA;
@ -829,6 +831,18 @@ gst_vaapidecode_parse(GstVideoDecoder *vdec,
return ret; return ret;
} }
static GstFlowReturn
gst_vaapidecode_parse(GstVideoDecoder *vdec,
GstVideoCodecFrame *frame, GstAdapter *adapter, gboolean at_eos)
{
GstFlowReturn ret;
do {
ret = gst_vaapidecode_parse_frame(vdec, frame, adapter, at_eos);
} while (ret == GST_VAAPI_DECODE_FLOW_PARSE_DATA);
return ret;
}
static GstStateChangeReturn static GstStateChangeReturn
gst_vaapidecode_change_state (GstElement * element, GstStateChange transition) gst_vaapidecode_change_state (GstElement * element, GstStateChange transition)
{ {