1 /* GStreamer interactive videoscale test
2 * Copyright (C) 2008 Wim Taymans <wim.taymans@gmail.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
28 #define CAPS " capsfilter caps=\"video/x-raw-yuv, format=(fourcc)I420, width=(int)640, height=(int)480\" "
31 make_pipeline (gint type)
39 g_strdup_printf ("videotestsrc ! " CAPS
40 " ! videobox name=box ! videoscale ! " CAPS
41 " ! ffmpegcolorspace ! ximagesink");
47 result = gst_parse_launch_full (pstr, NULL, GST_PARSE_FLAG_NONE, NULL);
48 g_print ("created test %d: \"%s\"\n", type, pstr);
57 main (int argc, char **argv)
59 GstElement *pipe, *filter;
64 gint round, type, stop;
66 gst_init (&argc, &argv);
72 type = atoi (argv[1]);
79 pipe = make_pipeline (type);
83 filter = gst_bin_get_by_name (GST_BIN (pipe), "box");
86 /* start with no borders or cropping */
87 left = right = top = bottom = 0;
88 rdir = ldir = tdir = bdir = -10;
90 for (round = 0; round < MAX_ROUND; round++) {
91 g_print ("box to %dx%d %dx%d (%d/%d) \r", left, right, top, bottom,
94 g_object_set (filter, "left", left, "right", right, "top", top, "bottom",
98 gst_element_set_state (pipe, GST_STATE_PLAYING);
109 else if (right < -20)
121 else if (bottom < -40)
125 gst_bus_poll (GST_ELEMENT_BUS (pipe), GST_MESSAGE_ERROR,
128 g_print ("got error \n");
130 gst_message_unref (message);
133 g_print ("test %d done \n", type);
135 gst_object_unref (filter);
136 gst_element_set_state (pipe, GST_STATE_NULL);
137 gst_object_unref (pipe);