Skip to content

Instantly share code, notes, and snippets.

@djg
Created February 23, 2016 00:34
Show Gist options
  • Save djg/35c7a8bea6a7f8989eae to your computer and use it in GitHub Desktop.
Save djg/35c7a8bea6a7f8989eae to your computer and use it in GitHub Desktop.
# YCBCR422
diff --git a/gfx/2d/MacIOSurface.cpp b/gfx/2d/MacIOSurface.cpp
index 4ac0a50..8231d8a 100644
--- a/gfx/2d/MacIOSurface.cpp
+++ b/gfx/2d/MacIOSurface.cpp
@@ -476,6 +476,8 @@ MacIOSurface::GetFormat()
OSType pixelFormat = GetPixelFormat();
if (pixelFormat == '420v') {
return SurfaceFormat::NV12;
+ } else if (pixelFormat == '2vuy') {
+ return SurfaceFormat::YUV422;
} else {
return HasAlpha() ? SurfaceFormat::R8G8B8A8 : SurfaceFormat::R8G8B8X8;
}
@@ -500,6 +502,12 @@ MacIOSurface::CGLTexImageIOSurface2D(CGLContextObj ctx, size_t plane)
internalFormat = format = GL_LUMINANCE_ALPHA;
}
type = GL_UNSIGNED_BYTE;
+ } else if (pixelFormat == '2vuy') {
+ MOZ_ASSERT(plane == 0);
+
+ internalFormat = GL_RGB;
+ format = GL_APPLE_ycbcr_422;
+ type = GL_UNSIGNED_SHORT_8_8_REV_APPLE;
} else {
MOZ_ASSERT(plane == 0);
diff --git a/gfx/2d/Types.h b/gfx/2d/Types.h
index 3da1523..c44c679 100644
--- a/gfx/2d/Types.h
+++ b/gfx/2d/Types.h
@@ -54,6 +54,7 @@ enum class SurfaceFormat : int8_t {
// These ones are their own special cases.
YUV,
NV12,
+ YUV422,
// This represents the unknown format.
UNKNOWN,
@@ -80,6 +81,7 @@ inline bool IsOpaque(SurfaceFormat aFormat)
case SurfaceFormat::R5G6B5_UINT16:
case SurfaceFormat::YUV:
case SurfaceFormat::NV12:
+ case SurfaceFormat::YUV422:
return true;
default:
return false;
diff --git a/gfx/layers/LayersLogging.cpp b/gfx/layers/LayersLogging.cpp
index ff6b79b..22fd69c 100644
--- a/gfx/layers/LayersLogging.cpp
+++ b/gfx/layers/LayersLogging.cpp
@@ -300,6 +300,7 @@ AppendToString(std::stringstream& aStream, mozilla::gfx::SurfaceFormat format,
case SurfaceFormat::A8: aStream << "SurfaceFormat::A8"; break;
case SurfaceFormat::YUV: aStream << "SurfaceFormat::YUV"; break;
case SurfaceFormat::NV12: aStream << "SurfaceFormat::NV12"; break;
+ case SurfaceFormat::YUV422: aStream << "SurfaceFormat::YUV422"; break;
case SurfaceFormat::UNKNOWN: aStream << "SurfaceFormat::UNKNOWN"; break;
default:
NS_ERROR("unknown surface format");
diff --git a/gfx/layers/opengl/CompositorOGL.cpp b/gfx/layers/opengl/CompositorOGL.cpp
index f52ad67..9c38484 100644
--- a/gfx/layers/opengl/CompositorOGL.cpp
+++ b/gfx/layers/opengl/CompositorOGL.cpp
@@ -867,7 +867,8 @@ CompositorOGL::GetShaderConfigFor(Effect *aEffect,
MOZ_ASSERT_IF(source->GetTextureTarget() == LOCAL_GL_TEXTURE_RECTANGLE_ARB,
source->GetFormat() == gfx::SurfaceFormat::R8G8B8A8 ||
source->GetFormat() == gfx::SurfaceFormat::R8G8B8X8 ||
- source->GetFormat() == gfx::SurfaceFormat::R5G6B5_UINT16);
+ source->GetFormat() == gfx::SurfaceFormat::R5G6B5_UINT16 ||
+ source->GetFormat() == gfx::SurfaceFormat::YUV422 );
config = ShaderConfigFromTargetAndFormat(source->GetTextureTarget(),
source->GetFormat());
if (!texturedEffect->mPremultiplied) {
diff --git a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp
index bea27eb..e0ff22d 100644
--- a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp
+++ b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp
@@ -77,7 +77,11 @@ MacIOSurfaceTextureHostOGL::SetCompositor(Compositor* aCompositor)
gfx::SurfaceFormat
MacIOSurfaceTextureHostOGL::GetFormat() const {
- return mSurface->GetFormat();
+ gfx::SurfaceFormat fmt = mSurface->GetFormat();
+ if (fmt != gfx::SurfaceFormat::YUV422) {
+ return fmt;
+ }
+ return gfx::SurfaceFormat::R8G8B8X8;
}
gfx::IntSize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment