Commit ea970336 authored by Gwenole Beauchesne's avatar Gwenole Beauchesne

decoder: add {start,end}_frame() hooks.

The start_frame() hook is called prior to traversing all decode-units
for decoding. The unit argument represents the first slice in the frame.
Some codecs (e.g. H.264) need to wait for the first slice in order to
determine the actual VA context parameters.
parent 66cc8754
......@@ -210,13 +210,24 @@ do_decode(GstVaapiDecoder *decoder, GstVideoCodecFrame *base_frame)
{
GstVaapiDecoderClass * const klass = GST_VAAPI_DECODER_GET_CLASS(decoder);
GstVaapiParserState * const ps = &decoder->priv->parser_state;
GstVaapiDecoderFrame *frame;
GstVaapiDecoderFrame * const frame = base_frame->user_data;
GstVaapiDecoderStatus status;
GSList *l;
ps->current_frame = base_frame;
frame = base_frame->user_data;
if (klass->start_frame) {
for (l = frame->units; l != NULL; l = l->next) {
GstVaapiDecoderUnit * const unit = l->data;
if (GST_VAAPI_DECODER_UNIT_IS_SLICE(unit)) {
status = klass->start_frame(decoder, unit);
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
return status;
break;
}
}
}
for (l = frame->units; l != NULL; l = l->next) {
GstVaapiDecoderUnit * const unit = l->data;
if (GST_VAAPI_DECODER_UNIT_IS_SKIPPED(unit))
......@@ -225,6 +236,12 @@ do_decode(GstVaapiDecoder *decoder, GstVideoCodecFrame *base_frame)
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
return status;
}
if (klass->end_frame) {
status = klass->end_frame(decoder);
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
return status;
}
return GST_VAAPI_DECODER_STATUS_SUCCESS;
}
......
......@@ -118,6 +118,9 @@ struct _GstVaapiDecoderClass {
struct _GstVaapiDecoderUnit **unit_ptr);
GstVaapiDecoderStatus (*decode)(GstVaapiDecoder *decoder,
struct _GstVaapiDecoderUnit *unit);
GstVaapiDecoderStatus (*start_frame)(GstVaapiDecoder *decoder,
struct _GstVaapiDecoderUnit *unit);
GstVaapiDecoderStatus (*end_frame)(GstVaapiDecoder *decoder);
};
GType
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment