opengl gpuimage 对yuv数据模糊处理

猿说编程 猿说编程 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
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 绘制,效率低了点。
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部