From 9f890c5935b735d57799f6ac82b89cf446dac777 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Sat, 12 Sep 2015 00:51:52 +1000 Subject: [PATCH] vtdec: Use R/RG textures for NV12 when the context provides them Fixes playback to GL memory on iOS, where the colours are messed up by passing Luminance/LuminanceAlpha textures where color convert expects R/RG textures. https://bugzilla.gnome.org/show_bug.cgi?id=754504 --- sys/applemedia/corevideotexturecache.m | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/sys/applemedia/corevideotexturecache.m b/sys/applemedia/corevideotexturecache.m index a35dcf65d4..d5b9aeb74e 100644 --- a/sys/applemedia/corevideotexturecache.m +++ b/sys/applemedia/corevideotexturecache.m @@ -172,30 +172,40 @@ gl_mem_from_buffer (GstCoreVideoTextureCache * cache, CVOpenGLESTextureGetName (texture), CVOpenGLESTextureGetTarget (texture), &cache->input_info, 0, NULL, texture, (GDestroyNotify) CFRelease); break; - case GST_VIDEO_FORMAT_NV12: + case GST_VIDEO_FORMAT_NV12: { + GstVideoGLTextureType textype; + GLenum texfmt; + + textype = gst_gl_texture_type_from_format (cache->ctx, GST_VIDEO_FORMAT_NV12, 0); + texfmt = gst_gl_format_from_gl_texture_type (textype); + /* vtdec does NV12 on iOS when doing GLMemory */ if (CVOpenGLESTextureCacheCreateTextureFromImage (kCFAllocatorDefault, - cache->cache, pixel_buf, NULL, GL_TEXTURE_2D, GL_LUMINANCE, + cache->cache, pixel_buf, NULL, GL_TEXTURE_2D, texfmt, GST_VIDEO_INFO_WIDTH (&cache->input_info), GST_VIDEO_INFO_HEIGHT (&cache->input_info), - GL_LUMINANCE, GL_UNSIGNED_BYTE, 0, &texture) != kCVReturnSuccess) + texfmt, GL_UNSIGNED_BYTE, 0, &texture) != kCVReturnSuccess) goto error; *mem1 = (GstMemory *) gst_gl_memory_wrapped_texture (cache->ctx, CVOpenGLESTextureGetName (texture), CVOpenGLESTextureGetTarget (texture), &cache->input_info, 0, NULL, texture, (GDestroyNotify) CFRelease); + textype = gst_gl_texture_type_from_format (cache->ctx, GST_VIDEO_FORMAT_NV12, 1); + texfmt = gst_gl_format_from_gl_texture_type (textype); + if (CVOpenGLESTextureCacheCreateTextureFromImage (kCFAllocatorDefault, - cache->cache, pixel_buf, NULL, GL_TEXTURE_2D, GL_LUMINANCE_ALPHA, + cache->cache, pixel_buf, NULL, GL_TEXTURE_2D, texfmt, GST_VIDEO_INFO_WIDTH (&cache->input_info) / 2, GST_VIDEO_INFO_HEIGHT (&cache->input_info) / 2, - GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 1, &texture) != kCVReturnSuccess) + texfmt, GL_UNSIGNED_BYTE, 1, &texture) != kCVReturnSuccess) goto error; *mem2 = (GstMemory *) gst_gl_memory_wrapped_texture (cache->ctx, CVOpenGLESTextureGetName (texture), CVOpenGLESTextureGetTarget (texture), &cache->input_info, 0, NULL, texture, (GDestroyNotify) CFRelease); break; + } #endif default: g_warn_if_reached ();