diff options
author | Markus Ebner <info@ebner-markus.de> | 2021-04-07 18:54:49 +0200 |
---|---|---|
committer | GStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2021-04-10 11:26:59 +0000 |
commit | e31cbce4d50c4c5e63f955d6ead2476786e0e801 (patch) | |
tree | e039117c843de4797e22545f16ae9ee88b8e2232 | |
parent | 3ba8abb0560277ec0a78cc180162e1ce8553a0c1 (diff) |
videocrop: Added support for planar pixel formats > 8bits
- Added support for planar pixel formats with depths greater than 8bits
to transform_planar implementation
- Added a whole lot of new pixel formats to the support-list
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/515>
-rw-r--r-- | gst/videocrop/gstvideocrop-private.h | 25 | ||||
-rw-r--r-- | gst/videocrop/gstvideocrop.c | 29 | ||||
-rw-r--r-- | gst/videocrop/gstvideocrop.h | 27 |
3 files changed, 60 insertions, 21 deletions
diff --git a/gst/videocrop/gstvideocrop-private.h b/gst/videocrop/gstvideocrop-private.h index 7cae3b1ec..6e52ce39d 100644 --- a/gst/videocrop/gstvideocrop-private.h +++ b/gst/videocrop/gstvideocrop-private.h @@ -7,14 +7,23 @@ * between both, avoiding the need of manual synchronization */ +#define VIDEO_CROP_FORMATS_PACKED_SIMPLE "RGB, BGR, RGB16, RGB15, " \ + "RGBx, xRGB, BGRx, xBGR, RGBA, ARGB, BGRA, ABGR, " \ + "GRAY8, GRAY16_LE, GRAY16_BE, AYUV" +#define VIDEO_CROP_FORMATS_PACKED_COMPLEX "YVYU, YUY2, UYVY" +#define VIDEO_CROP_FORMATS_PLANAR "I420, A420, YV12, Y444, Y42B, Y41B, " \ + "I420_10BE, A420_10BE, Y444_10BE, A444_10BE, I422_10BE, A422_10BE, " \ + "I420_10LE, A420_10LE, Y444_10LE, A444_10LE, I422_10LE, A422_10LE, " \ + "I420_12BE, Y444_12BE, I422_12BE, " \ + "I420_12LE, Y444_12LE, I422_12LE" +#define VIDEO_CROP_FORMATS_SEMI_PLANAR "NV12, NV21" + +/* aspectratiocrop uses videocrop. sync caps changes between both */ #define VIDEO_CROP_CAPS \ - GST_VIDEO_CAPS_MAKE ("{ RGBx, xRGB, BGRx, xBGR, " \ - "RGBA, ARGB, BGRA, ABGR, RGB, BGR, AYUV, YUY2, Y444, " \ - "Y42B, Y41B, YVYU, UYVY, I420, YV12, RGB16, RGB15, " \ - "GRAY8, NV12, NV21, GRAY16_LE, GRAY16_BE }") "; " \ - "video/x-raw(ANY), " \ - "width = " GST_VIDEO_SIZE_RANGE ", " \ - "height = " GST_VIDEO_SIZE_RANGE ", " \ - "framerate = " GST_VIDEO_FPS_RANGE + GST_VIDEO_CAPS_MAKE ("{" \ + VIDEO_CROP_FORMATS_PACKED_SIMPLE "," \ + VIDEO_CROP_FORMATS_PACKED_COMPLEX "," \ + VIDEO_CROP_FORMATS_PLANAR "," \ + VIDEO_CROP_FORMATS_SEMI_PLANAR "}") #endif /* __GST_VIDEO_CROP_PRIVATE_H__ */ diff --git a/gst/videocrop/gstvideocrop.c b/gst/videocrop/gstvideocrop.c index c9223e83b..3f904c028 100644 --- a/gst/videocrop/gstvideocrop.c +++ b/gst/videocrop/gstvideocrop.c @@ -341,11 +341,16 @@ gst_video_crop_transform_planar (GstVideoCrop * vcrop, guint subsampled_crop_left, subsampled_crop_top; guint copy_width; gint i; + gsize bytes_per_pixel; /* plane */ plane_in = GST_VIDEO_FRAME_PLANE_DATA (in_frame, p); plane_out = GST_VIDEO_FRAME_PLANE_DATA (out_frame, p); + /* To support > 8bit, we need to add a byte-multiplier that specifies + * how many bytes are used per pixel value */ + bytes_per_pixel = GST_VIDEO_FRAME_COMP_PSTRIDE (in_frame, p); + /* apply crop top/left * crop_top and crop_left have to be rounded down to the corresponding * subsampling factor, since, e.g.: the first line in a subsampled plane @@ -361,8 +366,9 @@ gst_video_crop_transform_planar (GstVideoCrop * vcrop, subsampled_crop_top) * GST_VIDEO_FRAME_PLANE_STRIDE (in_frame, p); plane_in += GST_VIDEO_FORMAT_INFO_SCALE_WIDTH (format_info, p, - subsampled_crop_left); - copy_width = (guint) GST_VIDEO_FRAME_COMP_WIDTH (out_frame, p); + subsampled_crop_left) * bytes_per_pixel; + copy_width = GST_VIDEO_FRAME_COMP_WIDTH (out_frame, p) * bytes_per_pixel; + for (i = 0; i < GST_VIDEO_FRAME_COMP_HEIGHT (out_frame, p); ++i) { memcpy (plane_out, plane_in, copy_width); @@ -821,9 +827,28 @@ gst_video_crop_set_info (GstVideoFilter * vfilter, GstCaps * in, } break; case GST_VIDEO_FORMAT_I420: + case GST_VIDEO_FORMAT_I420_10BE: + case GST_VIDEO_FORMAT_I420_10LE: + case GST_VIDEO_FORMAT_I420_12BE: + case GST_VIDEO_FORMAT_I420_12LE: + case GST_VIDEO_FORMAT_A420: + case GST_VIDEO_FORMAT_A420_10BE: + case GST_VIDEO_FORMAT_A420_10LE: case GST_VIDEO_FORMAT_YV12: case GST_VIDEO_FORMAT_Y444: + case GST_VIDEO_FORMAT_Y444_10BE: + case GST_VIDEO_FORMAT_Y444_10LE: + case GST_VIDEO_FORMAT_Y444_12BE: + case GST_VIDEO_FORMAT_Y444_12LE: + case GST_VIDEO_FORMAT_A444_10BE: + case GST_VIDEO_FORMAT_A444_10LE: case GST_VIDEO_FORMAT_Y42B: + case GST_VIDEO_FORMAT_I422_10BE: + case GST_VIDEO_FORMAT_I422_10LE: + case GST_VIDEO_FORMAT_A422_10BE: + case GST_VIDEO_FORMAT_A422_10LE: + case GST_VIDEO_FORMAT_I422_12BE: + case GST_VIDEO_FORMAT_I422_12LE: case GST_VIDEO_FORMAT_Y41B: crop->packing = VIDEO_CROP_PIXEL_FORMAT_PLANAR; break; diff --git a/gst/videocrop/gstvideocrop.h b/gst/videocrop/gstvideocrop.h index cf7588ee5..85b7d2f97 100644 --- a/gst/videocrop/gstvideocrop.h +++ b/gst/videocrop/gstvideocrop.h @@ -23,7 +23,6 @@ #include <gst/video/gstvideofilter.h> G_BEGIN_DECLS - #define GST_TYPE_VIDEO_CROP \ (gst_video_crop_get_type()) #define GST_VIDEO_CROP(obj) \ @@ -34,12 +33,20 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VIDEO_CROP)) #define GST_IS_VIDEO_CROP_CLASS(klass) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VIDEO_CROP)) - -typedef enum { - VIDEO_CROP_PIXEL_FORMAT_PACKED_SIMPLE = 0, /* RGBx, AYUV */ - VIDEO_CROP_PIXEL_FORMAT_PACKED_COMPLEX, /* UYVY, YVYU */ - VIDEO_CROP_PIXEL_FORMAT_PLANAR, /* I420, YV12, Y444 */ - VIDEO_CROP_PIXEL_FORMAT_SEMI_PLANAR /* NV12, NV21 */ + typedef enum +{ + /* RGB (+ variants), ARGB (+ variants), AYUV, GRAY */ + VIDEO_CROP_PIXEL_FORMAT_PACKED_SIMPLE = 0, + /* YVYU, YUY2, UYVY */ + VIDEO_CROP_PIXEL_FORMAT_PACKED_COMPLEX, + /* I420, A420, YV12, Y444, Y42B, Y41B, + * I420_10BE, A420_10BE, Y444_10BE, A444_10BE, I422_10BE, A422_10BE, + * I420_10LE, A420_10LE, Y444_10LE, A444_10LE, I422_10LE, A422_10LE, + * I420_12BE, Y444_12BE, I422_12BE, + * I420_12LE, Y444_12LE, I422_12LE */ + VIDEO_CROP_PIXEL_FORMAT_PLANAR, + /* NV12, NV21 */ + VIDEO_CROP_PIXEL_FORMAT_SEMI_PLANAR } VideoCropPixelFormat; typedef struct _GstVideoCropImageDetails GstVideoCropImageDetails; @@ -51,7 +58,7 @@ struct _GstVideoCrop { GstVideoFilter parent; - /*< private >*/ + /*< private > */ gint prop_left; gint prop_right; gint prop_top; @@ -66,7 +73,7 @@ struct _GstVideoCrop gint crop_top; gint crop_bottom; - VideoCropPixelFormat packing; + VideoCropPixelFormat packing; gint macro_y_off; gboolean raw_caps; @@ -80,6 +87,4 @@ struct _GstVideoCropClass GType gst_video_crop_get_type (void); G_END_DECLS - #endif /* __GST_VIDEO_CROP_H__ */ - |