文章目录
1. Goal
亮度、对比度、色相和饱和度是常见的视频调整,它们在GStreamer中统称为色彩平衡设置。本教程展示了:
- 如何找到可用的色彩平衡通道
- 如何改变它们
2. Introduction
Basic tutorial 5: GUI toolkit integration 已经解释了GObject接口的概念:应用程序使用它们来确定某些功能是否可用,而不考虑
实现该功能的实际元素。
playbin实现了色彩平衡界面(GstColorBalance),它允许访问色彩平衡设置。如果playbin pipeline中的任何元素都支持这个接口,playbin只需将其转发给应用程序,否则,就会在pipeline中插入色彩平衡元素。
这个接口允许查询可用的颜色平衡通道(GstColorBalanceChannel),以及它们的名称和有效值范围,然后修改其中任何一个的当前值。
3. Color balance example
3.1 code
#include <string.h>
#include <stdio.h>
#include <gst/gst.h>
#include <gst/video/colorbalance.h>
typedef struct _CustomData {
GstElement *pipeline;
GMainLoop *loop;
} CustomData;
/* Process a color balance command */
static void update_color_channel (const gchar *channel_name, gboolean increase, GstColorBalance *cb) {
gdouble step;
gint value;
GstColorBalanceChannel *channel = NULL;
const GList *channels, *l;
/* Retrieve the list of channels and locate the requested one */
channels = gst_color_balance_list_channels (cb);
for (l = channels; l != NULL; l = l->next) {
GstColorBalanceChannel *tmp = (GstColorBalanceChannel *)l->data;
if (g_strrstr (tmp->label, channel_name)) {
channel = tmp;
break;
}
}
if (!channel)
return;
/* Change the channel's value */
step = 0.1 * (channel->max_value - channel->min_value);
value = gst_color_balance_get_value (cb, channel);
if (increase) {
value = (gint)(value + step);
if (value > channel->max_value)
value = channel->max_value;
} else {
value = (gint)(value - step);
if (value < channel->min_value)
value = channel->min_value;
}
gst_color_balance_set_value (cb, channel, value);
}
/* Output the current values of all Color Balance channels */