applemedia: improve vtenc/vtdec performance
authorOle André Vadla Ravnås <oravnas@cisco.com>
Mon, 8 Nov 2010 12:49:04 +0000 (13:49 +0100)
committerOle André Vadla Ravnås <oravnas@cisco.com>
Mon, 8 Nov 2010 13:02:50 +0000 (14:02 +0100)
Profiling of H.264 encode and decode revealed that conversions
between packed and planar were happening behind the scenes.

Hence we now choose I420 instead of YUY2.

sys/applemedia/cvapi.h
sys/applemedia/vtdec.c
sys/applemedia/vtenc.c
sys/applemedia/vth264decbin.c
sys/applemedia/vth264encbin.c

index 9c792b9..3d99e38 100644 (file)
@@ -47,8 +47,9 @@ enum _CVReturn
 
 enum _CVPixelFormatType
 {
-  kCVPixelFormatType_422YpCbCr8Deprecated   = 'yuvs',
-  kCVPixelFormatType_422YpCbCr8             = '2vuy'
+  kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange = '420v',
+  kCVPixelFormatType_422YpCbCr8Deprecated         = 'yuvs',
+  kCVPixelFormatType_422YpCbCr8                   = '2vuy'
 };
 
 struct _GstCVApi
index cca78eb..24b40ca 100644 (file)
@@ -94,7 +94,7 @@ gst_vtdec_base_init (GstVTDecClass * klass)
       GST_PAD_SRC,
       GST_PAD_ALWAYS,
       gst_caps_new_simple ("video/x-raw-yuv",
-          "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'),
+          "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
           "width", GST_TYPE_INT_RANGE, min_width, max_width,
           "height", GST_TYPE_INT_RANGE, min_height, max_height,
           "framerate", GST_TYPE_FRACTION_RANGE,
@@ -345,7 +345,7 @@ gst_vtdec_create_session (GstVTDec * self, CMFormatDescriptionRef fmt_desc)
   pb_attrs = CFDictionaryCreateMutable (NULL, 0, &kCFTypeDictionaryKeyCallBacks,
       &kCFTypeDictionaryValueCallBacks);
   gst_vtutil_dict_set_i32 (pb_attrs, *(cv->kCVPixelBufferPixelFormatTypeKey),
-      kCVPixelFormatType_422YpCbCr8Deprecated);
+      kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange);
   gst_vtutil_dict_set_i32 (pb_attrs, *(cv->kCVPixelBufferWidthKey),
       self->negotiated_width);
   gst_vtutil_dict_set_i32 (pb_attrs, *(cv->kCVPixelBufferHeightKey),
index 932944a..45e0eff 100644 (file)
@@ -112,7 +112,7 @@ gst_vtenc_base_init (GstVTEncClass * klass)
       GST_PAD_SINK,
       GST_PAD_ALWAYS,
       gst_caps_new_simple ("video/x-raw-yuv",
-          "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'),
+          "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('I', '4', '2', '0'),
           "width", GST_TYPE_INT_RANGE, min_width, max_width,
           "height", GST_TYPE_INT_RANGE, min_height, max_height,
           "framerate", GST_TYPE_FRACTION_RANGE,
@@ -491,13 +491,11 @@ gst_vtenc_create_session (GstVTEnc * self)
   pb_attrs = CFDictionaryCreateMutable (NULL, 0, &kCFTypeDictionaryKeyCallBacks,
       &kCFTypeDictionaryValueCallBacks);
   gst_vtutil_dict_set_i32 (pb_attrs, *(cv->kCVPixelBufferPixelFormatTypeKey),
-      kCVPixelFormatType_422YpCbCr8Deprecated);
+      kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange);
   gst_vtutil_dict_set_i32 (pb_attrs, *(cv->kCVPixelBufferWidthKey),
       self->negotiated_width);
   gst_vtutil_dict_set_i32 (pb_attrs, *(cv->kCVPixelBufferHeightKey),
       self->negotiated_height);
-  gst_vtutil_dict_set_i32 (pb_attrs,
-      *(cv->kCVPixelBufferBytesPerRowAlignmentKey), 2 * self->negotiated_width);
 
   callback.func = gst_vtenc_output_buffer;
   callback.data = self;
index e78c71d..d2c248d 100644 (file)
@@ -57,7 +57,7 @@ static GstStaticPadTemplate vth264decbin_src_template =
 GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("YUY2"))
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420"))
     );
 
 #define TAA_VT_H264_DEC_BIN_GET_PRIVATE(obj)  \
index 30f8817..54026bc 100644 (file)
@@ -48,7 +48,7 @@ static GstStaticPadTemplate vth264encbin_sink_template =
 GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("YUY2"))
+    GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("I420"))
     );
 
 static GstStaticPadTemplate vth264encbin_src_template =