Replace naudio.dll with code

This commit is contained in:
CroakFang
2022-09-10 16:59:44 +08:00
parent 3c17d8770d
commit 19dbe75b53
1113 changed files with 50280 additions and 182 deletions
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3c1f75350d960914cb70909e86065ca3
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 497dbcc8f29bc4f4491b76ffb68daeca
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b4f3b826ae7019f4cbc0122e140dda20
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,356 @@
/****************************************************************************
*
* Copyright (c) 2018 CRI Middleware Co., Ltd.
*
****************************************************************************/
#if !UNITY_EDITOR && UNITY_ANDROID
using UnityEngine;
using System.Runtime.InteropServices;
namespace CriWare {
namespace CriMana.Detail
{
public static partial class AutoResisterRendererResourceFactories
{
[RendererResourceFactoryPriority(7000)]
public class RendererResourceFactoryAndroidH264Rgb : RendererResourceFactory
{
public override RendererResource CreateRendererResource(int playerId, MovieInfo movieInfo, bool additive, Shader userShader)
{
bool isCodecSuitable = movieInfo.codecType == CodecType.H264 && !CriManaPlugin.criManaUnity_IsBufferOutputForH264Enabled_ANDROID();
bool isGraphicsApiSuitable = (UnityEngine.SystemInfo.graphicsDeviceType != UnityEngine.Rendering.GraphicsDeviceType.Vulkan);
bool isSuitable = isCodecSuitable && isGraphicsApiSuitable;
return isSuitable
? new RendererResourceAndroidH264Rgb(playerId, movieInfo, additive, userShader)
: null;
}
protected override void OnDisposeManaged()
{
}
protected override void OnDisposeUnmanaged()
{
}
}
}
public class RendererResourceAndroidH264Rgb : RendererResource
{
private const int RenderEventAction_ATTACH = (int)Player.CriManaUnityPlayer_RenderEventAction.DESTROY + 1;
private int playerId;
private int width;
private int height;
private int dispWidth;
private int dispHeight;
private int alphaWidth;
private int alphaHeight;
private bool useUserShader;
private Vector4 movieTextureST = new Vector4(1, -1, 0, 1);
private Vector4 alphaTextureST = Vector4.zero;
private Texture2D[] textures;
private System.IntPtr[] nativePtrs = new System.IntPtr[1];
private bool needsUpdateTexture = false;
private bool needsToDetachInitTexture = false;
private bool areTexturesUpdated = false;
private bool isStoppingForSeek = false;
private bool isStartTriggered = true;
private System.UInt32 nativeTextureId;
public RendererResourceAndroidH264Rgb(int playerId, MovieInfo movieInfo, bool additive, Shader userShader)
{
this.playerId = playerId;
width = (int)movieInfo.width;
height = (int)movieInfo.height;
dispWidth = (int)movieInfo.dispWidth;
dispHeight = (int)movieInfo.dispHeight;
hasAlpha = movieInfo.hasAlpha;
if (hasAlpha) {
alphaWidth = Ceiling32(Ceiling16(CeilingWith(width, 8)));
alphaHeight = CeilingWith(height, 16);
}
this.additive = additive;
useUserShader = userShader != null;
if (userShader != null) {
shader = userShader;
} else {
string shaderName = "CriMana/AndroidH264Rgb";
shader = Shader.Find(shaderName);
}
}
protected override void OnDisposeManaged()
{
}
protected override void OnDisposeUnmanaged()
{
DisposeTextures(textures);
textures = null;
}
public override bool IsPrepared()
{ return true; }
public override bool ContinuePreparing()
{ return true; }
public override bool IsSuitable(int playerId, MovieInfo movieInfo, bool additive, Shader userShader)
{
bool isPlayerSuitable = playerId == this.playerId;
bool isCodecSuitable = movieInfo.codecType == CodecType.H264;
bool isSizeSuitable = (width == (int)movieInfo.width) && (height == (int)movieInfo.height);
bool isAlphaSuitable = hasAlpha == movieInfo.hasAlpha;
bool isAdditiveSuitable = this.additive == additive;
bool isShaderSuitable = this.useUserShader ? (userShader == shader) : true;
return isPlayerSuitable && isCodecSuitable && isSizeSuitable && isAlphaSuitable && isAdditiveSuitable && isShaderSuitable;
}
public override bool OnPlayerStopForSeek()
{
if (textures == null) {
return true;
}
isStoppingForSeek = true;
isStartTriggered = false;
return true;
}
public override void OnPlayerStart()
{
isStartTriggered = true;
}
public override bool ShouldSkipDestroyOnStopForSeek()
{ return true; }
private void forceUpdateMaterialTextures(Texture[] newTextures)
{
if (currentMaterial != null) {
currentMaterial.mainTexture = newTextures[0];
currentMaterial.SetTexture("_TextureRGB", newTextures[0]);
if (hasAlpha) {
currentMaterial.SetTexture("_TextureA", newTextures[1]);
}
}
}
public override void AttachToPlayer(int playerId)
{
if (!isStoppingForSeek) {
nativeTextureId = 0xffffffff;
}
criManaUnityPlayer_MediaCodecAttachTexture_ANDROID(playerId, nativeTextureId);
needsToDetachInitTexture = true;
}
public override bool UpdateFrame(int playerId, FrameInfo frameInfo, ref bool frameDrop)
{
if (needsToDetachInitTexture) { // only once
needsToDetachInitTexture = false;
criManaUnityPlayer_MediaCodecDetachTexture_ANDROID(playerId, 0xffffffff);
}
bool isFrameUpdated = CRIWARE9061FF01(playerId, 0, null, frameInfo, ref frameDrop);
if (isFrameUpdated && !frameDrop) {
needsUpdateTexture = true;
}
return isFrameUpdated;
}
public override bool UpdateMaterial(Material material)
{
if (!areTexturesUpdated) {
return false;
}
if (currentMaterial != material) {
currentMaterial = material;
SetupStaticMaterialProperties();
}
if (textures != null) {
material.mainTexture = textures[0];
material.SetTexture("_TextureRGB", textures[0]);
if (hasAlpha && textures[1] != null) {
material.SetTexture("_TextureA", textures[1]);
}
}
material.SetVector("_MovieTexture_ST", movieTextureST);
if (hasAlpha) {
material.SetVector("_AlphaTexture_ST", alphaTextureST);
}
return true;
}
private void UpdateMovieTextureST(float[] texCoords, float dispWidth, float dispHeight)
{
movieTextureST.x = texCoords[0];
movieTextureST.y = texCoords[1];
movieTextureST.z = texCoords[2];
movieTextureST.w = texCoords[3];
float uScale = (dispWidth != alphaWidth) ? ((float)dispWidth - 0.5f) / (float)alphaWidth : 1.0f;
float vScale = (dispHeight != alphaHeight) ? ((float)dispHeight - 0.5f) / (float)alphaHeight : 1.0f;
alphaTextureST.x = uScale;
alphaTextureST.y = -vScale;
alphaTextureST.z = 0.0f;
alphaTextureST.w = vScale;
}
public override void UpdateTextures()
{
if (needsUpdateTexture) { // only once by frame (updates texture may be called multiple time because it is by object an camera
int numTextures = hasAlpha ? 2 : 1;
nativePtrs[0] = System.IntPtr.Zero;
bool isTextureUpdated = CRIWAREDA63C3D7(playerId, numTextures, nativePtrs);
areTexturesUpdated |= isTextureUpdated;
if (isTextureUpdated && nativePtrs[0] != System.IntPtr.Zero && isStartTriggered) {
needsUpdateTexture = false;
var nativeTexture = (NativeTexture)Marshal.PtrToStructure(nativePtrs[0], typeof(NativeTexture));
if (textures == null) {
textures = new Texture2D[2];
textures[0] = Texture2D.CreateExternalTexture(width, height, TextureFormat.ARGB32, false, false, new System.IntPtr(nativeTexture.nativePtrRGB));
textures[0].wrapMode = TextureWrapMode.Clamp;
if (hasAlpha) {
#if !UNITY_5_6_OR_NEWER || UNITY_5_6_0 || UNITY_5_6_1
TextureFormat format = TextureFormat.Alpha8;
#else
TextureFormat format = TextureFormat.R8;
#endif
textures[1] = Texture2D.CreateExternalTexture(alphaWidth, alphaHeight, format, false, false, new System.IntPtr(nativeTexture.nativePtrA));
textures[1].wrapMode = TextureWrapMode.Clamp;
}
if (currentMaterial != null) {
forceUpdateMaterialTextures(textures);
}
nativeTextureId = nativeTexture.nativePtrRGB;
} else {
textures[0].UpdateExternalTexture(new System.IntPtr(nativeTexture.nativePtrRGB));
if (hasAlpha) {
textures[1].UpdateExternalTexture(new System.IntPtr(nativeTexture.nativePtrA));
}
}
UpdateMovieTextureST(nativeTexture.texCoords, dispWidth, dispHeight);
isStoppingForSeek = false;
}
}
}
[StructLayout(LayoutKind.Sequential)]
struct NativeTexture
{
public System.UInt32 nativePtrRGB; // opengl GLuint texture name
public System.UInt32 nativePtrA; // opengl GLuint texture name
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public float[] texCoords; // texture coordinates
}
public static bool IsSupported()
{
if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Vulkan) {
Debug.Log("[CRIWARE] Another RendererResource will be used for Vulkan. Please use CriManaPlugin.IsCodecSupported instead.");
return true;
}
/* check if native code for Android MediaCodec is supported by device */
if (!criManaUnity_IsMediaCodecSupported_ANDROID((int)SystemInfo.graphicsDeviceType)) {
Debug.Log("[CRIWARE] criManaUnity_IsMediaCodecSupported_ANDROID returned false.");
return false;
}
/* If OpenGLES2, all devices can render h.264 videos */
if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.OpenGLES2) {
return true;
}
/* Load a shader for rendering test */
Shader shader = Shader.Find("CriMana/AndroidH264DummySupportCheck");
/* Check the compiled shader is supported(only works on old Unity) */
if (!shader.isSupported) {
return false;
}
/* Save current active RenderTexture */
var current = RenderTexture.active;
/* Create textures for shader rendering test */
Texture2D texture = new Texture2D(1, 1, TextureFormat.ARGB32, false);
RenderTexture renderTexture = new RenderTexture(1, 1, 0);
renderTexture.Create();
/* Create material with the shader */
Material material = new Material(shader);
/* Render on RenderTexture */
Graphics.Blit(texture, renderTexture, material, 0);
/* Copy pixels of RenderTexture to Texture */
RenderTexture.active = renderTexture;
texture.ReadPixels(new Rect(0, 0, renderTexture.width, renderTexture.height), 0, 0);
texture.Apply();
/* Check pixel color */
var color = texture.GetPixel(0, 0);
bool ret = (color.r == 1.0f) && (color.g == 1.0f) && (color.b == 1.0f);
/* Reset current active RenderTexture */
RenderTexture.active = current;
/* Cleaning */
Material.Destroy(material);
Texture2D.Destroy(texture);
Texture2D.Destroy(renderTexture);
return ret;
}
#region DLL Import
#if !CRIWARE_ENABLE_HEADLESS_MODE
[DllImport(CriWare.Common.pluginName, CallingConvention = CriWare.Common.pluginCallingConvention)]
private static extern bool criManaUnity_IsMediaCodecSupported_ANDROID(int device_type);
[DllImport(CriWare.Common.pluginName, CallingConvention = CriWare.Common.pluginCallingConvention)]
private static extern System.UInt32 criManaUnity_MediaCodecCreateTexture_ANDROID();
[DllImport(CriWare.Common.pluginName, CallingConvention = CriWare.Common.pluginCallingConvention)]
private static extern void criManaUnity_MediaCodecDeleteTexture_ANDROID(System.UInt32 oes_texture);
[DllImport(CriWare.Common.pluginName, CallingConvention = CriWare.Common.pluginCallingConvention)]
private static extern bool criManaUnityPlayer_MediaCodecAttachTexture_ANDROID(int player_id, System.UInt32 oes_texture);
[DllImport(CriWare.Common.pluginName, CallingConvention = CriWare.Common.pluginCallingConvention)]
private static extern void criManaUnityPlayer_MediaCodecDetachTexture_ANDROID(int player_id, System.UInt32 oes_texture);
#else
private static bool criManaUnity_IsMediaCodecSupported_ANDROID(int device_type) { return true; }
private static System.UInt32 criManaUnity_MediaCodecCreateTexture_ANDROID() { return 0x0; }
private static void criManaUnity_MediaCodecDeleteTexture_ANDROID(System.UInt32 oes_texture) { }
private static bool criManaUnityPlayer_MediaCodecAttachTexture_ANDROID(int player_id, System.UInt32 oes_texture) { return true; }
private static void criManaUnityPlayer_MediaCodecDetachTexture_ANDROID(int player_id, System.UInt32 oes_texture) { }
#endif
#endregion
}
}
} //namespace CriWare
#endif
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 4d3185896891e4109a5d1e0802757b9e
timeCreated: 1445063317
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,341 @@
/****************************************************************************
*
* Copyright (c) 2015-2018 CRI Middleware Co., Ltd.
*
****************************************************************************/
#if !UNITY_EDITOR && UNITY_ANDROID
using UnityEngine;
using System;
namespace CriWare {
namespace CriMana.Detail
{
public static partial class AutoResisterRendererResourceFactories
{
[RendererResourceFactoryPriority(5050)]
public class RendererResourceFactoryAndroidSofdecPrimeYuv : RendererResourceFactory
{
public override RendererResource CreateRendererResource(int playerId, MovieInfo movieInfo, bool additive, Shader userShader)
{
bool isCodecSuitable = movieInfo.codecType == CodecType.SofdecPrime ||
movieInfo.codecType == CodecType.VP9 ||
(CriManaPlugin.criManaUnity_IsBufferOutputForH264Enabled_ANDROID() && movieInfo.codecType == CodecType.H264);
bool isGraphicsApiSuitable = (UnityEngine.SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.OpenGLES3);
bool isSuitable = isCodecSuitable && isGraphicsApiSuitable;
return isSuitable
? new RendererResourceAndroidSofdecPrimeYuv(playerId, movieInfo, additive, userShader)
: null;
}
protected override void OnDisposeManaged()
{
}
protected override void OnDisposeUnmanaged()
{
}
}
}
public class RendererResourceAndroidSofdecPrimeYuv : RendererResource
{
private int width, height;
private int chromaWidth, chromaHeight;
private int alphaWidth, alphaHeight;
private bool useUserShader;
private CodecType codecType;
private const TextureFormat format = TextureFormat.R8;
private const TextureFormat formatUV = TextureFormat.RG16;
private Vector4 movieTextureST = Vector4.zero;
private Vector4 movieChromaTextureST = Vector4.zero;
private Vector4 movieAlphaTextureST = Vector4.zero;
private Texture2D[] textures;
private int numImages = -1;
private int numImagesForYUV = -1;
System.IntPtr[] nativePtrs = new System.IntPtr[4];
private RenderTexture[] renderTextures;
private Int32 playerID;
private bool areTexturesUpdated = false;
private bool isFrameUpdated = false;
private bool isStoppingForSeek = false;
private bool isStartTriggered = true;
public RendererResourceAndroidSofdecPrimeYuv(int playerId, MovieInfo movieInfo, bool additive, Shader userShader)
{
CalculateTextureSize(ref width, ref height, (int)movieInfo.width, (int)movieInfo.height, movieInfo.codecType, false);
CalculateTextureSize(ref chromaWidth, ref chromaHeight, (int)movieInfo.width, (int)movieInfo.height, movieInfo.codecType, true);
this.additive = additive;
hasAlpha = movieInfo.hasAlpha;
useUserShader = userShader != null;
codecType = movieInfo.codecType;
if (userShader != null) {
shader = userShader;
} else {
string shaderName = "CriMana/AndroidSofdecPrimeYuv";
shader = Shader.Find(shaderName);
}
if (hasAlpha) {
CalculateTextureSize(ref alphaWidth, ref alphaHeight, (int)movieInfo.width, (int)movieInfo.height, movieInfo.alphaCodecType, false);
}
UpdateMovieTextureST(movieInfo.dispWidth, movieInfo.dispHeight);
nativePtrs = new IntPtr[4];
playerID = playerId;
}
protected override void OnDisposeManaged()
{
}
protected override void OnDisposeUnmanaged()
{
DisposeTextures(textures);
DisposeTextures(renderTextures);
textures = null;
renderTextures = null;
}
public override bool IsPrepared()
{
return areTexturesUpdated && isFrameUpdated;
}
public override bool ContinuePreparing()
{ return true; }
public override bool IsSuitable(int playerId, MovieInfo movieInfo, bool additive, Shader userShader)
{
int w = 0, h = 0;
CalculateTextureSize(ref w, ref h, (int)movieInfo.width, (int)movieInfo.height, movieInfo.codecType, false);
bool isCodecSuitable = movieInfo.codecType == codecType;
bool isSizeSuitable = (width == w) && (height == h);
bool isAlphaSuitable = hasAlpha == movieInfo.hasAlpha;
bool isAdditiveSuitable = this.additive == additive;
bool isShaderSuitable = this.useUserShader ? (userShader == shader) : true;
return isCodecSuitable && isSizeSuitable && isAlphaSuitable && isAdditiveSuitable && isShaderSuitable;
}
public override bool OnPlayerStopForSeek()
{
isStoppingForSeek = true;
isStartTriggered = false;
if (renderTextures != null || textures == null || textures[0] == null) {
return true;
}
renderTextures = new RenderTexture[hasAlpha ? 4 : 3];
for (int i = 0; i < renderTextures.Length; i++) {
Texture2D baseTexture = textures[i];
RenderTexture texture = new RenderTexture(baseTexture.width, baseTexture.height, 0, RenderTextureFormat.R8);
texture.Create();
Graphics.Blit(baseTexture, texture);
renderTextures[i] = texture;
}
forceUpdateMaterialTextures(renderTextures);
DisposeTextures(textures);
return true;
}
public override void OnPlayerStart() {
isStartTriggered = true;
}
private void forceUpdateMaterialTextures(Texture[] newTextures) {
if (currentMaterial != null) {
currentMaterial.SetTexture("_TextureY", newTextures[0]);
currentMaterial.SetTexture("_TextureU", newTextures[1]);
currentMaterial.SetTexture("_TextureV", newTextures[2]);
if (hasAlpha) {
currentMaterial.SetTexture("_TextureA", newTextures[3]);
}
}
}
public override void AttachToPlayer(int playerId)
{
DisposeTextures(textures);
areTexturesUpdated = false;
isFrameUpdated = false;
}
public override bool UpdateFrame(int playerId, FrameInfo frameInfo, ref bool frameDrop)
{
bool updated = CRIWARE9061FF01(playerId, 4, null, frameInfo, ref frameDrop);
if (updated && !frameDrop) {
UpdateMovieTextureST(frameInfo.dispWidth, frameInfo.dispHeight);
}
isFrameUpdated |= updated;
if (isFrameUpdated) {
numImages = (int)frameInfo.numImages;
numImagesForYUV = hasAlpha ? numImages - 1 : numImages;
}
return updated;
}
public override bool UpdateMaterial(Material material)
{
if (areTexturesUpdated) {
if (textures != null && textures[0] != null) {
if (currentMaterial != material) {
currentMaterial = material;
SetupStaticMaterialProperties();
if (numImagesForYUV == 3) {
material.DisableKeyword("CRI_UV_FORMAT");
} else {
material.EnableKeyword("CRI_UV_FORMAT");
}
}
material.SetVector("_MovieTexture_ST", movieTextureST);
material.SetVector("_MovieChromaTexture_ST", movieChromaTextureST);
if (!isStoppingForSeek) {
material.SetTexture("_TextureY", textures[0]);
if (numImagesForYUV == 3) {
material.SetTexture("_TextureU", textures[1]);
material.SetTexture("_TextureV", textures[2]);
} else {
material.SetTexture("_TextureUV", textures[1]);
}
if (hasAlpha) {
material.SetVector("_MovieAlphaTexture_ST", movieAlphaTextureST);
material.SetTexture("_TextureA", textures[numImages - 1]);
}
DisposeTextures(renderTextures);
renderTextures = null;
}
}
return true;
} else {
return renderTextures != null;
}
}
private void UpdateMovieTextureST(System.UInt32 dispWidth, System.UInt32 dispHeight)
{
float uScale = (dispWidth != width) ? (float)(dispWidth - 1) / width : 1.0f;
float vScale = (dispHeight != height) ? (float)(dispHeight - 1) / height : 1.0f;
movieTextureST.x = uScale;
movieTextureST.y = -vScale;
movieTextureST.z = 0.0f;
movieTextureST.w = vScale;
uScale = (dispWidth != chromaWidth * 2) ? (float)(dispWidth / 2 - 1) / (chromaWidth * 2) * 2 : 1.0f;
vScale = (dispHeight != chromaHeight * 2) ? (float)(dispHeight / 2 - 1) / (chromaHeight * 2) * 2 : 1.0f;
movieChromaTextureST.x = uScale;
movieChromaTextureST.y = -vScale;
movieChromaTextureST.z = 0.0f;
movieChromaTextureST.w = vScale;
if (hasAlpha) {
uScale = (dispWidth != alphaWidth) ? (float)(dispWidth - 1) / alphaWidth : 1.0f;
vScale = (dispHeight != alphaHeight) ? (float)(dispHeight - 1) / alphaHeight : 1.0f;
movieAlphaTextureST.x = uScale;
movieAlphaTextureST.y = -vScale;
movieAlphaTextureST.z = 0.0f;
movieAlphaTextureST.w = vScale;
}
}
public override void UpdateTextures()
{
nativePtrs[0] = System.IntPtr.Zero;
bool updated = CRIWAREDA63C3D7(playerID, numImages, nativePtrs);
areTexturesUpdated |= updated;
if (updated && nativePtrs[0] != System.IntPtr.Zero && isStartTriggered) {
if (textures == null || textures[0] == null) {
textures = new Texture2D[numImages];
textures[0] = Texture2D.CreateExternalTexture(width, height, format, false, false, nativePtrs[0]);
textures[0].wrapMode = TextureWrapMode.Clamp;
if (numImagesForYUV == 3) { /* Y/U/V */
textures[1] = Texture2D.CreateExternalTexture(chromaWidth, chromaHeight, format, false, false, nativePtrs[1]);
textures[1].wrapMode = TextureWrapMode.Clamp;
textures[2] = Texture2D.CreateExternalTexture(chromaWidth, chromaHeight, format, false, false, nativePtrs[2]);
textures[2].wrapMode = TextureWrapMode.Clamp;
} else { /* Y/UV */
textures[1] = Texture2D.CreateExternalTexture(chromaWidth, chromaHeight, formatUV, false, false, nativePtrs[1]);
textures[1].wrapMode = TextureWrapMode.Clamp;
}
if (hasAlpha) {
textures[numImages - 1] = Texture2D.CreateExternalTexture(alphaWidth, alphaHeight, format, false, false, nativePtrs[numImages - 1]);
textures[numImages - 1].wrapMode = TextureWrapMode.Clamp;
}
} else {
for (int i = 0; i < numImages; i++) {
textures[i].UpdateExternalTexture(nativePtrs[i]);
}
}
isStoppingForSeek = false;
}
}
private static void CalculateTextureSize(ref int w, ref int h, int videoWidth, int videoHeight, CodecType type, bool isChroma)
{
if (type == CodecType.SofdecPrime) {
if (!isChroma) {
w = Ceiling32(Ceiling16(CeilingWith(videoWidth, 8)));
h = CeilingWith(videoHeight, 8);
} else {
w = Ceiling32(Ceiling16(CeilingWith(videoWidth, 8)) / 2);
h = CeilingWith(videoHeight, 8) / 2;
}
} else if (type == CodecType.VP9) {
if (!isChroma) {
w = CeilingWith(CeilingWith(videoWidth, 2), 8);
h = CeilingWith(videoHeight, 2);
} else {
w = CeilingWith(CeilingWith(videoWidth, 2) / 2, 8);
h = CeilingWith(videoHeight, 2) / 2;
}
} else if (type == CodecType.H264) {
if (!isChroma) {
w = Ceiling16(Ceiling16(CeilingWith(videoWidth, 8)));
h = CeilingWith(videoHeight, 8);
} else {
w = Ceiling16(Ceiling16(CeilingWith(videoWidth, 8)) / 2);
h = CeilingWith(videoHeight, 8) / 2;
}
}
}
} // class
} // namespace
} //namespace CriWare
#endif
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2c1b5bfeca611e446ad85bec1af765ec
timeCreated: 1504693376
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,303 @@
/****************************************************************************
*
* Copyright (c) 2015 CRI Middleware Co., Ltd.
*
****************************************************************************/
#if !UNITY_EDITOR && UNITY_ANDROID
using UnityEngine;
using System;
namespace CriWare {
namespace CriMana.Detail
{
public static partial class AutoResisterRendererResourceFactories
{
[RendererResourceFactoryPriority(5060)]
public class RendererResourceFactoryAndroidSofdecPrimeYuvLegacyGles2 : RendererResourceFactory
{
public override RendererResource CreateRendererResource(int playerId, MovieInfo movieInfo, bool additive, Shader userShader)
{
bool isCodecSuitable = movieInfo.codecType == CodecType.SofdecPrime || movieInfo.codecType == CodecType.VP9 ||
(CriManaPlugin.criManaUnity_IsBufferOutputForH264Enabled_ANDROID() && movieInfo.codecType == CodecType.H264);
bool isGraphicsApiSuitable = (UnityEngine.SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.OpenGLES2 ||
UnityEngine.SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Vulkan);
bool isSuitable = isCodecSuitable && isGraphicsApiSuitable;
return isSuitable
? new RendererResourceAndroidSofdecPrimeYuvLegacyGles2(playerId, movieInfo, additive, userShader)
: null;
}
protected override void OnDisposeManaged()
{
}
protected override void OnDisposeUnmanaged()
{
}
}
}
public class RendererResourceAndroidSofdecPrimeYuvLegacyGles2 : RendererResource
{
private int width, height;
private int chromaWidth, chromaHeight;
private int alphaWidth, alphaHeight;
private bool useUserShader;
CodecType codecType;
private int movieWidth, movieHeight;
private const TextureFormat format = TextureFormat.Alpha8;
private const TextureFormat formatUV = TextureFormat.RG16;
private Vector4 movieTextureST = Vector4.zero;
private Vector4 movieChromaTextureST = Vector4.zero;
private Vector4 movieAlphaTextureST = Vector4.zero;
private Texture2D[][] textures;
private RenderTexture[] renderTextures;
private IntPtr[][] nativeTextures;
private int numImages = -1;
private int numImagesForYUV = -1;
private Int32 numTextureSets = 2;
private Int32 currentTextureSet = 0;
private Int32 drawTextureSet = -1;
private Int32 playerID;
private bool isStoppingForSeek = false;
public RendererResourceAndroidSofdecPrimeYuvLegacyGles2(int playerId, MovieInfo movieInfo, bool additive, Shader userShader)
{
hasAlpha = movieInfo.hasAlpha;
this.additive = additive;
useUserShader = userShader != null;
movieWidth = (int)movieInfo.width;
movieHeight = (int)movieInfo.height;
if (userShader != null) {
shader = userShader;
} else {
string shaderName = "CriMana/AndroidSofdecPrimeYuvLegacy";
shader = Shader.Find(shaderName);
}
textures = new Texture2D[numTextureSets][];
for (int i = 0; i < numTextureSets; i++) {
textures[i] = new Texture2D[4];
for (int j = 0; j < 4; j++) {
textures[i][j] = null;
}
}
nativeTextures = new IntPtr[numTextureSets][];
for (int i = 0; i < numTextureSets; i++) {
nativeTextures[i] = new IntPtr[4];
for (int j = 0; j < 4; j++) {
nativeTextures[i][j] = IntPtr.Zero;
}
}
codecType = movieInfo.codecType;
playerID = playerId;
}
protected override void OnDisposeManaged()
{}
protected override void OnDisposeUnmanaged()
{
CRIWARE2676F2A5(playerID, 0 ,null);
for (int i = 0; i < numTextureSets; i++) {
DisposeTextures(textures[i]);
}
textures = null;
nativeTextures = null;
}
public override bool IsPrepared()
{ return true; }
public override bool ContinuePreparing()
{ return true; }
public override bool IsSuitable(int playerId, MovieInfo movieInfo, bool additive, Shader userShader) {
bool isCodecSuitable = movieInfo.codecType == codecType;
bool isSizeSuitable = (movieWidth == (int)movieInfo.width) && (movieHeight == (int)movieInfo.height);
bool isAlphaSuitable = hasAlpha == movieInfo.hasAlpha;
bool isAdditiveSuitable = this.additive == additive;
bool isShaderSuitable = this.useUserShader ? (userShader == shader) : true;
return isCodecSuitable && isSizeSuitable && isAlphaSuitable && isAdditiveSuitable && isShaderSuitable;
}
public override bool OnPlayerStopForSeek() {
isStoppingForSeek = (drawTextureSet >= 0);
return true;
}
public override void AttachToPlayer(int playerId) {
CRIWARE71A23DE1(playerID, 0, new IntPtr[1]);
drawTextureSet = -1;
}
public override bool UpdateFrame(int playerId, FrameInfo frameInfo, ref bool frameDrop) {
bool isFrameUpdated = CRIWARE9061FF01(playerId, 0, null, frameInfo, ref frameDrop);
if (isFrameUpdated && !frameDrop) {
drawTextureSet = currentTextureSet;
currentTextureSet = (currentTextureSet + 1) % numTextureSets;
isStoppingForSeek = false;
}
if (isFrameUpdated && textures[0][0] == null) {
numImages = (int)frameInfo.numImages;
numImagesForYUV = hasAlpha ? numImages - 1 : numImages;
CalculateTextureSize(ref width, ref height, (int)frameInfo.width, (int)frameInfo.height, codecType, false);
CalculateTextureSize(ref chromaWidth, ref chromaHeight, (int)frameInfo.width, (int)frameInfo.height, codecType, true);
if (hasAlpha) {
CalculateTextureSize(ref alphaWidth, ref alphaHeight, (int)frameInfo.width, (int)frameInfo.height, CodecType.SofdecPrime, false);
}
UpdateMovieTextureST(frameInfo.dispWidth, frameInfo.dispHeight);
for (int i = 0; i < numTextureSets; i++) {
textures[i][0] = new Texture2D(width, height, format, false, true);
textures[i][0].wrapMode = TextureWrapMode.Clamp;
if (numImagesForYUV == 3) {
textures[i][1] = new Texture2D(chromaWidth, chromaHeight, format, false, true);
textures[i][1].wrapMode = TextureWrapMode.Clamp;
textures[i][2] = new Texture2D(chromaWidth, chromaHeight, format, false, true);
textures[i][2].wrapMode = TextureWrapMode.Clamp;
} else {
textures[i][1] = new Texture2D(chromaWidth, chromaHeight, formatUV, false, true);
textures[i][1].wrapMode = TextureWrapMode.Clamp;
}
for (int j = 0; j < numImagesForYUV; j++) {
nativeTextures[i][j] = textures[i][j].GetNativeTexturePtr();
}
if (hasAlpha) {
textures[i][numImages - 1] = new Texture2D(alphaWidth, alphaHeight, format, false, true);
textures[i][numImages - 1].wrapMode = TextureWrapMode.Clamp;
nativeTextures[i][numImages - 1] = textures[i][numImages - 1].GetNativeTexturePtr();
}
}
}
return isFrameUpdated;
}
public override bool UpdateMaterial(Material material) {
if (isStoppingForSeek)
return true;
if (drawTextureSet < 0)
return false;
if (currentMaterial != material) {
currentMaterial = material;
SetupStaticMaterialProperties();
if (numImagesForYUV == 3) {
material.DisableKeyword("CRI_UV_FORMAT");
} else {
material.EnableKeyword("CRI_UV_FORMAT");
}
}
material.SetVector("_MovieTexture_ST", movieTextureST);
material.SetVector("_MovieChromaTexture_ST", movieChromaTextureST);
material.SetTexture("_TextureY", textures[drawTextureSet][0]);
if (numImagesForYUV == 3) {
material.SetTexture("_TextureU", textures[drawTextureSet][1]);
material.SetTexture("_TextureV", textures[drawTextureSet][2]);
} else {
material.SetTexture("_TextureUV", textures[drawTextureSet][1]);
}
if (hasAlpha) {
material.SetVector("_MovieAlphaTexture_ST", movieAlphaTextureST);
material.SetTexture("_TextureA", textures[drawTextureSet][numImages - 1]);
}
return true;
}
private void UpdateMovieTextureST(System.UInt32 dispWidth, System.UInt32 dispHeight) {
float uScale = (dispWidth != width) ? (float)(dispWidth - 1) / width : 1.0f;
float vScale = (dispHeight != height) ? (float)(dispHeight - 1) / height : 1.0f;
movieTextureST.x = uScale;
movieTextureST.y = -vScale;
movieTextureST.z = 0.0f;
movieTextureST.w = vScale;
uScale = (dispWidth != chromaWidth * 2) ?
(float)(dispWidth / 2 - 1) / (chromaWidth * 2) * 2 :
1.0f;
vScale = (dispHeight != chromaHeight * 2) ?
(float)(dispHeight / 2 - 1) / (chromaHeight * 2) * 2 :
1.0f;
movieChromaTextureST.x = uScale;
movieChromaTextureST.y = -vScale;
movieChromaTextureST.z = 0.0f;
movieChromaTextureST.w = vScale;
if (hasAlpha) {
uScale = (dispWidth != alphaWidth) ? (float)(dispWidth - 1) / alphaWidth : 1.0f;
vScale = (dispHeight != alphaHeight) ? (float)(dispHeight - 1) / alphaHeight : 1.0f;
movieAlphaTextureST.x = uScale;
movieAlphaTextureST.y = -vScale;
movieAlphaTextureST.z = 0.0f;
movieAlphaTextureST.w = vScale;
}
}
public override void UpdateTextures()
{
if (drawTextureSet < 0)
return;
CRIWAREDA63C3D7(playerID, numImages, nativeTextures[drawTextureSet]);
}
private static void CalculateTextureSize(ref int w, ref int h, int videoWidth, int videoHeight, CodecType type, bool isChroma) {
if (type == CodecType.SofdecPrime) {
if (!isChroma) {
w = Ceiling32(Ceiling16(CeilingWith(videoWidth, 8)));
h = CeilingWith(videoHeight, 8);
} else {
w = Ceiling32(Ceiling16(CeilingWith(videoWidth, 8)) / 2);
h = CeilingWith(videoHeight, 8) / 2;
}
} else if (type == CodecType.VP9) {
if (!isChroma) {
w = CeilingWith(CeilingWith(videoWidth, 2), 8);
h = CeilingWith(CeilingWith(videoHeight, 2), 8);
} else {
w = CeilingWith(CeilingWith(videoWidth, 2) / 2, 8);
h = CeilingWith(CeilingWith(videoHeight, 2) / 2, 8);
}
} else if (type == CodecType.H264) {
if (!isChroma) {
w = videoWidth;
h = videoHeight;
} else {
w = videoWidth / 2;
h = videoHeight / 2;
}
}
}
}
}
} //namespace CriWare
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0278ee25c85693943bd37be41852fa52
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c4a7bb2022b729345931dc907d6ab8a5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6ecbb7559c822d94e9e5864caa40b65f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fc89c6c3bcab4e148b1f6396cb7fd89f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,106 @@
Shader "CriMana/AndroidH264Rgb"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
[HideInInspector] _MovieTexture_ST ("MovieTexture_ST", Vector) = (1.0, 1.0, 0, 0)
[HideInInspector] _AlphaTexture_ST("AlphaTexture_ST", Vector) = (1.0, 1.0, 0, 0)
[HideInInspector] _TextureRGB ("TextureRGB", 2D) = "white" {}
[HideInInspector] _TextureA ("TextureA", 2D) = "white" {}
[HideInInspector] _SrcBlendMode ("SrcBlendMode", Int) = 0
[HideInInspector] _DstBlendMode ("DstBlendMode", Int) = 0
[HideInInspector] _CullMode("CullMode", Int) = 2
[HideInInspector] _ZWriteMode("ZWriteMode", Int) = 1
}
SubShader
{
Tags
{
"Queue" = "Transparent"
"PreviewType"="Plane"
}
Pass
{
Blend [_SrcBlendMode] [_DstBlendMode]
Cull [_CullMode]
ZWrite [_ZWriteMode]
ZTest [unity_GUIZTestMode]
GLSLPROGRAM
#version 100 // this will be converted to 300 es when using OpenGLES3
#pragma multi_compile _ CRI_ALPHA_MOVIE
#pragma multi_compile _ CRI_APPLY_TARGET_ALPHA
#pragma multi_compile _ CRI_LINEAR_COLORSPACE
#ifdef VERTEX
attribute vec4 _glesVertex;
attribute vec4 _glesMultiTexCoord0;
#ifdef CRI_APPLY_TARGET_ALPHA
attribute vec4 _glesColor;
varying lowp float alpha;
#endif
uniform highp vec4 _MainTex_ST;
uniform highp vec4 _MovieTexture_ST;
varying mediump vec2 xlv_TEXCOORD0;
#ifdef CRI_ALPHA_MOVIE
uniform highp vec4 _AlphaTexture_ST;
varying mediump vec2 xlv_TEXCOORD1;
#endif
void main ()
{
highp vec4 tmpvar;
tmpvar.w = 1.0;
tmpvar.xyz = _glesVertex.xyz;
gl_Position = (unity_MatrixVP * (unity_ObjectToWorld * tmpvar)); // UnityObjectToClipPos(*)
xlv_TEXCOORD0 = (((_glesMultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw) * _MovieTexture_ST.xy) + _MovieTexture_ST.zw;
#ifdef CRI_ALPHA_MOVIE
xlv_TEXCOORD1 = (((_glesMultiTexCoord0.xy * _MainTex_ST.xy) + _MainTex_ST.zw) * _AlphaTexture_ST.xy) + _AlphaTexture_ST.zw;
#endif
#ifdef CRI_APPLY_TARGET_ALPHA
alpha = _glesColor.w;
#endif
}
#endif
#ifdef FRAGMENT
#extension GL_OES_EGL_image_external : enable
#extension GL_OES_EGL_image_external_essl3 : enable
#if (defined(SHADER_API_GLES3) && defined(GL_OES_EGL_image_external_essl3)) || defined(GL_OES_EGL_image_external) && !defined(SHADER_API_GLCORE)
uniform samplerExternalOES _TextureRGB;
#else
uniform sampler2D _TextureRGB;
#endif
varying mediump vec2 xlv_TEXCOORD0;
uniform lowp float _Transparency;
#ifdef CRI_ALPHA_MOVIE
uniform sampler2D _TextureA;
varying mediump vec2 xlv_TEXCOORD1;
#endif
#ifdef CRI_APPLY_TARGET_ALPHA
varying lowp float alpha;
#endif
void main ()
{
#if (defined(SHADER_API_GLES3) && defined(GL_OES_EGL_image_external_essl3)) || defined(GL_OES_EGL_image_external) && !defined(SHADER_API_GLCORE)
gl_FragData[0] = texture2D(_TextureRGB, xlv_TEXCOORD0);
#else
gl_FragData[0].x = gl_FragData[0].y = gl_FragData[0].z = 0.0f;
#endif
#ifdef CRI_LINEAR_COLORSPACE
gl_FragData[0].x = pow(max(gl_FragData[0].x, 0.001), 2.2);
gl_FragData[0].y = pow(max(gl_FragData[0].y, 0.001), 2.2);
gl_FragData[0].z = pow(max(gl_FragData[0].z, 0.001), 2.2);
#endif
#ifdef CRI_ALPHA_MOVIE
gl_FragData[0].w = texture2D(_TextureA, xlv_TEXCOORD1).x;
#endif
#ifdef CRI_APPLY_TARGET_ALPHA
gl_FragData[0].w *= alpha;
#endif
gl_FragData[0].w *= 1.0 - _Transparency;
}
#endif
ENDGLSL
}
}
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 01205c74879764ae9b7e3fe90473f53f
timeCreated: 1445063687
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,46 @@
Shader "CriMana/AndroidH264DummySupportCheck"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
}
SubShader
{
Pass
{
ZTest Always
Cull Off
Zwrite Off
Blend One Zero
GLSLPROGRAM
#version 100 // this will be converted to 300 es when using OpenGLES3
#ifdef VERTEX
attribute vec4 _glesVertex;
void main()
{
highp vec4 tmpvar;
tmpvar.w = 1.0;
tmpvar.xyz = _glesVertex.xyz;
gl_Position = (unity_MatrixVP * (unity_ObjectToWorld * tmpvar)); // UnityObjectToClipPos(*)
}
#endif
#ifdef FRAGMENT
#extension GL_OES_EGL_image_external : enable
#extension GL_OES_EGL_image_external_essl3 : enable
void main()
{
#if (defined(SHADER_API_GLES3) && defined(GL_OES_EGL_image_external_essl3)) || defined(GL_OES_EGL_image_external)
gl_FragData[0].x = gl_FragData[0].y = gl_FragData[0].z = 1.0f;
#else
gl_FragData[0].x = gl_FragData[0].y = gl_FragData[0].z = 0.0f;
Dummy code for shader compilation failure.
#endif
}
#endif
ENDGLSL
}
}
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 51ee31cd511ac614ea39aa4dd7841c15
timeCreated: 1510192307
licenseType: Pro
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,144 @@
Shader "CriMana/AndroidSofdecPrimeYuv"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
[HideInInspector] _MovieTexture_ST ("MovieTexture_ST", Vector) = (1.0, 1.0, 0, 0)
[HideInInspector] _MovieChromaTexture_ST("MovieChromaTexture_ST", Vector) = (1.0, 1.0, 0, 0)
[HideInInspector] _MovieAlphaTexture_ST("MovieAlphaTexture_ST", Vector) = (1.0, 1.0, 0, 0)
[HideInInspector] _TextureY ("TextureY", 2D) = "white" {}
[HideInInspector] _TextureU ("TextureU", 2D) = "white" {}
[HideInInspector] _TextureV ("TextureV", 2D) = "white" {}
[HideInInspector] _TextureUV ("TextureUV", 2D) = "white" {}
[HideInInspector] _TextureA ("TextureA", 2D) = "white" {}
[HideInInspector] _SrcBlendMode ("SrcBlendMode", Int) = 0
[HideInInspector] _DstBlendMode ("DstBlendMode", Int) = 0
[HideInInspector] _CullMode("CullMode", Int) = 2
[HideInInspector] _ZWriteMode("ZWriteMode", Int) = 1
}
SubShader
{
Tags
{
"Queue" = "Transparent"
"PreviewType"="Plane"
}
Pass
{
Blend [_SrcBlendMode] [_DstBlendMode]
Cull [_CullMode]
ZWrite [_ZWriteMode]
ZTest [unity_GUIZTestMode]
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#if defined(SHADER_API_PSP2) || defined(SHADER_API_PS3)
// seems that ARB_precision_hint_fastest is not supported on these platforms.
#else
#pragma fragmentoption ARB_precision_hint_fastest
#endif
#include "UnityCG.cginc"
#pragma multi_compile _ CRI_UV_FORMAT
#pragma multi_compile _ CRI_ALPHA_MOVIE
#pragma multi_compile _ CRI_APPLY_TARGET_ALPHA
#pragma multi_compile _ CRI_LINEAR_COLORSPACE
struct appdata
{
float4 vertex : POSITION;
half2 texcoord : TEXCOORD0;
#ifdef CRI_APPLY_TARGET_ALPHA
float4 color : COLOR;
#endif
};
struct v2f
{
float4 pos : SV_POSITION;
half2 uv : TEXCOORD0;
half2 uv2 : TEXCOORD1;
#ifdef CRI_ALPHA_MOVIE
half2 uv3 : TEXCOORD2;
#endif
#ifdef CRI_APPLY_TARGET_ALPHA
float4 color : COLOR;
#endif
};
float4 _MainTex_ST;
float4 _MovieTexture_ST;
float4 _MovieChromaTexture_ST;
#ifdef CRI_ALPHA_MOVIE
float4 _MovieAlphaTexture_ST;
#endif
v2f vert(appdata v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = (TRANSFORM_TEX(v.texcoord, _MainTex) * _MovieTexture_ST.xy) + _MovieTexture_ST.zw;
o.uv2 = (TRANSFORM_TEX(v.texcoord, _MainTex) * _MovieChromaTexture_ST.xy) + _MovieChromaTexture_ST.zw;
#ifdef CRI_ALPHA_MOVIE
o.uv3 = (TRANSFORM_TEX(v.texcoord, _MainTex) * _MovieAlphaTexture_ST.xy) + _MovieAlphaTexture_ST.zw;
#endif
#ifdef CRI_APPLY_TARGET_ALPHA
o.color = v.color;
#endif
return o;
}
static const fixed3x3 yuv_to_rgb = {
{1.16438, 0.0, 1.59603},
{1.16438, -0.39176, -0.81297},
{1.16438, 2.01723, 0.0}
};
sampler2D _TextureY;
#ifdef CRI_UV_FORMAT
sampler2D _TextureUV;
#else
sampler2D _TextureU;
sampler2D _TextureV;
#endif
#ifdef CRI_ALPHA_MOVIE
sampler2D _TextureA;
#endif
fixed _Transparency;
fixed4 frag(v2f i) : COLOR
{
fixed4 color;
color.r = tex2D(_TextureY, i.uv).r;
#ifdef CRI_UV_FORMAT
color.g = tex2D(_TextureUV, i.uv2).r;
color.b = tex2D(_TextureUV, i.uv2).a;
#else
color.g = tex2D(_TextureU, i.uv2).r;
color.b = tex2D(_TextureV, i.uv2).r;
#endif
#ifdef CRI_ALPHA_MOVIE
color.a = tex2D(_TextureA, i.uv3).r;
#else
color.a = 1.0;
#endif
color.rgb = color.rgb + fixed3(-0.06275, -0.50196, -0.50196);
color.rgb = mul(yuv_to_rgb, color.rgb);
#ifdef CRI_LINEAR_COLORSPACE
color.rgb = pow(max(color.rgb, 0), 2.2);
#endif
#ifdef CRI_APPLY_TARGET_ALPHA
color.a = color.a * i.color.a;
#endif
color.a *= 1 - _Transparency;
return color;
}
ENDCG
}
}
}
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 545dfb3f920144f7bb3599122209656b
timeCreated: 1510116192
licenseType: Pro
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,141 @@
Shader "CriMana/AndroidSofdecPrimeYuvLegacy"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
[HideInInspector] _MovieTexture_ST ("MovieTexture_ST", Vector) = (1.0, 1.0, 0, 0)
[HideInInspector] _MovieChromaTexture_ST ("MovieChromaTexture_ST", Vector) = (1.0, 1.0, 0, 0)
[HideInInspector] _MovieAlphaTexture_ST ("MovieAlphaTexture_ST", Vector) = (1.0, 1.0, 0, 0)
[HideInInspector] _TextureY ("TextureY", 2D) = "white" {}
[HideInInspector] _TextureU ("TextureU", 2D) = "white" {}
[HideInInspector] _TextureV ("TextureV", 2D) = "white" {}
[HideInInspector] _TextureUV ("TextureUV", 2D) = "white" {}
[HideInInspector] _TextureA ("TextureA", 2D) = "white" {}
[HideInInspector] _SrcBlendMode ("SrcBlendMode", Int) = 0
[HideInInspector] _DstBlendMode ("DstBlendMode", Int) = 0
[HideInInspector] _CullMode ("CullMode", Int) = 2
[HideInInspector] _ZWriteMode ("ZWriteMode", Int) = 1
}
SubShader
{
Tags
{
"Queue" = "Transparent"
"PreviewType"="Plane"
}
Pass
{
Blend [_SrcBlendMode] [_DstBlendMode]
Cull [_CullMode]
ZWrite [_ZWriteMode]
ZTest [unity_GUIZTestMode]
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
#pragma multi_compile _ CRI_UV_FORMAT
#pragma multi_compile _ CRI_ALPHA_MOVIE
#pragma multi_compile _ CRI_APPLY_TARGET_ALPHA
#pragma multi_compile _ CRI_LINEAR_COLORSPACE
struct appdata
{
float4 vertex : POSITION;
half2 texcoord : TEXCOORD0;
#ifdef CRI_APPLY_TARGET_ALPHA
float4 color : COLOR;
#endif
};
struct v2f
{
float4 pos : SV_POSITION;
half2 uv : TEXCOORD0;
half2 uv2 : TEXCOORD1;
#ifdef CRI_ALPHA_MOVIE
half2 uv3 : TEXCOORD2;
#endif
#ifdef CRI_APPLY_TARGET_ALPHA
float4 color : COLOR;
#endif
};
float4 _MainTex_ST;
float4 _MovieTexture_ST;
float4 _MovieChromaTexture_ST;
#ifdef CRI_ALPHA_MOVIE
float4 _MovieAlphaTexture_ST;
#endif
v2f vert(appdata v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = (TRANSFORM_TEX(v.texcoord, _MainTex) * _MovieTexture_ST.xy) + _MovieTexture_ST.zw;
o.uv2 = (TRANSFORM_TEX(v.texcoord, _MainTex) * _MovieChromaTexture_ST.xy) + _MovieChromaTexture_ST.zw;
#ifdef CRI_ALPHA_MOVIE
o.uv3 = (TRANSFORM_TEX(v.texcoord, _MainTex) * _MovieAlphaTexture_ST.xy) + _MovieAlphaTexture_ST.zw;
#endif
#ifdef CRI_APPLY_TARGET_ALPHA
o.color = v.color;
#endif
return o;
}
static const fixed3x3 yuv_to_rgb = {
{1.16438, 0.0, 1.59603},
{1.16438, -0.39176, -0.81297},
{1.16438, 2.01723, 0.0}
};
sampler2D _TextureY;
#ifdef CRI_UV_FORMAT
sampler2D _TextureUV;
#else
sampler2D _TextureU;
sampler2D _TextureV;
#endif
#ifdef CRI_ALPHA_MOVIE
sampler2D _TextureA;
#endif
fixed _Transparency;
fixed4 frag(v2f i) : COLOR
{
fixed3 yuv;
yuv.r = tex2D(_TextureY, i.uv).a;
#ifdef CRI_UV_FORMAT
yuv.g = tex2D(_TextureUV, i.uv2).r;
yuv.b = tex2D(_TextureUV, i.uv2).g;
#else
yuv.g = tex2D(_TextureU, i.uv2).a;
yuv.b = tex2D(_TextureV, i.uv2).a;
#endif
yuv = yuv + fixed3(-0.06275, -0.50196, -0.50196);
fixed4 color;
color.rgb = mul(yuv_to_rgb, yuv);
#ifdef CRI_LINEAR_COLORSPACE
color.rgb = pow(max(color.rgb, 0), 2.2);
#endif
#ifdef CRI_ALPHA_MOVIE
color.a = tex2D(_TextureA, i.uv3).a;
#else
color.a = 1.0;
#endif
#ifdef CRI_APPLY_TARGET_ALPHA
color.a = color.a * i.color.a;
#endif
color.a *= 1 - _Transparency;
return color;
}
ENDCG
}
}
}
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 510c610c0d60660428de1beaa9982292
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1f17bd2af1cbd884fb63295a765287fb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,32 @@
fileFormatVersion: 2
guid: 521d7b784dd40df459e34bafc2167eab
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Android: Android
second:
enabled: 1
settings: {}
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: dd5b85be0649e2646ad30cd7c49913b2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,97 @@
fileFormatVersion: 2
guid: fd84e4785f0e6d1408d320599643aa77
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 0
Exclude Editor: 1
Exclude Linux: 1
Exclude Linux64: 1
Exclude LinuxUniversal: 1
Exclude OSXUniversal: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Android: Android
second:
enabled: 1
settings:
CPU: ARM64
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
CPU: AnyCPU
DefaultValueInitialized: true
OS: AnyOS
- first:
Facebook: Win
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: x86
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: LinuxUniversal
second:
enabled: 0
settings:
CPU: None
- first:
Standalone: OSXUniversal
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 68c2d2dcab5ddcc47a56b2c3c165e7f8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,145 @@
fileFormatVersion: 2
guid: d6295746feec9704e95338f43a6d517a
timeCreated: 1433816086
licenseType: Pro
PluginImporter:
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
data:
first:
'': Any
second:
enabled: 0
settings:
Exclude Android: 0
Exclude Editor: 1
Exclude Linux: 1
Exclude Linux64: 1
Exclude LinuxUniversal: 1
Exclude OSXIntel: 1
Exclude OSXIntel64: 1
Exclude OSXUniversal: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
Exclude WindowsStoreApps: 1
Exclude iOS: 1
Exclude tvOS: 1
data:
first:
'': Editor
second:
enabled: 0
settings:
CPU: AnyCPU
OS: AnyOS
data:
first:
Android: Android
second:
enabled: 1
settings:
CPU: ARMv7
data:
first:
Any:
second:
enabled: 0
settings: {}
data:
first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
data:
first:
Facebook: Win
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: x86
data:
first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: x86_64
data:
first:
Standalone: OSXIntel
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Standalone: OSXIntel64
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Standalone: Win
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
DontProcess: False
PlaceholderPath:
SDK: AnySDK
ScriptingBackend: AnyScriptingBackend
data:
first:
iPhone: iOS
second:
enabled: 0
settings:
CompileFlags:
FrameworkDependencies:
data:
first:
tvOS: tvOS
second:
enabled: 0
settings:
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,146 @@
fileFormatVersion: 2
guid: 7b4b9afed8aedea4dafc1a56bf9806f0
timeCreated: 1486043713
licenseType: Pro
PluginImporter:
serializedVersion: 2
iconMap: {}
executionOrder: {}
isPreloaded: 0
isOverridable: 0
platformData:
data:
first:
'': Any
second:
enabled: 0
settings:
Exclude Android: 0
Exclude Editor: 1
Exclude Linux: 1
Exclude Linux64: 1
Exclude LinuxUniversal: 1
Exclude OSXIntel: 1
Exclude OSXIntel64: 1
Exclude OSXUniversal: 1
Exclude PS4: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
Exclude WindowsStoreApps: 1
Exclude iOS: 1
Exclude tvOS: 1
data:
first:
'': Editor
second:
enabled: 0
settings:
CPU: AnyCPU
OS: AnyOS
data:
first:
Android: Android
second:
enabled: 1
settings:
CPU: ARMv7
data:
first:
Any:
second:
enabled: 0
settings: {}
data:
first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
data:
first:
Facebook: Win
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: x86
data:
first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: x86_64
data:
first:
Standalone: OSXIntel
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Standalone: OSXIntel64
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Standalone: Win
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
data:
first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
DontProcess: False
PlaceholderPath:
SDK: AnySDK
ScriptingBackend: AnyScriptingBackend
data:
first:
iPhone: iOS
second:
enabled: 0
settings:
CompileFlags:
FrameworkDependencies:
data:
first:
tvOS: tvOS
second:
enabled: 0
settings:
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1c126827a14a46747863272b2b214f9b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,131 @@
fileFormatVersion: 2
guid: 8a5e2b17a976caf4397218dfc89ddd43
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Android: 0
Exclude Editor: 1
Exclude Linux: 1
Exclude Linux64: 1
Exclude LinuxUniversal: 1
Exclude OSXIntel: 1
Exclude OSXIntel64: 1
Exclude OSXUniversal: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
Exclude WindowsStoreApps: 1
Exclude iOS: 1
Exclude tvOS: 1
- first:
: Editor
second:
enabled: 0
settings:
CPU: AnyCPU
OS: AnyOS
- first:
Android: Android
second:
enabled: 1
settings:
CPU: x86
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Facebook: Win
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Linux
second:
enabled: 0
settings:
CPU: x86
- first:
Standalone: Linux64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: OSXIntel
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: OSXIntel64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Win
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
DontProcess: False
PlaceholderPath:
SDK: AnySDK
ScriptingBackend: AnyScriptingBackend
- first:
iPhone: iOS
second:
enabled: 0
settings:
CompileFlags:
FrameworkDependencies:
- first:
tvOS: tvOS
second:
enabled: 0
settings:
CompileFlags:
FrameworkDependencies:
userData:
assetBundleName:
assetBundleVariant: