mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-10 03:19:40 +00:00
decoder: optimize pre-allocation of decoder units.
Optimize pre-allocation of decoder units, thus avoiding un-necessary memory reallocations. The heuristic used is that we could have around one slice unit per macroblock line.
This commit is contained in:
parent
4fd99cc989
commit
a486d1af66
3 changed files with 16 additions and 6 deletions
|
@ -135,7 +135,8 @@ do_parse(GstVaapiDecoder *decoder,
|
|||
GstVideoCodecFrame *base_frame, GstAdapter *adapter, gboolean at_eos,
|
||||
guint *got_unit_size_ptr, gboolean *got_frame_ptr)
|
||||
{
|
||||
GstVaapiParserState * const ps = &decoder->priv->parser_state;
|
||||
GstVaapiDecoderPrivate * const priv = decoder->priv;
|
||||
GstVaapiParserState * const ps = &priv->parser_state;
|
||||
GstVaapiDecoderFrame *frame;
|
||||
GstVaapiDecoderUnit *unit;
|
||||
GstVaapiDecoderStatus status;
|
||||
|
@ -145,7 +146,9 @@ do_parse(GstVaapiDecoder *decoder,
|
|||
|
||||
frame = gst_video_codec_frame_get_user_data(base_frame);
|
||||
if (!frame) {
|
||||
frame = gst_vaapi_decoder_frame_new();
|
||||
GstVideoCodecState * const codec_state = priv->codec_state;
|
||||
frame = gst_vaapi_decoder_frame_new(codec_state->info.width,
|
||||
codec_state->info.height);
|
||||
if (!frame)
|
||||
return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;
|
||||
gst_video_codec_frame_set_user_data(base_frame,
|
||||
|
|
|
@ -66,24 +66,31 @@ free_units(GArray **units_ptr)
|
|||
|
||||
/**
|
||||
* gst_vaapi_decoder_frame_new:
|
||||
* @width: frame width in pixels
|
||||
* @height: frame height in pixels
|
||||
*
|
||||
* Creates a new #GstVaapiDecoderFrame object.
|
||||
*
|
||||
* Returns: The newly allocated #GstVaapiDecoderFrame
|
||||
*/
|
||||
GstVaapiDecoderFrame *
|
||||
gst_vaapi_decoder_frame_new(void)
|
||||
gst_vaapi_decoder_frame_new(guint width, guint height)
|
||||
{
|
||||
GstVaapiDecoderFrame *frame;
|
||||
guint num_slices;
|
||||
|
||||
frame = (GstVaapiDecoderFrame *)
|
||||
gst_vaapi_mini_object_new(gst_vaapi_decoder_frame_class());
|
||||
if (!frame)
|
||||
return NULL;
|
||||
|
||||
if (!alloc_units(&frame->pre_units, 4))
|
||||
if (!height)
|
||||
height = 1088;
|
||||
num_slices = (height + 15) / 16;
|
||||
|
||||
if (!alloc_units(&frame->pre_units, 16))
|
||||
goto error;
|
||||
if (!alloc_units(&frame->units, 1))
|
||||
if (!alloc_units(&frame->units, num_slices))
|
||||
goto error;
|
||||
if (!alloc_units(&frame->post_units, 1))
|
||||
goto error;
|
||||
|
|
|
@ -76,7 +76,7 @@ struct _GstVaapiDecoderFrame {
|
|||
|
||||
G_GNUC_INTERNAL
|
||||
GstVaapiDecoderFrame *
|
||||
gst_vaapi_decoder_frame_new(void);
|
||||
gst_vaapi_decoder_frame_new(guint width, guint height);
|
||||
|
||||
G_GNUC_INTERNAL
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue