mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
libs: video: split allocation query caos and pad caps
Since the allocation query caps contains memory size and the pad's caps contains the display size, a video encoder or decoder might need to allocate a different frame size than the size negotiated in the caps. This patch splits this logic distinction for videodecoder and videoencoder. The user if needs a different allocation caps, should set the allocation_caps in the GstVideoCodecState before calling negotiate() vmethod. Otherwise the allocation_caps will be the same as the caps set in the src pad. https://bugzilla.gnome.org/show_bug.cgi?id=764421
This commit is contained in:
parent
052fe11949
commit
b4a695cd11
4 changed files with 15 additions and 4 deletions
|
@ -3797,6 +3797,8 @@ gst_video_decoder_negotiate_default (GstVideoDecoder * decoder)
|
|||
|
||||
if (state->caps == NULL)
|
||||
state->caps = gst_video_info_to_caps (&state->info);
|
||||
if (state->allocation_caps == NULL)
|
||||
state->allocation_caps = gst_caps_ref (state->caps);
|
||||
|
||||
GST_DEBUG_OBJECT (decoder, "setting caps %" GST_PTR_FORMAT, state->caps);
|
||||
|
||||
|
@ -3845,7 +3847,7 @@ gst_video_decoder_negotiate_default (GstVideoDecoder * decoder)
|
|||
goto done;
|
||||
decoder->priv->output_state_changed = FALSE;
|
||||
/* Negotiate pool */
|
||||
ret = gst_video_decoder_negotiate_pool (decoder, state->caps);
|
||||
ret = gst_video_decoder_negotiate_pool (decoder, state->allocation_caps);
|
||||
|
||||
done:
|
||||
return ret;
|
||||
|
|
|
@ -1630,6 +1630,9 @@ gst_video_encoder_negotiate_default (GstVideoEncoder * encoder)
|
|||
encoder->priv->output_state_changed = FALSE;
|
||||
}
|
||||
|
||||
if (state->allocation_caps == NULL)
|
||||
state->allocation_caps = gst_caps_ref (state->caps);
|
||||
|
||||
/* Push all pending pre-caps events of the oldest frame before
|
||||
* setting caps */
|
||||
frame = encoder->priv->frames ? encoder->priv->frames->data : NULL;
|
||||
|
@ -1668,7 +1671,7 @@ gst_video_encoder_negotiate_default (GstVideoEncoder * encoder)
|
|||
if (!ret)
|
||||
goto done;
|
||||
|
||||
query = gst_query_new_allocation (state->caps, TRUE);
|
||||
query = gst_query_new_allocation (state->allocation_caps, TRUE);
|
||||
if (!gst_pad_peer_query (encoder->srcpad, query)) {
|
||||
GST_DEBUG_OBJECT (encoder, "didn't get downstream ALLOCATION hints");
|
||||
}
|
||||
|
|
|
@ -162,6 +162,8 @@ _gst_video_codec_state_free (GstVideoCodecState * state)
|
|||
|
||||
if (state->caps)
|
||||
gst_caps_unref (state->caps);
|
||||
if (state->allocation_caps)
|
||||
gst_caps_unref (state->allocation_caps);
|
||||
if (state->codec_data)
|
||||
gst_buffer_unref (state->codec_data);
|
||||
g_slice_free (GstVideoCodecState, state);
|
||||
|
|
|
@ -41,9 +41,11 @@ typedef struct _GstVideoCodecFrame GstVideoCodecFrame;
|
|||
/**
|
||||
* GstVideoCodecState:
|
||||
* @info: The #GstVideoInfo describing the stream
|
||||
* @caps: The #GstCaps
|
||||
* @caps: The #GstCaps used in the caps negotiation of the pad.
|
||||
* @codec_data: a #GstBuffer corresponding to the
|
||||
* 'codec_data' field of a stream, or NULL.
|
||||
* @allocation_caps: The #GstCaps for allocation query and pool
|
||||
* negotiation. Since: 1.10
|
||||
*
|
||||
* Structure representing the state of an incoming or outgoing video
|
||||
* stream for encoders and decoders.
|
||||
|
@ -67,8 +69,10 @@ struct _GstVideoCodecState
|
|||
|
||||
GstBuffer *codec_data;
|
||||
|
||||
GstCaps *allocation_caps;
|
||||
|
||||
/*< private >*/
|
||||
void *padding[GST_PADDING_LARGE];
|
||||
void *padding[GST_PADDING_LARGE - 1];
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue