Gstreamer播放教程5: Color Balance

本文档详细介绍了如何在GStreamer中使用色彩平衡接口,包括查找和改变色彩平衡通道,以及通过gst_color_balance_list_channels(), gst_color_balance_get_value()和gst_color_balance_set_value()等函数进行操作。" 117270789,10559174,C++实现医生值班排班系统,"['C++编程', '算法', '逻辑编程']
摘要由CSDN通过智能技术生成

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 */
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值