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.
This commit is contained in:
Gwenole Beauchesne 2012-12-13 10:20:35 +01:00
parent 66cc8754fc
commit ea9703362c
2 changed files with 22 additions and 2 deletions

View file

@ -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;
}

View file

@ -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