summaryrefslogtreecommitdiff
path: root/tests/simple-decoder.c
diff options
context:
space:
mode:
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>2013-01-15 18:49:28 +0100
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>2013-01-17 19:04:13 +0100
commit7b4dadc8ae0ee9a8b0ec531264a4348ee646c6b4 (patch)
treef8a289a9e290ca810cbd4eca380df4ce9b436653 /tests/simple-decoder.c
parentc094fe303849a384d6761c512c235e1e04a33a2d (diff)
downloadgst-vaapi-7b4dadc8ae0ee9a8b0ec531264a4348ee646c6b4.tar.gz
tests: simple-decoder: set window size to the surface dimensions.
Set the window size to the decoded surface dimensions, if the user has not requested the application to run in full-screen mode. Besides, no effort is made to preserve aspect ratio or to center the video within the mapped window.
Diffstat (limited to 'tests/simple-decoder.c')
-rw-r--r--tests/simple-decoder.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/tests/simple-decoder.c b/tests/simple-decoder.c
index 76d4c395..d01ae42f 100644
--- a/tests/simple-decoder.c
+++ b/tests/simple-decoder.c
@@ -74,8 +74,11 @@ typedef struct {
GCond decoder_ready;
GAsyncQueue *decoder_queue;
GstVaapiCodec codec;
- GstVideoCodecState codec_state;
+ guint surface_width;
+ guint surface_height;
GstVaapiWindow *window;
+ guint window_width;
+ guint window_height;
GThread *render_thread;
volatile gboolean render_thread_cancel;
GstBuffer *last_buffer;
@@ -324,6 +327,25 @@ stop_decoder(App *app)
return TRUE;
}
+static void
+ensure_window_size(App *app, GstVaapiSurface *surface)
+{
+ guint width, height;
+
+ if (gst_vaapi_window_get_fullscreen(app->window))
+ return;
+
+ gst_vaapi_surface_get_size(surface, &width, &height);
+ if (app->surface_width == width && app->surface_height == height)
+ return;
+ app->surface_width = width;
+ app->surface_height = height;
+
+ gst_vaapi_window_set_size(app->window, width, height);
+ gst_vaapi_window_get_size(app->window,
+ &app->window_width, &app->window_height);
+}
+
static gboolean
renderer_process(App *app, GstBuffer *buffer)
{
@@ -345,6 +367,8 @@ renderer_process(App *app, GstBuffer *buffer)
if (!surface)
SEND_ERROR("failed to get decoded surface from video meta");
+ ensure_window_size(app, surface);
+
if (!gst_vaapi_window_put_surface(app->window, surface, NULL, NULL,
GST_VAAPI_PICTURE_STRUCTURE_FRAME))
SEND_ERROR("failed to render surface %" GST_VAAPI_ID_FORMAT,
@@ -453,6 +477,9 @@ app_new(void)
g_cond_init(&app->event_cond);
g_cond_init(&app->decoder_ready);
+ app->window_width = 640;
+ app->window_height = 480;
+
app->decoder_queue = g_async_queue_new_full(
(GDestroyNotify)gst_buffer_unref);
if (!app->decoder_queue)
@@ -533,7 +560,8 @@ app_run(App *app, int argc, char *argv[])
return FALSE;
}
- app->window = video_output_create_window(app->display, 640, 480);
+ app->window = video_output_create_window(app->display,
+ app->window_width, app->window_height);
if (!app->window) {
g_message("failed to create window");
return FALSE;