tests: add support for GStreamer 1.0.

This commit is contained in:
Gwenole Beauchesne 2013-03-21 10:12:09 +01:00
parent 51151e7aa1
commit 13ca9f382c
5 changed files with 39 additions and 11 deletions

View file

@ -49,6 +49,15 @@ gst_compat_structure_get_fourcc(const GstStructure *structure,
return TRUE;
}
/* GstTypeFind */
#undef GstTypeFindPeekFunction
#define GstTypeFindPeekFunction GstCompatTypeFindPeekFunction
#undef GstTypeFindSuggestFunction
#define GstTypeFindSuggestFunction GstCompatTypeFindSuggestFunction
typedef const guint8 *(*GstCompatTypeFindPeekFunction)(gpointer, gint64, guint);
typedef void (*GstCompatTypeFindSuggestFunction)(gpointer, guint, GstCaps *);
/* ------------------------------------------------------------------------ */
/* --- GStreamer = 0.10 --- */
/* ------------------------------------------------------------------------ */

View file

@ -41,7 +41,7 @@ static const CodecMap g_codec_map[] = {
{ "wmv3", GST_VAAPI_CODEC_VC1,
"video/x-wmv, wmvversion=3" },
{ "vc1", GST_VAAPI_CODEC_VC1,
"video/x-wmv, wmvversion=3, format=(fourcc)WVC1" },
"video/x-wmv, wmvversion=3, format=(string)WVC1" },
{ NULL, }
};

View file

@ -151,15 +151,14 @@ decoder_put_buffers(GstVaapiDecoder *decoder)
codec = get_codec_defs(decoder);
g_return_val_if_fail(codec != NULL, FALSE);
buffer = gst_buffer_new();
codec->get_video_info(&info);
buffer = gst_buffer_new_wrapped_full(GST_MEMORY_FLAG_READONLY,
(guchar *)info.data, info.data_size, 0, info.data_size, NULL, NULL);
if (!buffer) {
GST_ERROR("failed to create encoded data buffer");
return FALSE;
}
codec->get_video_info(&info);
gst_buffer_set_data(buffer, (guchar *)info.data, info.data_size);
success = gst_vaapi_decoder_put_buffer(decoder, buffer);
gst_buffer_unref(buffer);
if (!success) {

View file

@ -251,13 +251,12 @@ decoder_thread(gpointer data)
if (G_UNLIKELY(ofs == app->file_size))
buffer = NULL;
else {
buffer = gst_buffer_new();
const gsize size = MIN(4096, app->file_size - ofs);
buffer = gst_buffer_new_wrapped_full(GST_MEMORY_FLAG_READONLY,
app->file_data, app->file_size, ofs, size, NULL, NULL);
if (!buffer)
SEND_ERROR("failed to allocate new buffer");
GST_BUFFER_DATA(buffer) = app->file_data + ofs;
GST_BUFFER_SIZE(buffer) = MIN(4096, app->file_size - ofs);
ofs += GST_BUFFER_SIZE(buffer);
ofs += size;
}
if (!gst_vaapi_decoder_put_buffer(app->decoder, buffer))
SEND_ERROR("failed to push buffer to decoder");

View file

@ -53,15 +53,22 @@ static GOptionEntry g_options[] = {
static void
upload_subpicture(GstBuffer *buffer, const VideoSubpictureInfo *subinfo)
{
guint32 * const dst = (guint32 *)GST_BUFFER_DATA(buffer);
const guint32 * const src = subinfo->data;
guint i, len = subinfo->data_size / 4;
GstMapInfo map_info;
guint32 *dst;
if (!gst_buffer_map(buffer, &map_info, GST_MAP_WRITE))
return;
dst = (guint32 *)map_info.data;
/* Convert from RGBA source to ARGB */
for (i = 0; i < len; i++) {
const guint32 rgba = src[i];
dst[i] = (rgba >> 8) | (rgba << 24);
}
gst_buffer_unmap(buffer, &map_info);
}
int
@ -120,9 +127,23 @@ main(int argc, char *argv[])
subrect.height = subinfo.height;
subrect.width = subinfo.width;
#if GST_CHECK_VERSION(1,0,0)
{
GstVideoMeta * const vmeta =
gst_buffer_add_video_meta(buffer, GST_VIDEO_FRAME_FLAG_NONE,
GST_VIDEO_OVERLAY_COMPOSITION_FORMAT_RGB,
subinfo.width, subinfo.height);
if (!vmeta)
g_error("could not create video meta");
overlay = gst_video_overlay_rectangle_new_raw(buffer,
subrect.x, subrect.y, subrect.width, subrect.height, flags);
}
#else
overlay = gst_video_overlay_rectangle_new_argb(buffer,
subinfo.width, subinfo.height, subinfo.width * 4,
subrect.x, subrect.y, subrect.width, subrect.height, flags);
#endif
if (!overlay)
g_error("could not create video overlay");
gst_buffer_unref(buffer);