applemedia: avfvideosrc: change texture format from BGRA to NV12 on iOS
authorAlessandro Decina <alessandro.d@gmail.com>
Wed, 6 Jan 2016 00:29:15 +0000 (11:29 +1100)
committerAlessandro Decina <alessandro.d@gmail.com>
Wed, 6 Jan 2016 00:43:37 +0000 (11:43 +1100)
Change texture format from BGRA to NV12. This allows a pipeline like avfvideosrc
! tee name=t ! ... ! glimagesink t. ! ... ! gldownload ! vtenc_h264 ! ...  to
negotiate GLMemory. This makes the glimagesink branch much faster (obviously)
and triggers the 0-copy path between avfvideosrc and vtenc (using the CV meta).
Combined this results in a huge perf improvement on iOS (25-30% of CPU time in a
pipeline like the one above).

Note that this doesn't introduce a new shader conversion in the sink, since BGRA
textures had to be copied/converted from format=BGRA,texture-target=RECTANGLE to
format=RGBA,texture-target=2D anyway.

sys/applemedia/avfvideosrc.m

index 455fd2f..6d3390d 100644 (file)
@@ -55,7 +55,7 @@ static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
 #else
         GST_VIDEO_CAPS_MAKE_WITH_FEATURES
         (GST_CAPS_FEATURE_MEMORY_GL_MEMORY,
-            "BGRA") ", "
+            "NV12") ", "
         "texture-target = " GST_GL_TEXTURE_TARGET_2D_STR "; "
 #endif
         "video/x-raw, "
@@ -421,7 +421,7 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
 #if !HAVE_IOS
   GstVideoFormat gl_format = GST_VIDEO_FORMAT_UYVY;
 #else
-  GstVideoFormat gl_format = GST_VIDEO_FORMAT_BGRA;
+  GstVideoFormat gl_format = GST_VIDEO_FORMAT_NV12;
 #endif
 
   GST_DEBUG_OBJECT (element, "Getting device caps");