Merge branch 'tizen' into tizen_gst_1.19.2
[platform/upstream/gstreamer.git] / gst-libs / gst / video / video-info.c
index 6f9fc7b..93bede5 100644 (file)
@@ -798,6 +798,7 @@ fill_planes (GstVideoInfo * info, gsize plane_size[GST_VIDEO_MAX_PLANES])
     case GST_VIDEO_FORMAT_RGBA:
     case GST_VIDEO_FORMAT_BGRx:
     case GST_VIDEO_FORMAT_BGRA:
+    case GST_VIDEO_FORMAT_SR32:
     case GST_VIDEO_FORMAT_xRGB:
     case GST_VIDEO_FORMAT_ARGB:
     case GST_VIDEO_FORMAT_xBGR:
@@ -847,6 +848,7 @@ fill_planes (GstVideoInfo * info, gsize plane_size[GST_VIDEO_MAX_PLANES])
       break;
     case GST_VIDEO_FORMAT_GRAY16_BE:
     case GST_VIDEO_FORMAT_GRAY16_LE:
+    case GST_VIDEO_FORMAT_INVZ:
       info->stride[0] = GST_ROUND_UP_4 (width * 2);
       info->offset[0] = 0;
       info->size = info->stride[0] * height;
@@ -878,7 +880,12 @@ fill_planes (GstVideoInfo * info, gsize plane_size[GST_VIDEO_MAX_PLANES])
       info->size = info->stride[0] * height;
       break;
     case GST_VIDEO_FORMAT_I420:
+    case GST_VIDEO_FORMAT_S420:
     case GST_VIDEO_FORMAT_YV12:        /* same as I420, but plane 1+2 swapped */
+#ifdef TIZEN_PROFILE_TV
+    case GST_VIDEO_FORMAT_STV0:
+    case GST_VIDEO_FORMAT_STV1:
+#endif
       info->stride[0] = GST_ROUND_UP_4 (width);
       info->stride[1] = GST_ROUND_UP_4 (GST_ROUND_UP_2 (width) / 2);
       info->stride[2] = info->stride[1];
@@ -934,15 +941,34 @@ fill_planes (GstVideoInfo * info, gsize plane_size[GST_VIDEO_MAX_PLANES])
       info->size = info->stride[0] * height * 4;
       break;
     case GST_VIDEO_FORMAT_NV12:
+#ifdef TIZEN_FEATURE_VIDEO_MODIFICATION
+    case GST_VIDEO_FORMAT_SN12:
+    case GST_VIDEO_FORMAT_ST12:
+    case GST_VIDEO_FORMAT_SN21:
+#endif
     case GST_VIDEO_FORMAT_NV21:
       info->stride[0] = GST_ROUND_UP_4 (width);
       info->stride[1] = info->stride[0];
       info->offset[0] = 0;
       info->offset[1] = info->stride[0] * GST_ROUND_UP_2 (height);
+#ifdef TIZEN_FEATURE_VIDEO_MODIFICATION
+      info->size = info->stride[0] * GST_ROUND_UP_2 (height) * 3 / 2;
+#else
       cr_h = GST_ROUND_UP_2 (height) / 2;
       if (GST_VIDEO_INFO_IS_INTERLACED (info))
         cr_h = GST_ROUND_UP_2 (cr_h);
       info->size = info->offset[1] + info->stride[0] * cr_h;
+#endif
+      break;
+    case GST_VIDEO_FORMAT_AV12:
+      info->stride[0] = GST_ROUND_UP_4 (width);
+      info->stride[1] = info->stride[0];
+      info->stride[2] = info->stride[0];
+      info->offset[0] = 0;
+      info->offset[1] = info->stride[0] * GST_ROUND_UP_2 (height);
+      info->offset[2] =
+          info->offset[1] + (info->stride[1] * GST_ROUND_UP_2 (height) / 2);
+      info->size = info->offset[2] + info->stride[2] * GST_ROUND_UP_2 (height);
       break;
     case GST_VIDEO_FORMAT_NV16:
     case GST_VIDEO_FORMAT_NV61:
@@ -1167,6 +1193,9 @@ fill_planes (GstVideoInfo * info, gsize plane_size[GST_VIDEO_MAX_PLANES])
     case GST_VIDEO_FORMAT_ENCODED:
       break;
     case GST_VIDEO_FORMAT_UNKNOWN:
+#ifdef TIZEN_FEATURE_VIDEO_MODIFICATION
+    default:
+#endif
       GST_ERROR ("invalid format");
       g_warning ("invalid format");
       return FALSE;
@@ -1176,13 +1205,13 @@ fill_planes (GstVideoInfo * info, gsize plane_size[GST_VIDEO_MAX_PLANES])
   if (plane_size) {
     for (i = 0; i < GST_VIDEO_MAX_PLANES; i++) {
       if (i < GST_VIDEO_INFO_N_PLANES (info)) {
-        gint comps[GST_VIDEO_MAX_COMPONENTS];
+        gint comp[GST_VIDEO_MAX_COMPONENTS];
         guint plane_height;
 
         /* Convert plane index to component index */
-        gst_video_format_info_component (info->finfo, i, comps);
+        gst_video_format_info_component (info->finfo, i, comp);
         plane_height =
-            GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (info->finfo, comps[0],
+            GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (info->finfo, comp[0],
             GST_VIDEO_INFO_FIELD_HEIGHT (info));
         plane_size[i] = plane_height * GST_VIDEO_INFO_PLANE_STRIDE (info, i);
       } else {
@@ -1367,11 +1396,14 @@ gst_video_info_align_full (GstVideoInfo * info, GstVideoAlignment * align,
     GST_LOG ("left padding %u", align->padding_left);
     aligned = TRUE;
     for (i = 0; i < n_planes; i++) {
+      gint comp[GST_VIDEO_MAX_COMPONENTS];
       gint hedge;
 
       /* this is the amount of pixels to add as left padding */
-      hedge = GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (vinfo, i, align->padding_left);
-      hedge *= GST_VIDEO_FORMAT_INFO_PSTRIDE (vinfo, i);
+      gst_video_format_info_component (vinfo, i, comp);
+      hedge = GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (vinfo, comp[0],
+          align->padding_left);
+      hedge *= GST_VIDEO_FORMAT_INFO_PSTRIDE (vinfo, comp[0]);
 
       GST_LOG ("plane %d, padding %d, alignment %u", i, hedge,
           align->stride_align[i]);
@@ -1419,25 +1451,20 @@ gst_video_info_align_full (GstVideoInfo * info, GstVideoAlignment * align,
   info->height = height;
 
   for (i = 0; i < n_planes; i++) {
-    gint vedge, hedge, comp;
-
-    /* Find the component for this plane, FIXME, we assume the plane number and
-     * component number is the same for now, for scaling the dimensions this is
-     * currently true for all formats but it might not be when adding new
-     * formats. We might need to add a plane subsamling in the format info to
-     * make this more generic or maybe use a plane -> component mapping. */
-    comp = i;
+    gint comp[GST_VIDEO_MAX_COMPONENTS];
+    gint vedge, hedge;
 
+    gst_video_format_info_component (info->finfo, i, comp);
     hedge =
-        GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (vinfo, comp, align->padding_left);
+        GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (vinfo, comp[0], align->padding_left);
     vedge =
-        GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (vinfo, comp, align->padding_top);
+        GST_VIDEO_FORMAT_INFO_SCALE_HEIGHT (vinfo, comp[0], align->padding_top);
 
     GST_DEBUG ("plane %d: comp: %d, hedge %d vedge %d align %d stride %d", i,
-        comp, hedge, vedge, align->stride_align[i], info->stride[i]);
+        comp[0], hedge, vedge, align->stride_align[i], info->stride[i]);
 
     info->offset[i] += (vedge * info->stride[i]) +
-        (hedge * GST_VIDEO_FORMAT_INFO_PSTRIDE (vinfo, comp));
+        (hedge * GST_VIDEO_FORMAT_INFO_PSTRIDE (vinfo, comp[0]));
   }
 
   return TRUE;