From 75ad1246a204b6e4e43cf41e9b7e65f5b0f64ea3 Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Tue, 10 Nov 2015 14:21:33 +1100 Subject: [PATCH] applemedia: fix vtdec texture sharing on ios 9.1 Use gst_gl_sized_gl_format_from_gl_format_type to get the format passed to CVOpenGLESTextureCacheCreateTextureFromImage. Before this change extracting the second texture from the pixel buffer was failing on ios 9.1. --- sys/applemedia/corevideotexturecache.m | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sys/applemedia/corevideotexturecache.m b/sys/applemedia/corevideotexturecache.m index 4d9547a2b3..706b6d68f3 100644 --- a/sys/applemedia/corevideotexturecache.m +++ b/sys/applemedia/corevideotexturecache.m @@ -187,34 +187,37 @@ gl_mem_from_buffer (GstCoreVideoTextureCache * cache, break; case GST_VIDEO_FORMAT_NV12: { GstVideoGLTextureType textype; - GLenum texfmt; + GLenum texifmt, texfmt; textype = gst_gl_texture_type_from_format (cache->ctx, GST_VIDEO_FORMAT_NV12, 0); - texfmt = gst_gl_format_from_gl_texture_type (textype); - gl_target = gst_gl_texture_target_from_gl (CVOpenGLESTextureGetTarget (texture)); + texifmt = gst_gl_format_from_gl_texture_type (textype); + texfmt = gst_gl_sized_gl_format_from_gl_format_type (cache->ctx, texifmt, GL_UNSIGNED_BYTE); /* vtdec does NV12 on iOS when doing GLMemory */ if (CVOpenGLESTextureCacheCreateTextureFromImage (kCFAllocatorDefault, - cache->cache, pixel_buf, NULL, GL_TEXTURE_2D, texfmt, + cache->cache, pixel_buf, NULL, GL_TEXTURE_2D, texifmt, GST_VIDEO_INFO_WIDTH (&cache->input_info), GST_VIDEO_INFO_HEIGHT (&cache->input_info), texfmt, GL_UNSIGNED_BYTE, 0, &texture) != kCVReturnSuccess) goto error; + gl_target = gst_gl_texture_target_from_gl (CVOpenGLESTextureGetTarget (texture)); *mem1 = (GstMemory *) gst_gl_memory_wrapped_texture (cache->ctx, CVOpenGLESTextureGetName (texture), gl_target, &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); + texifmt = gst_gl_format_from_gl_texture_type (textype); + texfmt = gst_gl_sized_gl_format_from_gl_format_type (cache->ctx, texifmt, GL_UNSIGNED_BYTE); if (CVOpenGLESTextureCacheCreateTextureFromImage (kCFAllocatorDefault, - cache->cache, pixel_buf, NULL, GL_TEXTURE_2D, texfmt, + cache->cache, pixel_buf, NULL, GL_TEXTURE_2D, texifmt, GST_VIDEO_INFO_WIDTH (&cache->input_info) / 2, GST_VIDEO_INFO_HEIGHT (&cache->input_info) / 2, texfmt, GL_UNSIGNED_BYTE, 1, &texture) != kCVReturnSuccess) goto error; + gl_target = gst_gl_texture_target_from_gl (CVOpenGLESTextureGetTarget (texture)); *mem2 = (GstMemory *) gst_gl_memory_wrapped_texture (cache->ctx, CVOpenGLESTextureGetName (texture), gl_target, &cache->input_info, 0, NULL, texture, (GDestroyNotify) CFRelease);