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:
Víctor Manuel Jáquez Leal 2016-03-31 15:31:31 +02:00
parent 052fe11949
commit b4a695cd11
4 changed files with 15 additions and 4 deletions

View file

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

View file

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

View file

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

View file

@ -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];
};
/**