diff options
author | Sven Gothel <[email protected]> | 2023-03-14 14:17:53 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-03-14 14:17:53 +0100 |
commit | 6faab9ada2a7e2b99bb20ce828915a07fdcbea27 (patch) | |
tree | cf55401d676e8b31ba55eca93cde8d4fdb99984d /src/jogl/classes/jogamp/opengl/util/av | |
parent | 67a723477ecd818fbc5859fe20ee536a3b4efae5 (diff) |
TextureSequence (API Change): Use setTextureLookupFunctionName(..) explicitly to set the name upfront, clarifying workflow. Impl: ImageSequence + GLMediaPlayerImpl
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/util/av')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java | 23 | ||||
-rw-r--r-- | src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java | 23 |
2 files changed, 31 insertions, 15 deletions
diff --git a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java index a9e4b5bc3..d94fbb1a7 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java +++ b/src/jogl/classes/jogamp/opengl/util/av/GLMediaPlayerImpl.java @@ -268,15 +268,29 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { } } + protected String textureLookupFunctionName = "texture2D"; + + /** + * {@inheritDoc} + * + * This implementation simply sets and returns the build-in function name of <code>texture2D</code>, + * if not overridden by specialization, e.g. using the ffmpeg implementation. + */ + @Override + public String setTextureLookupFunctionName(final String texLookupFuncName) throws IllegalStateException { + textureLookupFunctionName = "texture2D"; + return textureLookupFunctionName; + } + /** * {@inheritDoc} * * This implementation simply returns the build-in function name of <code>texture2D</code>, - * if not overridden by specialization. + * if not overridden by specialization, e.g. using the ffmpeg implementation. */ @Override - public String getTextureLookupFunctionName(final String desiredFuncName) { - return "texture2D"; + public final String getTextureLookupFunctionName() { + return textureLookupFunctionName; } /** @@ -297,7 +311,8 @@ public abstract class GLMediaPlayerImpl implements GLMediaPlayer { textureFragmentShaderHashCode = 0; return 0; } else if( 0 == textureFragmentShaderHashCode ) { - int hash = 31 + getTextureLookupFragmentShaderImpl().hashCode(); + int hash = 31 + getTextureLookupFunctionName().hashCode(); + hash = ((hash << 5) - hash) + getTextureLookupFragmentShaderImpl().hashCode(); hash = ((hash << 5) - hash) + getTextureSampler2DType().hashCode(); textureFragmentShaderHashCode = hash; } diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java index 91bef005a..fb3e8e4d3 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java @@ -276,7 +276,6 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { // Video // - private String texLookupFuncName = "ffmpegTexture2D"; private boolean usesTexLookupShader = false; private VideoPixelFormat vPixelFmt = null; private int vPlanes = 0; @@ -703,14 +702,16 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { * Otherwise the call is delegated to it's super class. */ @Override - public final String getTextureLookupFunctionName(final String desiredFuncName) { + public String setTextureLookupFunctionName(final String texLookupFuncName) throws IllegalStateException { if( usesTexLookupShader ) { - if(null != desiredFuncName && desiredFuncName.length()>0) { - texLookupFuncName = desiredFuncName; + if(null != texLookupFuncName && texLookupFuncName.length()>0) { + textureLookupFunctionName = texLookupFuncName; + } else { + textureLookupFunctionName = "ffmpegTexture2D"; } - return texLookupFuncName; + return textureLookupFunctionName; } - return super.getTextureLookupFunctionName(desiredFuncName); + return super.getTextureLookupFunctionName(); } /** @@ -729,7 +730,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { case YUVJ420P: case YUV420P: // < planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples) return - "vec4 "+texLookupFuncName+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ + "vec4 "+getTextureLookupFunctionName()+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ " const vec2 u_off = vec2("+tc_w_1+", 0.0);\n"+ " const vec2 v_off = vec2("+tc_w_1+", 0.5);\n"+ " vec2 tc_half = texCoord*0.5;\n"+ @@ -750,7 +751,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { case YUVJ422P: case YUV422P: ///< planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples) return - "vec4 "+texLookupFuncName+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ + "vec4 "+getTextureLookupFunctionName()+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ " const vec2 u_off = vec2("+tc_w_1+" , 0.0);\n"+ " const vec2 v_off = vec2("+tc_w_1+" * 1.5, 0.0);\n"+ " vec2 tc_halfw = vec2(texCoord.x*0.5, texCoord.y);\n"+ @@ -771,7 +772,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { case YUYV422: // < packed YUV 4:2:2, 2 x 16bpp, [Y0 Cb] [Y1 Cr] // Stuffed into RGBA half width texture return - "vec4 "+texLookupFuncName+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ + "vec4 "+getTextureLookupFunctionName()+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ " "+ " float y1,u,y2,v,y,r,g,b;\n"+ " vec2 tc_halfw = vec2(texCoord.x*0.5, texCoord.y);\n"+ @@ -793,7 +794,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { case UYVY422: // < packed YUV 4:2:2, 2 x 16bpp, Cb Y0 Cr Y1 // Stuffed into RGBA half width texture return - "vec4 "+texLookupFuncName+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ + "vec4 "+getTextureLookupFunctionName()+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ " "+ " float y1,u,y2,v,y,r,g,b;\n"+ " vec2 tc_halfw = vec2(texCoord.x*0.5, texCoord.y);\n"+ @@ -815,7 +816,7 @@ public class FFMPEGMediaPlayer extends GLMediaPlayerImpl { case BGR24: return - "vec4 "+texLookupFuncName+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ + "vec4 "+getTextureLookupFunctionName()+"(in "+getTextureSampler2DType()+" image, in vec2 texCoord) {\n"+ " "+ " vec3 bgr = texture2D(image, texCoord).rgb;\n"+ " return vec4(bgr.b, bgr.g, bgr.r, 1);\n"+ /* just swizzle */ |