More simplifications.

This commit is contained in:
gb 2010-05-03 21:14:01 +00:00 committed by Gwenole Beauchesne
parent 73766f9466
commit 09552b1559
2 changed files with 22 additions and 46 deletions

View file

@ -38,13 +38,6 @@
G_DEFINE_TYPE(GstVaapiDecoder, gst_vaapi_decoder, G_TYPE_OBJECT); G_DEFINE_TYPE(GstVaapiDecoder, gst_vaapi_decoder, G_TYPE_OBJECT);
/* XXX: Make it a GstVaapiDecodedSurface? */
typedef struct _DecodedSurface DecodedSurface;
struct _DecodedSurface {
GstVaapiSurfaceProxy *proxy;
GstVaapiDecoderStatus status;
};
enum { enum {
PROP_0, PROP_0,
@ -140,18 +133,6 @@ decode_step(GstVaapiDecoder *decoder)
return status; return status;
} }
static inline DecodedSurface *
create_surface(void)
{
return g_slice_new0(DecodedSurface);
}
static inline void
destroy_surface(DecodedSurface *ds)
{
g_slice_free(DecodedSurface, ds);
}
static gboolean static gboolean
push_surface( push_surface(
GstVaapiDecoder *decoder, GstVaapiDecoder *decoder,
@ -160,27 +141,21 @@ push_surface(
) )
{ {
GstVaapiDecoderPrivate * const priv = decoder->priv; GstVaapiDecoderPrivate * const priv = decoder->priv;
DecodedSurface *ds; GstVaapiSurfaceProxy *proxy;
ds = create_surface();
if (!ds)
return FALSE;
GST_DEBUG("queue decoded surface %" GST_VAAPI_ID_FORMAT, GST_DEBUG("queue decoded surface %" GST_VAAPI_ID_FORMAT,
GST_VAAPI_ID_ARGS(GST_VAAPI_OBJECT_ID(surface))); GST_VAAPI_ID_ARGS(GST_VAAPI_OBJECT_ID(surface)));
ds->proxy = gst_vaapi_surface_proxy_new(priv->context, surface);
if (ds->proxy) {
ds->status = GST_VAAPI_DECODER_STATUS_SUCCESS;
gst_vaapi_surface_proxy_set_timestamp(ds->proxy, timestamp);
}
else
ds->status = GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;
g_queue_push_tail(priv->surfaces, ds); proxy = gst_vaapi_surface_proxy_new(priv->context, surface);
if (!proxy)
return FALSE;
gst_vaapi_surface_proxy_set_timestamp(proxy, timestamp);
g_queue_push_tail(priv->surfaces, proxy);
return TRUE; return TRUE;
} }
static inline DecodedSurface * static inline GstVaapiSurfaceProxy *
pop_surface(GstVaapiDecoder *decoder) pop_surface(GstVaapiDecoder *decoder)
{ {
GstVaapiDecoderPrivate * const priv = decoder->priv; GstVaapiDecoderPrivate * const priv = decoder->priv;
@ -229,7 +204,7 @@ gst_vaapi_decoder_finalize(GObject *object)
} }
if (priv->surfaces) { if (priv->surfaces) {
clear_queue(priv->surfaces, (GDestroyNotify)destroy_surface); clear_queue(priv->surfaces, (GDestroyNotify)g_object_unref);
g_queue_free(priv->surfaces); g_queue_free(priv->surfaces);
priv->surfaces = NULL; priv->surfaces = NULL;
} }
@ -423,25 +398,24 @@ gst_vaapi_decoder_get_surface(
GstVaapiDecoderStatus *pstatus GstVaapiDecoderStatus *pstatus
) )
{ {
GstVaapiSurfaceProxy *proxy = NULL; GstVaapiSurfaceProxy *proxy;
GstVaapiDecoderStatus status = GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA; GstVaapiDecoderStatus status;
DecodedSurface *ds;
if (pstatus)
*pstatus = GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN;
g_return_val_if_fail(GST_VAAPI_IS_DECODER(decoder), NULL); g_return_val_if_fail(GST_VAAPI_IS_DECODER(decoder), NULL);
ds = pop_surface(decoder); proxy = pop_surface(decoder);
if (!ds) { if (!proxy) {
do { do {
status = decode_step(decoder); status = decode_step(decoder);
} while (status == GST_VAAPI_DECODER_STATUS_SUCCESS); } while (status == GST_VAAPI_DECODER_STATUS_SUCCESS);
ds = pop_surface(decoder); proxy = pop_surface(decoder);
} }
if (ds) { if (proxy)
proxy = ds->proxy; status = GST_VAAPI_DECODER_STATUS_SUCCESS;
status = ds->status;
destroy_surface(ds);
}
if (pstatus) if (pstatus)
*pstatus = status; *pstatus = status;

View file

@ -472,7 +472,9 @@ decode_frame(GstVaapiDecoderFfmpeg *ffdecoder, guchar *buf, guint buf_size)
if (!surface) if (!surface)
return GST_VAAPI_DECODER_STATUS_ERROR_INVALID_SURFACE; return GST_VAAPI_DECODER_STATUS_ERROR_INVALID_SURFACE;
gst_vaapi_decoder_push_surface(GST_VAAPI_DECODER_CAST(ffdecoder), surface, priv->frame->pts); if (!gst_vaapi_decoder_push_surface(GST_VAAPI_DECODER_CAST(ffdecoder),
surface, priv->frame->pts))
return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;
return GST_VAAPI_DECODER_STATUS_SUCCESS; return GST_VAAPI_DECODER_STATUS_SUCCESS;
} }