mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 06:16:36 +00:00
decoder: expose new parse/decode API.
Introduce new decoding process whereby a GstVideoCodecFrame is created first. Next, input stream buffers are accumulated into a GstAdapter, that is then passed to the _parse() function. The GstVaapiDecoder object accumulates all parsed units and when a complete frame or field is detected, that GstVideoCodecFrame is passed to the _decode() function. Ultimately, the caller receives a GstVaapiSurfaceProxy if decoding process was successful.
This commit is contained in:
parent
ea9703362c
commit
6bed9ebe0f
3 changed files with 62 additions and 0 deletions
|
@ -787,3 +787,50 @@ gst_vaapi_decoder_check_status(GstVaapiDecoder *decoder)
|
|||
return GST_VAAPI_DECODER_STATUS_ERROR_NO_SURFACE;
|
||||
return GST_VAAPI_DECODER_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
GstVaapiDecoderStatus
|
||||
gst_vaapi_decoder_parse(GstVaapiDecoder *decoder,
|
||||
GstVideoCodecFrame *base_frame, GstAdapter *adapter, gboolean at_eos,
|
||||
guint *got_unit_size_ptr, gboolean *got_frame_ptr)
|
||||
{
|
||||
g_return_val_if_fail(GST_VAAPI_IS_DECODER(decoder),
|
||||
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
|
||||
g_return_val_if_fail(base_frame != NULL,
|
||||
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
|
||||
g_return_val_if_fail(adapter != NULL,
|
||||
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
|
||||
g_return_val_if_fail(got_unit_size_ptr != NULL,
|
||||
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
|
||||
g_return_val_if_fail(got_frame_ptr != NULL,
|
||||
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
|
||||
|
||||
return do_parse(decoder, base_frame, adapter, at_eos,
|
||||
got_unit_size_ptr, got_frame_ptr);
|
||||
}
|
||||
|
||||
GstVaapiDecoderStatus
|
||||
gst_vaapi_decoder_decode(GstVaapiDecoder *decoder,
|
||||
GstVideoCodecFrame *base_frame, GstVaapiSurfaceProxy **out_proxy_ptr)
|
||||
{
|
||||
GstVaapiDecoderStatus status;
|
||||
|
||||
g_return_val_if_fail(GST_VAAPI_IS_DECODER(decoder),
|
||||
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
|
||||
g_return_val_if_fail(base_frame != NULL,
|
||||
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
|
||||
g_return_val_if_fail(base_frame->user_data != NULL,
|
||||
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
|
||||
g_return_val_if_fail(out_proxy_ptr != NULL,
|
||||
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
|
||||
|
||||
status = gst_vaapi_decoder_check_status(decoder);
|
||||
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
status = do_decode(decoder, base_frame);
|
||||
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
|
||||
return status;
|
||||
|
||||
*out_proxy_ptr = pop_surface(decoder);
|
||||
return GST_VAAPI_DECODER_STATUS_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -73,6 +73,7 @@ typedef struct _GstVaapiDecoderClass GstVaapiDecoderClass;
|
|||
* @GST_VAAPI_DECODER_STATUS_ERROR_BITSTREAM_PARSER: Invalid or unsupported bitstream data.
|
||||
* @GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_PROFILE: Unsupported codec profile.
|
||||
* @GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_CHROMA_FORMAT: Unsupported chroma format.
|
||||
* @GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER: Unsupported parameter.
|
||||
* @GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN: Unknown error.
|
||||
*
|
||||
* Decoder status for gst_vaapi_decoder_get_surface().
|
||||
|
@ -89,6 +90,7 @@ typedef enum {
|
|||
GST_VAAPI_DECODER_STATUS_ERROR_BITSTREAM_PARSER,
|
||||
GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_PROFILE,
|
||||
GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_CHROMA_FORMAT,
|
||||
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER,
|
||||
GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN = -1
|
||||
} GstVaapiDecoderStatus;
|
||||
|
||||
|
@ -141,6 +143,15 @@ gst_vaapi_decoder_get_surface(
|
|||
GstVaapiDecoderStatus *pstatus
|
||||
);
|
||||
|
||||
GstVaapiDecoderStatus
|
||||
gst_vaapi_decoder_parse(GstVaapiDecoder *decoder,
|
||||
GstVideoCodecFrame *frame, GstAdapter *adapter, gboolean at_eos,
|
||||
guint *got_unit_size_ptr, gboolean *got_frame_ptr);
|
||||
|
||||
GstVaapiDecoderStatus
|
||||
gst_vaapi_decoder_decode(GstVaapiDecoder *decoder,
|
||||
GstVideoCodecFrame *frame, GstVaapiSurfaceProxy **out_proxy_ptr);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* GST_VAAPI_DECODER_H */
|
||||
|
|
|
@ -163,6 +163,10 @@ gst_vaapi_picture_create(
|
|||
picture->slices = g_ptr_array_new();
|
||||
if (!picture->slices)
|
||||
return FALSE;
|
||||
|
||||
gst_vaapi_mini_object_set_user_data(
|
||||
GST_VAAPI_MINI_OBJECT(picture->proxy),
|
||||
GST_VAAPI_DECODER_CODEC_FRAME(GET_DECODER(picture)), NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue