From: gb Date: Mon, 3 May 2010 20:55:17 +0000 (+0000) Subject: Simplify GstVaapiDecoder API. X-Git-Tag: 1.19.3~503^2~3456 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=73766f9466d2d1945ce3ed7d442ba9df5e852a0c;p=platform%2Fupstream%2Fgstreamer.git Simplify GstVaapiDecoder API. --- diff --git a/gst-libs/gst/vaapi/gstvaapidecoder.c b/gst-libs/gst/vaapi/gstvaapidecoder.c index 9f44130..3170fde 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder.c @@ -38,7 +38,7 @@ G_DEFINE_TYPE(GstVaapiDecoder, gst_vaapi_decoder, G_TYPE_OBJECT); -/* XXX: Make it a GstVaapiDecodedSurface + propagate PTS */ +/* XXX: Make it a GstVaapiDecodedSurface? */ typedef struct _DecodedSurface DecodedSurface; struct _DecodedSurface { GstVaapiSurfaceProxy *proxy; @@ -78,31 +78,6 @@ create_eos_buffer(void) return buffer; } -static GstBuffer * -create_buffer(const guchar *buf, guint buf_size, gboolean copy) -{ - GstBuffer *buffer; - - if (!buf || !buf_size) - return NULL; - - buffer = gst_buffer_new(); - if (!buffer) - return NULL; - - if (copy) { - buffer->malloc_data = g_malloc(buf_size); - if (!buffer->malloc_data) { - gst_buffer_unref(buffer); - return NULL; - } - memcpy(buffer->malloc_data, buf, buf_size); - buf = buffer->malloc_data; - } - init_buffer(buffer, buf, buf_size); - return buffer; -} - static void destroy_buffer(GstBuffer *buffer) { @@ -411,108 +386,6 @@ gst_vaapi_decoder_init(GstVaapiDecoder *decoder) } /** - * gst_vaapi_decoder_get_frame_rate: - * @decoder: a #GstVaapiDecoder - * @num: return location for the numerator of the frame rate - * @den: return location for the denominator of the frame rate - * - * Retrieves the current frame rate as the fraction @num / @den. The - * default frame rate is 30 fps. - */ -void -gst_vaapi_decoder_get_frame_rate( - GstVaapiDecoder *decoder, - guint *num, - guint *den -) -{ - g_return_if_fail(GST_VAAPI_IS_DECODER(decoder)); - - if (num) - *num = decoder->priv->fps_n; - - if (den) - *den = decoder->priv->fps_d; -} - -/** - * gst_vaapi_decoder_set_frame_rate: - * @decoder: a #GstVaapiDecoder - * @num: the numerator of the frame rate - * @den: the denominator of the frame rate - * - * Sets the frame rate for the stream to @num / @den. By default, the - * decoder will use the frame rate encoded in the elementary stream. - * If none is available, the decoder will default to 30 fps. - */ -void -gst_vaapi_decoder_set_frame_rate( - GstVaapiDecoder *decoder, - guint num, - guint den -) -{ - g_return_if_fail(GST_VAAPI_IS_DECODER(decoder)); - - decoder->priv->fps_n = num; - decoder->priv->fps_d = den; -} - -/** - * gst_vaapi_decoder_put_buffer_data: - * @decoder: a #GstVaapiDecoder - * @buf: pointer to buffer data - * @buf_size: size of buffer data in bytes - * - * Queues @buf_size bytes from the data @buf to the HW decoder. The - * caller is responsible for making sure @buf is live beyond this - * function. So, this function is mostly useful with static data - * buffers. gst_vaapi_decoder_put_buffer_data_copy() does the same but - * copies the data. - * - * Caller can notify an End-Of-Stream with @buf set to %NULL and - * @buf_size set to zero. - * - * Return value: %TRUE on success - */ -gboolean -gst_vaapi_decoder_put_buffer_data( - GstVaapiDecoder *decoder, - const guchar *buf, - guint buf_size -) -{ - g_return_val_if_fail(GST_VAAPI_IS_DECODER(decoder), FALSE); - - return push_buffer(decoder, create_buffer(buf, buf_size, FALSE)); -} - -/** - * gst_vaapi_decoder_put_buffer_data_copy: - * @decoder: a #GstVaapiDecoder - * @buf: pointer to buffer data - * @buf_size: size of buffer data in bytes - * - * Queues a copy of @buf to the HW decoder. - * - * Caller can notify an End-Of-Stream with @buf set to %NULL and - * @buf_size set to zero. - * - * Return value: %TRUE on success - */ -gboolean -gst_vaapi_decoder_put_buffer_data_copy( - GstVaapiDecoder *decoder, - const guchar *buf, - guint buf_size -) -{ - g_return_val_if_fail(GST_VAAPI_IS_DECODER(decoder), FALSE); - - return push_buffer(decoder, create_buffer(buf, buf_size, TRUE)); -} - -/** * gst_vaapi_decoder_put_buffer: * @decoder: a #GstVaapiDecoder * @buf: a #GstBuffer diff --git a/gst-libs/gst/vaapi/gstvaapidecoder.h b/gst-libs/gst/vaapi/gstvaapidecoder.h index 8af5e01..e7bc5ca 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder.h +++ b/gst-libs/gst/vaapi/gstvaapidecoder.h @@ -109,34 +109,6 @@ struct _GstVaapiDecoderClass { GType gst_vaapi_decoder_get_type(void); -void -gst_vaapi_decoder_get_frame_rate( - GstVaapiDecoder *decoder, - guint *num, - guint *den -); - -void -gst_vaapi_decoder_set_frame_rate( - GstVaapiDecoder *decoder, - guint num, - guint den -); - -gboolean -gst_vaapi_decoder_put_buffer_data( - GstVaapiDecoder *decoder, - const guchar *buf, - guint buf_size -); - -gboolean -gst_vaapi_decoder_put_buffer_data_copy( - GstVaapiDecoder *decoder, - const guchar *buf, - guint buf_size -); - gboolean gst_vaapi_decoder_put_buffer(GstVaapiDecoder *decoder, GstBuffer *buf); diff --git a/tests/test-decode.c b/tests/test-decode.c index c5f7f91..e17c229 100644 --- a/tests/test-decode.c +++ b/tests/test-decode.c @@ -82,6 +82,7 @@ main(int argc, char *argv[]) GstStructure *structure; GstVaapiDecoderStatus status; const CodecDefs *codec; + GstBuffer *buffer; GstVaapiSurfaceProxy *proxy; VideoDecodeInfo info; @@ -128,9 +129,17 @@ main(int argc, char *argv[]) decoder = gst_vaapi_decoder_ffmpeg_new_from_caps(display, decoder_caps); if (!decoder) g_error("could not create FFmpeg decoder"); + gst_caps_unref(decoder_caps); + + buffer = gst_buffer_new(); + if (!buffer) + g_error("could not create encoded data buffer"); + gst_buffer_set_data(buffer, (guchar *)info.data, info.data_size); - if (!gst_vaapi_decoder_put_buffer_data(decoder, info.data, info.data_size)) + if (!gst_vaapi_decoder_put_buffer(decoder, buffer)) g_error("could not send video data to the decoder"); + gst_buffer_unref(buffer); + if (!gst_vaapi_decoder_put_buffer(decoder, NULL)) g_error("could not send EOS to the decoder"); @@ -150,7 +159,6 @@ main(int argc, char *argv[]) pause(); g_object_unref(proxy); - gst_caps_unref(decoder_caps); g_object_unref(decoder); g_object_unref(window); g_object_unref(display);