opengl gpuimage 对yuv数据模糊处理

猿说编程 2017-03-01 04:11:00
void main()
{
vec4 textureColor;
vec4 outColor;
vec4 U;
vec4 V;

if(PixFormat == 1000.0f)
{
//RGB32
textureColor = vec4(texture2D(textureUniformRGBA,textureCoordinate));
textureColor.a = textureColor.a*RGB_Alpha;
}
else
{
//YUV420 TO RGB32
textureColor = vec4((texture2D(textureUniformY, textureCoordinate).r - 16./255.) * 1.164);
U = vec4(texture2D(textureUniformU, textureCoordinate).r - 128./255.);
V = vec4(texture2D(textureUniformV, textureCoordinate).r - 128./255.);
textureColor += V * vec4(1.596, -0.813, 0, 0);
textureColor += U * vec4(0, -0.392, 2.017, 0);
textureColor.a = RGB_Alpha;
}
if(1 == dark)
{
float brightness = 0.45f;
//模糊


vec2 firstOffset = vec2(1.3846153846 * texelWidthOffset, 1.3846153846 * texelHeightOffset) * blurSize;
vec2 secondOffset = vec2(3.2307692308 * texelWidthOffset, 3.2307692308 * texelHeightOffset) * blurSize;

centerTextureCoordinate = textureCoordinate;
oneStepLeftTextureCoordinate = textureCoordinate - firstOffset;
twoStepsLeftTextureCoordinate = textureCoordinate - secondOffset;
oneStepRightTextureCoordinate = textureCoordinate + firstOffset;
twoStepsRightTextureCoordinate = textureCoordinate + secondOffset;

vec4 fragmentColor = texture2D(textureUniformRGBA, centerTextureCoordinate) * 0.2270270270;
fragmentColor += texture2D(textureUniformRGBA, oneStepLeftTextureCoordinate) * 0.3162162162;
fragmentColor += texture2D(textureUniformRGBA, oneStepRightTextureCoordinate) * 0.3162162162;
fragmentColor += texture2D(textureUniformRGBA, twoStepsLeftTextureCoordinate) * 0.0702702703;/
fragmentColor += texture2D(textureUniformRGBA, twoStepsRightTextureCoordinate) * 0.0702702703;

//加暗
textureColor = vec4((fragmentColor.rgb * vec3(brightness)), fragmentColor.a);
//最后画面
gl_FragColor = textureColor;

}



目前的问题就是:如果输入数据是rgb32的话,使用这个脚本正常,如果输入数据是yuv的话,没办法使用这个脚本做模糊处理,主要是不知道yuv转换后的textureColor ,怎么做模糊的那部分处理,能直接在这个脚本上修改吗?


我现在的做法的:如果输入数据是yuv,我先转为rgb32后,在作为参数传入到shader脚本,如果是1080P的视频,我每帧画面都需要先转换为rgb32后在使用opengl 绘制,效率低了点。
...全文
954 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
wzw88486969 2017-12-13
  • 打赏
  • 举报
回复
自己解决了,是怎么解决的呢,,,把分给你自己了?
猿说编程 2017-03-30
  • 打赏
  • 举报
回复
自己已经解决
rightorwrong 2017-03-02
  • 打赏
  • 举报
回复
opengl能处理yuv吗 或者看能不能找到需要处理的yuv数据

2,543

社区成员

发帖
与我相关
我的任务
社区描述
专题开发/技术/项目 多媒体/流媒体开发
社区管理员
  • 多媒体/流媒体开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧