]> git.sesse.net Git - casparcg/commitdiff
2.1.0: image_shader: Fixed YUV -> BGRA.
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Wed, 15 Feb 2012 22:44:07 +0000 (22:44 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Wed, 15 Feb 2012 22:44:07 +0000 (22:44 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.1.0@2424 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

accelerator/ogl/image/image_shader.cpp

index d5c3a51883b3853043c4df43e8b36c51b6b4658b..1e78424338d1041c24cb9fdf6343ce46e1d002d9 100644 (file)
@@ -165,50 +165,25 @@ std::string get_fragment(bool blend_modes)
        +\r
        \r
        "                                                                                                                                                                       \n"\r
-       "//http://slouken.blogspot.com/2011/02/mpeg-acceleration-with-glsl.html                         \n"\r
-       "vec4 ycbcra_to_rgba_sd(float y, float cb, float cr, float a)                                           \n"\r
+       "vec4 ycbcra_to_rgba_sd(float Y, float Cb, float Cr, float A)                                           \n"\r
        "{                                                                                                                                                                      \n"\r
-       "       // YUV offset                                                                                                                                   \n"\r
-       "       const vec3 offset = vec3(-0.0625, -0.5, -0.5);                                                                  \n"\r
-       "                                                                                                                                                                       \n"\r
-       "       // RGB coefficients                                                                                                                     \n"\r
-       "       const vec3 Rcoeff = vec3(1.164,  0.000,  1.596);                                                                \n"\r
-       "       const vec3 Gcoeff = vec3(1.164, -0.391, -0.813);                                                                \n"\r
-       "       const vec3 Bcoeff = vec3(1.164,  2.018,  0.000);                                                                \n"\r
-       "                                                                                                                                                                       \n"\r
-       "       vec3 yuv = vec3(y, cr, cb);                                                                                                             \n"\r
        "   vec4 rgba;                                                                                                                                          \n"\r
-       "                                                                                                                                                                       \n"\r
-       "       yuv += offset;                                                                                                                                  \n"\r
-       "       rgba.r = dot(yuv, Rcoeff);                                                                                                              \n"\r
-       "       rgba.g = dot(yuv, Gcoeff);                                                                                                              \n"\r
-       "       rgba.b = dot(yuv, Bcoeff);                                                                                                              \n"\r
-       "       rgba.a = a;                                                                                                                                             \n"\r
-       "                                                                                                                                                                       \n"\r
-       "       return rgba;                                                                                                                                    \n"\r
+       "   rgba.b = (1.164*(Y*255 - 16) + 1.596*(Cr*255 - 128))/255;                                           \n"\r
+       "   rgba.g = (1.164*(Y*255 - 16) - 0.813*(Cr*255 - 128) - 0.391*(Cb*255 - 128))/255;\n"\r
+       "   rgba.r = (1.164*(Y*255 - 16) + 2.018*(Cb*255 - 128))/255;                                           \n"\r
+       "   rgba.a = A;                                                                                                                                         \n"\r
+       "       return rgba;                                                                                                                                    \n"     \r
        "}                                                                                                                                                                      \n"                     \r
        "                                                                                                                                                                       \n"\r
-       "vec4 ycbcra_to_rgba_hd(float y, float cb, float cr, float a)                                           \n"\r
+       "vec4 ycbcra_to_rgba_hd(float Y, float Cb, float Cr, float A)                                           \n"\r
        "{                                                                                                                                                                      \n"\r
-       "       // YUV offset                                                                                                                                   \n"\r
-       "       const vec3 offset = vec3(-0.0625, -0.5, -0.5);                                                                  \n"\r
-       "                                                                                                                                                                       \n"\r
-       "       // RGB coefficients                                                                                                                     \n"\r
-       "       const vec3 Rcoeff = vec3(1.164,  0.000,  1.793);                                                                \n"\r
-       "       const vec3 Gcoeff = vec3(1.164, -0.213, -0.534);                                                                \n"\r
-       "       const vec3 Bcoeff = vec3(1.164,  2.115,  0.000);                                                                \n"\r
-       "                                                                                                                                                                       \n"\r
-       "       vec3 yuv = vec3(y, cr, cb);                                                                                                             \n"\r
        "   vec4 rgba;                                                                                                                                          \n"\r
-       "                                                                                                                                                                       \n"\r
-       "       yuv += offset;                                                                                                                                  \n"\r
-       "       rgba.r = dot(yuv, Rcoeff);                                                                                                              \n"\r
-       "       rgba.g = dot(yuv, Gcoeff);                                                                                                              \n"\r
-       "       rgba.b = dot(yuv, Bcoeff);                                                                                                              \n"\r
-       "       rgba.a = a;                                                                                                                                             \n"\r
-       "                                                                                                                                                                       \n"\r
+       "   rgba.b = (1.164*(Y*255 - 16) + 1.793*(Cr*255 - 128))/255;                                           \n"\r
+       "   rgba.g = (1.164*(Y*255 - 16) - 0.534*(Cr*255 - 128) - 0.213*(Cb*255 - 128))/255;\n"\r
+       "   rgba.r = (1.164*(Y*255 - 16) + 2.115*(Cb*255 - 128))/255;                                           \n"\r
+       "   rgba.a = A;                                                                                                                                         \n"\r
        "       return rgba;                                                                                                                                    \n"\r
-       "}                                                                                                                                                                      \n"                     \r
+       "}                                                                                                                                                                      \n"                                     \r
        "                                                                                                                                                                       \n"             \r
        "vec4 ycbcra_to_rgba(float y, float cb, float cr, float a)                                                      \n"\r
        "{                                                                                                                                                                      \n"\r