aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-multimedia/gstreamer/gst-plugins-good/0016-videocrop-support-getting-NV12-image-details.patch
blob: e5a1bed63d3d4ea895cef9a68a9787e91b450a3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
From 47cf0121df5c54d665ccbf9a721cddf547fbbce3 Mon Sep 17 00:00:00 2001
From: Kazunori Kobayashi <kkobayas@igel.co.jp>
Date: Thu, 4 Oct 2012 11:29:44 +0900
Subject: [PATCH 16/31] videocrop: support getting NV12 image details

This patch adds a new pixel format definition that is NV12 format.
The color format type of NV12 is classified into VIDEO_CROP_PIXEL_FORMAT_SEMI_PLANAR.
When rowstride or chroma_byte_offset is contained in caps, image
details reflects these value.

This is preliminary for NV12 zero-copy cropping.
---
 gst/videocrop/gstvideocrop.c |   21 +++++++++++++++++++++
 gst/videocrop/gstvideocrop.h |    8 ++++++--
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/gst/videocrop/gstvideocrop.c b/gst/videocrop/gstvideocrop.c
index 0743719..b6336da 100644
--- a/gst/videocrop/gstvideocrop.c
+++ b/gst/videocrop/gstvideocrop.c
@@ -328,6 +328,27 @@ gst_video_crop_get_image_details_from_structure (GstVideoCrop * vcrop,
             details->v_stride * (GST_ROUND_UP_2 (height) / 2);
         break;
       }
+      case GST_MAKE_FOURCC ('N', 'V', '1', '2'):
+      {
+        gint stride, chroma_byte_offset;
+
+        details->packing = VIDEO_CROP_PIXEL_FORMAT_SEMI_PLANAR;
+
+        if (gst_structure_get_int (structure, "rowstride", &stride))
+          details->stride = stride;
+        else
+          details->stride = GST_ROUND_UP_2 (width);
+
+        details->y_off = 0;
+        if (gst_structure_get_int (structure, "chroma_byte_offset",
+                &chroma_byte_offset))
+          details->uv_off = chroma_byte_offset;
+        else
+          details->uv_off = details->stride * GST_ROUND_UP_2 (height);
+
+        details->size = details->uv_off * 3 / 2;
+      }
+        break;
       default:
         goto unknown_format;
     }
diff --git a/gst/videocrop/gstvideocrop.h b/gst/videocrop/gstvideocrop.h
index 5cfe03e..2e5d5e6 100644
--- a/gst/videocrop/gstvideocrop.h
+++ b/gst/videocrop/gstvideocrop.h
@@ -37,7 +37,8 @@ G_BEGIN_DECLS
 {
   VIDEO_CROP_PIXEL_FORMAT_PACKED_SIMPLE = 0,    /* RGBx, AYUV */
   VIDEO_CROP_PIXEL_FORMAT_PACKED_COMPLEX,       /* UYVY, YVYU */
-  VIDEO_CROP_PIXEL_FORMAT_PLANAR        /* I420, YV12 */
+  VIDEO_CROP_PIXEL_FORMAT_PLANAR,       /* I420, YV12 */
+  VIDEO_CROP_PIXEL_FORMAT_SEMI_PLANAR   /* NV12 */
 } VideoCropPixelFormat;
 
 typedef struct _GstVideoCropImageDetails GstVideoCropImageDetails;
@@ -51,7 +52,7 @@ struct _GstVideoCropImageDetails
   guint size;
 
   /* for packed RGB and YUV */
-  guint stride;
+  guint stride;                 /* common use in semi-planar */
   guint bytes_per_pixel;
   guint8 macro_y_off;           /* for YUY2, YVYU, UYVY, Y offset within macropixel in bytes */
 
@@ -59,6 +60,9 @@ struct _GstVideoCropImageDetails
   guint y_stride, y_off;
   guint u_stride, u_off;
   guint v_stride, v_off;
+
+  /* for semi-planar YUV */
+  guint uv_off;
 };
 
 typedef struct _GstVideoCrop GstVideoCrop;
-- 
1.7.9.5