Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: Fr Jul 18, 2025 04:32

Foren-Übersicht » Programmierung » OpenGL
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 17 Beiträge ]  Gehe zu Seite Vorherige  1, 2
Autor Nachricht
 Betreff des Beitrags:
BeitragVerfasst: Mi Jun 15, 2005 18:14 
Offline
DGL Member
Benutzeravatar

Registriert: Do Dez 05, 2002 10:35
Beiträge: 4234
Wohnort: Dortmund
Ja. Entweder machst du das bevor du die Bilddaten an OpenGL übergibst. Das muss dann sehr Performant sein. Oder du benutzt einen Fragmentshader. Da musst du aber stark aufpassen, dass du nicht die Hardwarelimitierungs sprengst.

Es gibt auch ein Programm welches Shader bereits zum abspielen einsetzt. Der Media Player Classic. Allerdings benutz der dafür Direct3D aber man kann diverse vordefinierte Shader auch noch bearbeiten. Sehr witzige Sache das. Aber sonst ist der Player auch sehr geil. Das aber nur mal am Rande. ;-)


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: So Jun 26, 2005 13:14 
Offline
DGL Member

Registriert: So Jun 26, 2005 13:06
Beiträge: 1
Ich habe mir das Beispiel hier mal angeschaut. Das ist ne schicke Idee ;) Ich war heute mal so frei und wollte die Ausgabe auf YUY2 erweitern und zur Umwandlung auf GL Slang zurückgreifen.

Als Fragment Shader steht bei mir folgendes:

Code:
  1.  
  2. uniform samplerRECT VideoTex;
  3.  
  4. // CCIR 601 standard
  5. //const half3 std601R={  1.164 ,  0     ,  1.4022   }; // from previous definition
  6. const half3 std601R = {  1.1644,  0.0011,  1.5957   };
  7. const half3 std601G = {  1.1644, -0.3913, -0.8130   };
  8. const half3 std601B = {  1.1644,  2.0174,  0.0011   };
  9. const half4 stdbias = { -0.0625,  -0.5  , -0.5, 0   };
  10.  
  11. // CCIR 709 standard (Garry amann)
  12. const half3 std709R = {  1.1644,  0.0008,  1.7932   };
  13. const half3 std709G = {  1.1642, -0.2131,  0.5328   };
  14. const half3 std709B = {  1.1665,  2.1124,  0.0011   };
  15. //const half4 stdbias={ -0.0625, -0.5  , -0.5, 0   };
  16.  
  17. // CCIR 601 extended (Garry Amann)
  18. const half3 ext601R = {  1.0,  0     ,  1.4022   };
  19. const half3 ext601G = {  1.0, -0.3456, -0.7145   };
  20. const half3 ext601B = {  1.0,  1.7710,  0        };
  21. const half4 extbias = {  0,   -0.5   , -0.5, 0   };
  22.  
  23. // CCIR 709 extended (Garry amann)
  24. // const mat3 can be used
  25. const half3 ext709R = {  1.000 ,  0    ,  1.540   };
  26. const half3 ext709G = {  1.000 , -0.183, -0.459   };
  27. const half3 ext709B = {  1.000 ,  1.816,  0       };
  28. //const half4 extbias = { -0.0625, -0.5  , -0.5, 0  };
  29.  
  30. // This does YUY2 to RGB conversion
  31. half4 yuyv_texture_sampler( in samplerRECT  texture,
  32.                             in half2 texcoord)
  33. {
  34.     half4 outColor;
  35.     half4 texColor0;
  36.     half4 texColor1;
  37.     half2 tc0, tc1;
  38.     half isOddUV, texel_sample, texel_offset;
  39.  
  40.     isOddUV = floor(frac(texcoord.x * 0.5) * 2);
  41.     texel_sample = 1.0;
  42.     texel_offset = +0.5;
  43.  
  44.     tc0.x = floor(texcoord.x) - (isOddUV * texel_sample) + texel_offset;
  45.     tc1.x = tc0.x + texel_sample;
  46.  
  47.     texColor0 = texRECT(texture, float2(tc0));
  48.     texColor1 = texRECT(texture, float2(tc1));
  49.    
  50.     // For L8A8, assume Y0Y1<-rgb, U0V0<-alpha
  51.     texColor0.r = texColor0.r; // assign Y0 (1st position) automatic
  52.     texColor0.g = texColor0.a; // assign U0 (2nd position)
  53.     texColor0.b = texColor1.a; // assign V0 (3rd position)
  54.  
  55.     texColor1.r = texColor1.r; // assign Y1 (1st position) automatic
  56.     texColor1.g = texColor0.a; // assign U0 (2nd position)
  57.     texColor1.b = texColor1.a; // assign V0 (3rd position)
  58.  
  59.     // assume RGBA0 (Y0 U0)
  60.     // assume RGBA1 (Y1 V0)
  61.     texColor1 = texColor1 * half4(isOddUV);
  62.  
  63.     // assume RGBA0 (Y0 U0)
  64.     // assume RGBA1 (Y1 V0)
  65.     texColor0 = texColor0 * half4(1-isOddUV);
  66.  
  67.     texColor0 = texColor0 + texColor1 + stdbias;
  68.    
  69.     outColor = half4(dot(std601R, texColor0),
  70.                     dot(std601G, texColor0),
  71.                     dot(std601B, texColor0),
  72.                     1.0 );
  73.     return outColor;
  74. }
  75.  
  76. // This does UYVY to RGB conversion
  77. half4 uyvy_texture_sampler( in samplerRECT texture,
  78.                             in half2 texcoord)
  79. {
  80.     half4 outColor;
  81.     half4 texColor0;
  82.     half4 texColor1;
  83.     half2 tc0, tc1;
  84.     half isOddUV, texel_sample, texel_offset;
  85.    
  86.     isOddUV = floor(frac(texcoord.x * 0.5) * 2);
  87.     texel_sample = 1.0;
  88.     texel_offset = +0.5;
  89.  
  90.     tc0.x = floor(texcoord.x) - (isOddUV * texel_sample) + texel_offset;
  91.     tc1.x = tc0.x + texel_sample;
  92.  
  93.     texColor0 = texRECT(texture, tc0);
  94.     texColor1 = texRECT(texture, tc1);
  95.  
  96.     // For A8L8, assume A8<-rgb L8<-alpha
  97.     texColor0.r = texColor0.a; // assign Y0 (1st position)
  98.     texColor0.g = texColor0.g; // assign U0 (2nd position)
  99.     texColor0.b = texColor1.b; // assign V0 (3rd position)
  100.  
  101.     texColor1.r = texColor1.a; // assign Y1 (1st position)
  102.     texColor1.g = texColor0.g; // assign U0 (2nd position)
  103.     texColor1.b = texColor1.b; // assign V0 (3rd position)
  104.    
  105.     // assume RGBA0 (Y0 U0)
  106.     // assume RGBA1 (Y1 V0)
  107.     texColor1 = texColor1 * half4(isOddUV);
  108.  
  109.     // assume RGBA0 (Y0 U0)
  110.     // assume RGBA1 (Y1 V0)
  111.     texColor0 = texColor0 * half4(1-isOddUV);
  112.  
  113.     texColor0 = texColor0 + texColor1 + stdbias;
  114.    
  115.     outColor = half4(dot(std601R, texColor0),
  116.                     dot(std601G, texColor0),
  117.                     dot(std601B, texColor0),
  118.                     1.0 );
  119.     return outColor;
  120. }
  121.  
  122. half4 main(void) : COLOR
  123. {
  124.     return yuyv_texture_sampler(VideoTex, gl_FragCoord[0]);
  125. }


Die VideoTex wird via:
Code:
  1.  
  2.       Location := glGetUniformLocationARB(FShader, PGLCharARB('VideoTex'));
  3.       if Location <> -1 then
  4.         glUniform1iARB(Location, FTextureID);
  5.  


übergeben. Da ich mich nur in C nen bisschen auskenne und OpenGL bis dato auch nur als 3D Only "ignoriert" habe, hab ich bestimmt nen Fehler gemacht. Die Konvertier Routinen stammen übrigens von NVIDIA. Der Shader liefert nur 5 Warnungen, aber keinen Error. Lediglich das Bild bleibt eklig grün - wenngleich die Rechenlast sich nicht ändert :)

Hat jemand eine Idee wie die main Routine aussehen müsste?

Danke im Vorraus,
Peter


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 17 Beiträge ]  Gehe zu Seite Vorherige  1, 2
Foren-Übersicht » Programmierung » OpenGL


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 3 Gäste


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
cron
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.007s | 14 Queries | GZIP : On ]