mirror of
https://github.com/mpv-player/mpv
synced 2025-01-03 13:32:16 +00:00
Implement OpenGL-based YUV to RGB version for Radeon 9200 class
cards on OS X. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30993 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
c7cdd996f5
commit
269b96d75e
@ -808,6 +808,37 @@ static void glSetupYUVCombinersATI(float uvcos, float uvsin) {
|
||||
mpglEndFragmentShader();
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Variant of glYUVSetupCombinersATI using the API
|
||||
* implemented by Apple.
|
||||
*/
|
||||
static void glSetupYUVTextFragment(float uvcos, float uvsin) {
|
||||
static const char template[] =
|
||||
"!!ATIfs1.0\n"
|
||||
"StartConstants;\n"
|
||||
" CONSTANT c0 = {%f, %f, %f};\n"
|
||||
" CONSTANT c1 = {%f, %f, %f};\n"
|
||||
"EndConstants;\n"
|
||||
"StartOutputPass;\n"
|
||||
" SampleMap r0, t0.str;\n"
|
||||
" SampleMap r1, t1.str;\n"
|
||||
" SampleMap r2, t2.str;\n"
|
||||
" MUL r1, r1.bias, c0.bias;\n"
|
||||
" MAD r2.4x, r2.bias, c1.bias, r1;\n"
|
||||
" ADD r0, r0, r2;\n"
|
||||
"EndPass;\n";
|
||||
GLfloat ucoef[4];
|
||||
GLfloat vcoef[4];
|
||||
char buffer[512];
|
||||
|
||||
fillUVcoeff(ucoef, vcoef, uvcos, uvsin);
|
||||
snprintf(buffer, sizeof(buffer), template,
|
||||
ucoef[0], ucoef[1], ucoef[2],
|
||||
vcoef[0], vcoef[1], vcoef[2]);
|
||||
mp_msg(MSGT_VO, MSGL_DBG2, "[gl] generated fragment program:\n%s\n", buffer);
|
||||
loadGPUProgram(GL_TEXT_FRAGMENT_SHADER_ATI, buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief helper function for gen_spline_lookup_tex
|
||||
* \param x subpixel-position ((0,1) range) to calculate weights for
|
||||
@ -1346,6 +1377,9 @@ void glSetupYUVConversion(gl_conversion_params_t *params) {
|
||||
case YUV_CONVERSION_COMBINERS_ATI:
|
||||
glSetupYUVCombinersATI(uvcos, uvsin);
|
||||
break;
|
||||
case YUV_CONVERSION_TEXT_FRAGMENT:
|
||||
glSetupYUVTextFragment(uvcos, uvsin);
|
||||
break;
|
||||
case YUV_CONVERSION_FRAGMENT_LOOKUP:
|
||||
case YUV_CONVERSION_FRAGMENT_LOOKUP3D:
|
||||
case YUV_CONVERSION_FRAGMENT:
|
||||
@ -1383,6 +1417,14 @@ void glEnableYUVConversion(GLenum target, int type) {
|
||||
mpglActiveTexture(GL_TEXTURE0);
|
||||
mpglEnable(GL_FRAGMENT_SHADER_ATI);
|
||||
break;
|
||||
case YUV_CONVERSION_TEXT_FRAGMENT:
|
||||
mpglActiveTexture(GL_TEXTURE1);
|
||||
mpglEnable(target);
|
||||
mpglActiveTexture(GL_TEXTURE2);
|
||||
mpglEnable(target);
|
||||
mpglActiveTexture(GL_TEXTURE0);
|
||||
mpglEnable(GL_TEXT_FRAGMENT_SHADER_ATI);
|
||||
break;
|
||||
case YUV_CONVERSION_FRAGMENT_LOOKUP3D:
|
||||
case YUV_CONVERSION_FRAGMENT_LOOKUP:
|
||||
case YUV_CONVERSION_FRAGMENT_POW:
|
||||
@ -1417,6 +1459,14 @@ void glDisableYUVConversion(GLenum target, int type) {
|
||||
mpglActiveTexture(GL_TEXTURE0);
|
||||
mpglDisable(GL_FRAGMENT_SHADER_ATI);
|
||||
break;
|
||||
case YUV_CONVERSION_TEXT_FRAGMENT:
|
||||
mpglActiveTexture(GL_TEXTURE1);
|
||||
mpglDisable(target);
|
||||
mpglActiveTexture(GL_TEXTURE2);
|
||||
mpglDisable(target);
|
||||
mpglActiveTexture(GL_TEXTURE0);
|
||||
mpglDisable(GL_TEXT_FRAGMENT_SHADER_ATI);
|
||||
break;
|
||||
case YUV_CONVERSION_FRAGMENT_LOOKUP3D:
|
||||
case YUV_CONVERSION_FRAGMENT_LOOKUP:
|
||||
case YUV_CONVERSION_FRAGMENT_POW:
|
||||
|
@ -71,6 +71,9 @@
|
||||
#ifndef GL_GENERATE_MIPMAP
|
||||
#define GL_GENERATE_MIPMAP 0x8191
|
||||
#endif
|
||||
#ifndef GL_TEXT_FRAGMENT_SHADER_ATI
|
||||
#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200
|
||||
#endif
|
||||
#ifndef GL_REGISTER_COMBINERS_NV
|
||||
#define GL_REGISTER_COMBINERS_NV 0x8522
|
||||
#endif
|
||||
@ -303,6 +306,8 @@ int loadGPUProgram(GLenum target, char *prog);
|
||||
#define YUV_CONVERSION_COMBINERS_ATI 5
|
||||
//! use a fragment program with 3D table lookup for YUV conversion
|
||||
#define YUV_CONVERSION_FRAGMENT_LOOKUP3D 6
|
||||
//! use ATI specific "text" register combiners ("fragment program")
|
||||
#define YUV_CONVERSION_TEXT_FRAGMENT 7
|
||||
//! use normal bilinear scaling for textures
|
||||
#define YUV_SCALER_BILIN 0
|
||||
//! use higher quality bicubic scaling for textures
|
||||
|
Loading…
Reference in New Issue
Block a user