summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Schmidt <jan@centricular.com>2015-09-12 00:51:52 +1000
committerJan Schmidt <jan@centricular.com>2015-09-12 04:33:34 +1000
commit9f890c5935b735d57799f6ac82b89cf446dac777 (patch)
tree2eb8e7b25a0f54a0fc8c3fa7db0ce71d7138d347
parent0d7d7f6c927530b2b3544c190f868fdf68e0f9de (diff)
downloadgstreamer-plugins-bad-9f890c5935b735d57799f6ac82b89cf446dac777.tar.gz
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
-rw-r--r--sys/applemedia/corevideotexturecache.m20
1 files changed, 15 insertions, 5 deletions
diff --git a/sys/applemedia/corevideotexturecache.m b/sys/applemedia/corevideotexturecache.m
index a35dcf65d..d5b9aeb74 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 ();