From 13ca9f382cba888c4248956a76d7179f9f953cb5 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Thu, 21 Mar 2013 10:12:09 +0100 Subject: [PATCH] tests: add support for GStreamer 1.0. --- gst-libs/gst/vaapi/gstcompat.h | 9 +++++++++ tests/codec.c | 2 +- tests/decoder.c | 7 +++---- tests/simple-decoder.c | 9 ++++----- tests/test-subpicture.c | 23 ++++++++++++++++++++++- 5 files changed, 39 insertions(+), 11 deletions(-) diff --git a/gst-libs/gst/vaapi/gstcompat.h b/gst-libs/gst/vaapi/gstcompat.h index 1868dc1..9d4d82a 100644 --- a/gst-libs/gst/vaapi/gstcompat.h +++ b/gst-libs/gst/vaapi/gstcompat.h @@ -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 --- */ /* ------------------------------------------------------------------------ */ diff --git a/tests/codec.c b/tests/codec.c index fa690f1..a1dd081 100644 --- a/tests/codec.c +++ b/tests/codec.c @@ -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, } }; diff --git a/tests/decoder.c b/tests/decoder.c index cb918c7..881f0a1 100644 --- a/tests/decoder.c +++ b/tests/decoder.c @@ -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) { diff --git a/tests/simple-decoder.c b/tests/simple-decoder.c index de299b4..04625a6 100644 --- a/tests/simple-decoder.c +++ b/tests/simple-decoder.c @@ -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"); diff --git a/tests/test-subpicture.c b/tests/test-subpicture.c index 2448274..be1ec58 100644 --- a/tests/test-subpicture.c +++ b/tests/test-subpicture.c @@ -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); -- 2.7.4