From: Wim Taymans Date: Tue, 28 Jun 2011 12:03:43 +0000 (+0200) Subject: video: port to new video apis X-Git-Tag: RELEASE-0.11.1~541 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ead60adb33dabdb56520fe059d16d345039af24f;p=platform%2Fupstream%2Fgst-plugins-good.git video: port to new video apis --- diff --git a/gst/videofilter/gstgamma.c b/gst/videofilter/gstgamma.c index eaa0dc8..5873b4c 100644 --- a/gst/videofilter/gstgamma.c +++ b/gst/videofilter/gstgamma.c @@ -71,49 +71,23 @@ enum #define DEFAULT_PROP_GAMMA 1 static GstStaticPadTemplate gst_gamma_src_template = - GST_STATIC_PAD_TEMPLATE ("src", +GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV") ";" - GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";" - GST_VIDEO_CAPS_ABGR ";" GST_VIDEO_CAPS_RGBA ";" - GST_VIDEO_CAPS_YUV ("Y444") ";" - GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_RGBx ";" - GST_VIDEO_CAPS_xBGR ";" GST_VIDEO_CAPS_BGRx ";" - GST_VIDEO_CAPS_RGB ";" GST_VIDEO_CAPS_BGR ";" - GST_VIDEO_CAPS_YUV ("Y42B") ";" - GST_VIDEO_CAPS_YUV ("NV12") ";" - GST_VIDEO_CAPS_YUV ("NV21") ";" - GST_VIDEO_CAPS_YUV ("YUY2") ";" - GST_VIDEO_CAPS_YUV ("UYVY") ";" - GST_VIDEO_CAPS_YUV ("YVYU") ";" - GST_VIDEO_CAPS_YUV ("I420") ";" - GST_VIDEO_CAPS_YUV ("YV12") ";" - GST_VIDEO_CAPS_YUV ("IYUV") ";" GST_VIDEO_CAPS_YUV ("Y41B") - ) + GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ AYUV, " + "ARGB, BGRA, ABGR, RGBA, ABGR, RGBA, Y444, " + "xRGB, RGBx, xBGR, BGRx, RGB, BGR, Y42B, NV12, " + "NV21, YUY2, UYVY, YVYU, I420, YV12, IYUV, Y41B }")) ); static GstStaticPadTemplate gst_gamma_sink_template = - GST_STATIC_PAD_TEMPLATE ("sink", +GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV") ";" - GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";" - GST_VIDEO_CAPS_ABGR ";" GST_VIDEO_CAPS_RGBA ";" - GST_VIDEO_CAPS_YUV ("Y444") ";" - GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_RGBx ";" - GST_VIDEO_CAPS_xBGR ";" GST_VIDEO_CAPS_BGRx ";" - GST_VIDEO_CAPS_RGB ";" GST_VIDEO_CAPS_BGR ";" - GST_VIDEO_CAPS_YUV ("Y42B") ";" - GST_VIDEO_CAPS_YUV ("NV12") ";" - GST_VIDEO_CAPS_YUV ("NV21") ";" - GST_VIDEO_CAPS_YUV ("YUY2") ";" - GST_VIDEO_CAPS_YUV ("UYVY") ";" - GST_VIDEO_CAPS_YUV ("YVYU") ";" - GST_VIDEO_CAPS_YUV ("I420") ";" - GST_VIDEO_CAPS_YUV ("YV12") ";" - GST_VIDEO_CAPS_YUV ("IYUV") ";" GST_VIDEO_CAPS_YUV ("Y41B") - ) + GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ AYUV, " + "ARGB, BGRA, ABGR, RGBA, ABGR, RGBA, Y444, " + "xRGB, RGBx, xBGR, BGRx, RGB, BGR, Y42B, NV12, " + "NV21, YUY2, UYVY, YVYU, I420, YV12, IYUV, Y41B }")) ); static void gst_gamma_set_property (GObject * object, guint prop_id, @@ -235,21 +209,18 @@ gst_gamma_calculate_tables (GstGamma * gamma) } static void -gst_gamma_planar_yuv_ip (GstGamma * gamma, guint8 * data) +gst_gamma_planar_yuv_ip (GstGamma * gamma, GstVideoFrame * frame) { gint i, j, height; - gint width, row_stride, row_wrap; + gint width, stride, row_wrap; const guint8 *table = gamma->gamma_table; + guint8 *data; - data = - data + gst_video_format_get_component_offset (gamma->format, 0, - gamma->width, gamma->height); - - width = gst_video_format_get_component_width (gamma->format, 0, gamma->width); - height = gst_video_format_get_component_height (gamma->format, 0, - gamma->height); - row_stride = gst_video_format_get_row_stride (gamma->format, 0, gamma->width); - row_wrap = row_stride - width; + data = GST_VIDEO_FRAME_COMP_DATA (frame, 0); + stride = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0); + width = GST_VIDEO_FRAME_COMP_WIDTH (frame, 0); + height = GST_VIDEO_FRAME_COMP_HEIGHT (frame, 0); + row_wrap = stride - width; for (i = 0; i < height; i++) { for (j = 0; j < width; j++) { @@ -261,22 +232,20 @@ gst_gamma_planar_yuv_ip (GstGamma * gamma, guint8 * data) } static void -gst_gamma_packed_yuv_ip (GstGamma * gamma, guint8 * data) +gst_gamma_packed_yuv_ip (GstGamma * gamma, GstVideoFrame * frame) { gint i, j, height; - gint width, row_stride, row_wrap; + gint width, stride, row_wrap; gint pixel_stride; const guint8 *table = gamma->gamma_table; + guint8 *data; - data = data + gst_video_format_get_component_offset (gamma->format, 0, - gamma->width, gamma->height); - - width = gst_video_format_get_component_width (gamma->format, 0, gamma->width); - height = gst_video_format_get_component_height (gamma->format, 0, - gamma->height); - row_stride = gst_video_format_get_row_stride (gamma->format, 0, gamma->width); - pixel_stride = gst_video_format_get_pixel_stride (gamma->format, 0); - row_wrap = row_stride - pixel_stride * width; + data = GST_VIDEO_FRAME_COMP_DATA (frame, 0); + stride = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0); + width = GST_VIDEO_FRAME_COMP_WIDTH (frame, 0); + height = GST_VIDEO_FRAME_COMP_HEIGHT (frame, 0); + pixel_stride = GST_VIDEO_FRAME_COMP_PSTRIDE (frame, 0); + row_wrap = stride - pixel_stride * width; for (i = 0; i < height; i++) { for (j = 0; j < width; j++) { @@ -302,29 +271,28 @@ static const gint cog_rgb_to_ycbcr_matrix_8bit_sdtv[] = { #define APPLY_MATRIX(m,o,v1,v2,v3) ((m[o*4] * v1 + m[o*4+1] * v2 + m[o*4+2] * v3 + m[o*4+3]) >> 8) static void -gst_gamma_packed_rgb_ip (GstGamma * gamma, guint8 * data) +gst_gamma_packed_rgb_ip (GstGamma * gamma, GstVideoFrame * frame) { gint i, j, height; - gint width, row_stride, row_wrap; + gint width, stride, row_wrap; gint pixel_stride; const guint8 *table = gamma->gamma_table; gint offsets[3]; gint r, g, b; gint y, u, v; + guint8 *data; - offsets[0] = gst_video_format_get_component_offset (gamma->format, 0, - gamma->width, gamma->height); - offsets[1] = gst_video_format_get_component_offset (gamma->format, 1, - gamma->width, gamma->height); - offsets[2] = gst_video_format_get_component_offset (gamma->format, 2, - gamma->width, gamma->height); + data = GST_VIDEO_FRAME_PLANE_DATA (frame, 0); + stride = GST_VIDEO_FRAME_PLANE_STRIDE (frame, 0); + width = GST_VIDEO_FRAME_COMP_WIDTH (frame, 0); + height = GST_VIDEO_FRAME_COMP_HEIGHT (frame, 0); - width = gst_video_format_get_component_width (gamma->format, 0, gamma->width); - height = gst_video_format_get_component_height (gamma->format, 0, - gamma->height); - row_stride = gst_video_format_get_row_stride (gamma->format, 0, gamma->width); - pixel_stride = gst_video_format_get_pixel_stride (gamma->format, 0); - row_wrap = row_stride - pixel_stride * width; + offsets[0] = GST_VIDEO_FRAME_COMP_OFFSET (frame, 0); + offsets[1] = GST_VIDEO_FRAME_COMP_OFFSET (frame, 1); + offsets[2] = GST_VIDEO_FRAME_COMP_OFFSET (frame, 2); + + pixel_stride = GST_VIDEO_FRAME_COMP_PSTRIDE (frame, 0); + row_wrap = stride - pixel_stride * width; for (i = 0; i < height; i++) { for (j = 0; j < width; j++) { @@ -355,19 +323,18 @@ gst_gamma_set_caps (GstBaseTransform * base, GstCaps * incaps, GstCaps * outcaps) { GstGamma *gamma = GST_GAMMA (base); + GstVideoInfo info; GST_DEBUG_OBJECT (gamma, "setting caps: in %" GST_PTR_FORMAT " out %" GST_PTR_FORMAT, incaps, outcaps); - if (!gst_video_format_parse_caps (incaps, &gamma->format, &gamma->width, - &gamma->height)) + if (!gst_video_info_from_caps (&info, incaps)) goto invalid_caps; - gamma->size = - gst_video_format_get_size (gamma->format, gamma->width, gamma->height); + gamma->info = info; - switch (gamma->format) { + switch (GST_VIDEO_INFO_FORMAT (&info)) { case GST_VIDEO_FORMAT_I420: case GST_VIDEO_FORMAT_YV12: case GST_VIDEO_FORMAT_Y41B: @@ -403,8 +370,10 @@ gst_gamma_set_caps (GstBaseTransform * base, GstCaps * incaps, return TRUE; invalid_caps: - GST_ERROR_OBJECT (gamma, "Invalid caps: %" GST_PTR_FORMAT, incaps); - return FALSE; + { + GST_ERROR_OBJECT (gamma, "Invalid caps: %" GST_PTR_FORMAT, incaps); + return FALSE; + } } static void @@ -428,8 +397,7 @@ static GstFlowReturn gst_gamma_transform_ip (GstBaseTransform * base, GstBuffer * outbuf) { GstGamma *gamma = GST_GAMMA (base); - guint8 *data; - gsize size; + GstVideoFrame frame; if (!gamma->process) goto not_negotiated; @@ -437,26 +405,23 @@ gst_gamma_transform_ip (GstBaseTransform * base, GstBuffer * outbuf) if (base->passthrough) goto done; - data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READWRITE); - - if (size != gamma->size) - goto wrong_size; + if (!gst_video_frame_map (&frame, &gamma->info, outbuf, GST_MAP_READWRITE)) + goto wrong_buffer; GST_OBJECT_LOCK (gamma); - gamma->process (gamma, data); + gamma->process (gamma, &frame); GST_OBJECT_UNLOCK (gamma); - gst_buffer_unmap (outbuf, data, size); + gst_video_frame_unmap (&frame); done: return GST_FLOW_OK; /* ERRORS */ -wrong_size: +wrong_buffer: { GST_ELEMENT_ERROR (gamma, STREAM, FORMAT, - (NULL), ("Invalid buffer size %d, expected %d", size, gamma->size)); - gst_buffer_unmap (outbuf, data, size); + (NULL), ("Invalid buffer received")); return GST_FLOW_ERROR; } not_negotiated: diff --git a/gst/videofilter/gstgamma.h b/gst/videofilter/gstgamma.h index 85d2e27..b76dd97 100644 --- a/gst/videofilter/gstgamma.h +++ b/gst/videofilter/gstgamma.h @@ -56,10 +56,7 @@ struct _GstGamma /* < private > */ /* format */ - GstVideoFormat format; - gint width; - gint height; - gint size; + GstVideoInfo info; /* properties */ gdouble gamma; @@ -67,7 +64,7 @@ struct _GstGamma /* tables */ guint8 gamma_table[256]; - void (*process) (GstGamma *gamma, guint8 *data); + void (*process) (GstGamma *gamma, GstVideoFrame *frame); }; struct _GstGammaClass diff --git a/gst/videofilter/gstvideobalance.c b/gst/videofilter/gstvideobalance.c index b59a97b..0c3eeb6 100644 --- a/gst/videofilter/gstvideobalance.c +++ b/gst/videofilter/gstvideobalance.c @@ -71,50 +71,26 @@ enum }; static GstStaticPadTemplate gst_video_balance_src_template = - GST_STATIC_PAD_TEMPLATE ("src", +GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV") ";" - GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";" - GST_VIDEO_CAPS_ABGR ";" GST_VIDEO_CAPS_RGBA ";" - GST_VIDEO_CAPS_YUV ("Y444") ";" - GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_RGBx ";" - GST_VIDEO_CAPS_xBGR ";" GST_VIDEO_CAPS_BGRx ";" - GST_VIDEO_CAPS_RGB ";" GST_VIDEO_CAPS_BGR ";" - GST_VIDEO_CAPS_YUV ("Y42B") ";" - GST_VIDEO_CAPS_YUV ("YUY2") ";" - GST_VIDEO_CAPS_YUV ("UYVY") ";" - GST_VIDEO_CAPS_YUV ("YVYU") ";" - GST_VIDEO_CAPS_YUV ("I420") ";" - GST_VIDEO_CAPS_YUV ("YV12") ";" - GST_VIDEO_CAPS_YUV ("IYUV") ";" GST_VIDEO_CAPS_YUV ("Y41B") - ) + GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ AYUV, " + "ARGB, BGRA, ABGR, RGBA, Y444, xRGB, RGBx, " + "xBGR, BGRx, RGB, BGR, Y42B, YUY2, UYVY, YVYU, " + "I420, YV12, IYUV, Y41B }")) ); static GstStaticPadTemplate gst_video_balance_sink_template = - GST_STATIC_PAD_TEMPLATE ("sink", +GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV") ";" - GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";" - GST_VIDEO_CAPS_ABGR ";" GST_VIDEO_CAPS_RGBA ";" - GST_VIDEO_CAPS_YUV ("Y444") ";" - GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_RGBx ";" - GST_VIDEO_CAPS_xBGR ";" GST_VIDEO_CAPS_BGRx ";" - GST_VIDEO_CAPS_RGB ";" GST_VIDEO_CAPS_BGR ";" - GST_VIDEO_CAPS_YUV ("Y42B") ";" - GST_VIDEO_CAPS_YUV ("YUY2") ";" - GST_VIDEO_CAPS_YUV ("UYVY") ";" - GST_VIDEO_CAPS_YUV ("YVYU") ";" - GST_VIDEO_CAPS_YUV ("I420") ";" - GST_VIDEO_CAPS_YUV ("YV12") ";" - GST_VIDEO_CAPS_YUV ("IYUV") ";" GST_VIDEO_CAPS_YUV ("Y41B") - ) + GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ AYUV, " + "ARGB, BGRA, ABGR, RGBA, Y444, xRGB, RGBx, " + "xBGR, BGRx, RGB, BGR, Y42B, YUY2, UYVY, YVYU, " + "I420, YV12, IYUV, Y41B }")) ); static void gst_video_balance_colorbalance_init (GstColorBalanceClass * iface); -static void gst_video_balance_interface_init (GstImplementsInterfaceClass * - klass); static void gst_video_balance_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); @@ -124,8 +100,6 @@ static void gst_video_balance_get_property (GObject * object, guint prop_id, #define gst_video_balance_parent_class parent_class G_DEFINE_TYPE_WITH_CODE (GstVideoBalance, gst_video_balance, GST_TYPE_VIDEO_FILTER, - G_IMPLEMENT_INTERFACE (GST_TYPE_IMPLEMENTS_INTERFACE, - gst_video_balance_interface_init); G_IMPLEMENT_INTERFACE (GST_TYPE_COLOR_BALANCE, gst_video_balance_colorbalance_init)); @@ -192,26 +166,24 @@ gst_video_balance_update_properties (GstVideoBalance * videobalance) } static void -gst_video_balance_planar_yuv (GstVideoBalance * videobalance, guint8 * data) +gst_video_balance_planar_yuv (GstVideoBalance * videobalance, + GstVideoFrame * frame) { gint x, y; guint8 *ydata; guint8 *udata, *vdata; gint ystride, ustride, vstride; - GstVideoFormat format; gint width, height; gint width2, height2; guint8 *tabley = videobalance->tabley; guint8 **tableu = videobalance->tableu; guint8 **tablev = videobalance->tablev; - format = videobalance->format; - width = videobalance->width; - height = videobalance->height; + width = GST_VIDEO_FRAME_WIDTH (frame); + height = GST_VIDEO_FRAME_HEIGHT (frame); - ydata = - data + gst_video_format_get_component_offset (format, 0, width, height); - ystride = gst_video_format_get_row_stride (format, 0, width); + ydata = GST_VIDEO_FRAME_PLANE_DATA (frame, 0); + ystride = GST_VIDEO_FRAME_PLANE_STRIDE (frame, 0); for (y = 0; y < height; y++) { guint8 *yptr; @@ -223,15 +195,13 @@ gst_video_balance_planar_yuv (GstVideoBalance * videobalance, guint8 * data) } } - width2 = gst_video_format_get_component_width (format, 1, width); - height2 = gst_video_format_get_component_height (format, 1, height); + width2 = GST_VIDEO_FRAME_COMP_WIDTH (frame, 1); + height2 = GST_VIDEO_FRAME_COMP_HEIGHT (frame, 1); - udata = - data + gst_video_format_get_component_offset (format, 1, width, height); - vdata = - data + gst_video_format_get_component_offset (format, 2, width, height); - ustride = gst_video_format_get_row_stride (format, 1, width); - vstride = gst_video_format_get_row_stride (format, 1, width); + udata = GST_VIDEO_FRAME_PLANE_DATA (frame, 1); + vdata = GST_VIDEO_FRAME_PLANE_DATA (frame, 2); + ustride = GST_VIDEO_FRAME_PLANE_STRIDE (frame, 1); + vstride = GST_VIDEO_FRAME_PLANE_STRIDE (frame, 2); for (y = 0; y < height2; y++) { guint8 *uptr, *vptr; @@ -251,57 +221,49 @@ gst_video_balance_planar_yuv (GstVideoBalance * videobalance, guint8 * data) } static void -gst_video_balance_packed_yuv (GstVideoBalance * videobalance, guint8 * data) +gst_video_balance_packed_yuv (GstVideoBalance * videobalance, + GstVideoFrame * frame) { - gint x, y; - guint8 *ydata; - guint8 *udata, *vdata; - gint ystride, ustride, vstride; + gint x, y, stride; + guint8 *ydata, *udata, *vdata; gint yoff, uoff, voff; - GstVideoFormat format; gint width, height; gint width2, height2; guint8 *tabley = videobalance->tabley; guint8 **tableu = videobalance->tableu; guint8 **tablev = videobalance->tablev; - format = videobalance->format; - width = videobalance->width; - height = videobalance->height; + width = GST_VIDEO_FRAME_WIDTH (frame); + height = GST_VIDEO_FRAME_HEIGHT (frame); - ydata = - data + gst_video_format_get_component_offset (format, 0, width, height); - ystride = gst_video_format_get_row_stride (format, 0, width); - yoff = gst_video_format_get_pixel_stride (format, 0); + stride = GST_VIDEO_FRAME_PLANE_STRIDE (frame, 0); + ydata = GST_VIDEO_FRAME_COMP_DATA (frame, 0); + yoff = GST_VIDEO_FRAME_COMP_PSTRIDE (frame, 0); for (y = 0; y < height; y++) { guint8 *yptr; - yptr = ydata + y * ystride; + yptr = ydata + y * stride; for (x = 0; x < width; x++) { *yptr = tabley[*yptr]; yptr += yoff; } } - width2 = gst_video_format_get_component_width (format, 1, width); - height2 = gst_video_format_get_component_height (format, 1, height); + width2 = GST_VIDEO_FRAME_COMP_WIDTH (frame, 1); + height2 = GST_VIDEO_FRAME_COMP_HEIGHT (frame, 1); - udata = - data + gst_video_format_get_component_offset (format, 1, width, height); - vdata = - data + gst_video_format_get_component_offset (format, 2, width, height); - ustride = gst_video_format_get_row_stride (format, 1, width); - vstride = gst_video_format_get_row_stride (format, 1, width); - uoff = gst_video_format_get_pixel_stride (format, 1); - voff = gst_video_format_get_pixel_stride (format, 2); + udata = GST_VIDEO_FRAME_COMP_DATA (frame, 1); + vdata = GST_VIDEO_FRAME_COMP_DATA (frame, 2); + uoff = GST_VIDEO_FRAME_COMP_PSTRIDE (frame, 1); + voff = GST_VIDEO_FRAME_COMP_PSTRIDE (frame, 2); for (y = 0; y < height2; y++) { guint8 *uptr, *vptr; guint8 u1, v1; - uptr = udata + y * ustride; - vptr = vdata + y * vstride; + uptr = udata + y * stride; + vptr = vdata + y * stride; for (x = 0; x < width2; x++) { u1 = *uptr; @@ -331,11 +293,13 @@ static const gint cog_rgb_to_ycbcr_matrix_8bit_sdtv[] = { #define APPLY_MATRIX(m,o,v1,v2,v3) ((m[o*4] * v1 + m[o*4+1] * v2 + m[o*4+2] * v3 + m[o*4+3]) >> 8) static void -gst_video_balance_packed_rgb (GstVideoBalance * videobalance, guint8 * data) +gst_video_balance_packed_rgb (GstVideoBalance * videobalance, + GstVideoFrame * frame) { gint i, j, height; - gint width, row_stride, row_wrap; + gint width, stride, row_wrap; gint pixel_stride; + guint8 *data; gint offsets[3]; gint r, g, b; gint y, u, v; @@ -344,24 +308,18 @@ gst_video_balance_packed_rgb (GstVideoBalance * videobalance, guint8 * data) guint8 **tableu = videobalance->tableu; guint8 **tablev = videobalance->tablev; - offsets[0] = gst_video_format_get_component_offset (videobalance->format, 0, - videobalance->width, videobalance->height); - offsets[1] = gst_video_format_get_component_offset (videobalance->format, 1, - videobalance->width, videobalance->height); - offsets[2] = gst_video_format_get_component_offset (videobalance->format, 2, - videobalance->width, videobalance->height); - - width = - gst_video_format_get_component_width (videobalance->format, 0, - videobalance->width); - height = - gst_video_format_get_component_height (videobalance->format, 0, - videobalance->height); - row_stride = - gst_video_format_get_row_stride (videobalance->format, 0, - videobalance->width); - pixel_stride = gst_video_format_get_pixel_stride (videobalance->format, 0); - row_wrap = row_stride - pixel_stride * width; + width = GST_VIDEO_FRAME_WIDTH (frame); + height = GST_VIDEO_FRAME_HEIGHT (frame); + + offsets[0] = GST_VIDEO_FRAME_COMP_OFFSET (frame, 0); + offsets[1] = GST_VIDEO_FRAME_COMP_OFFSET (frame, 1); + offsets[2] = GST_VIDEO_FRAME_COMP_OFFSET (frame, 2); + + data = GST_VIDEO_FRAME_PLANE_DATA (frame, 0); + stride = GST_VIDEO_FRAME_PLANE_STRIDE (frame, 0); + + pixel_stride = GST_VIDEO_FRAME_COMP_PSTRIDE (frame, 0); + row_wrap = stride - pixel_stride * width; for (i = 0; i < height; i++) { for (j = 0; j < width; j++) { @@ -400,21 +358,17 @@ gst_video_balance_set_caps (GstBaseTransform * base, GstCaps * incaps, GstCaps * outcaps) { GstVideoBalance *videobalance = GST_VIDEO_BALANCE (base); + GstVideoInfo info; GST_DEBUG_OBJECT (videobalance, "in %" GST_PTR_FORMAT " out %" GST_PTR_FORMAT, incaps, outcaps); videobalance->process = NULL; - if (!gst_video_format_parse_caps (incaps, &videobalance->format, - &videobalance->width, &videobalance->height)) + if (!gst_video_info_from_caps (&info, incaps)) goto invalid_caps; - videobalance->size = - gst_video_format_get_size (videobalance->format, videobalance->width, - videobalance->height); - - switch (videobalance->format) { + switch (GST_VIDEO_INFO_FORMAT (&info)) { case GST_VIDEO_FORMAT_I420: case GST_VIDEO_FORMAT_YV12: case GST_VIDEO_FORMAT_Y41B: @@ -441,14 +395,24 @@ gst_video_balance_set_caps (GstBaseTransform * base, GstCaps * incaps, videobalance->process = gst_video_balance_packed_rgb; break; default: + goto unknown_format; break; } - return videobalance->process != NULL; + videobalance->info = info; + + return TRUE; invalid_caps: - GST_ERROR_OBJECT (videobalance, "Invalid caps: %" GST_PTR_FORMAT, incaps); - return FALSE; + { + GST_ERROR_OBJECT (videobalance, "Invalid caps: %" GST_PTR_FORMAT, incaps); + return FALSE; + } +unknown_format: + { + GST_ERROR_OBJECT (videobalance, "unknown format %" GST_PTR_FORMAT, incaps); + return FALSE; + } } static void @@ -472,8 +436,7 @@ static GstFlowReturn gst_video_balance_transform_ip (GstBaseTransform * base, GstBuffer * outbuf) { GstVideoBalance *videobalance = GST_VIDEO_BALANCE (base); - guint8 *data; - gsize size; + GstVideoFrame frame; if (!videobalance->process) goto not_negotiated; @@ -482,32 +445,31 @@ gst_video_balance_transform_ip (GstBaseTransform * base, GstBuffer * outbuf) if (base->passthrough) goto done; - data = gst_buffer_map (outbuf, &size, NULL, GST_MAP_READWRITE); - - if (size != videobalance->size) - goto wrong_size; + if (!gst_video_frame_map (&frame, &videobalance->info, outbuf, + GST_MAP_READWRITE)) + goto wrong_frame; GST_OBJECT_LOCK (videobalance); - videobalance->process (videobalance, data); + videobalance->process (videobalance, &frame); GST_OBJECT_UNLOCK (videobalance); - gst_buffer_unmap (outbuf, data, size); + gst_video_frame_unmap (&frame); done: return GST_FLOW_OK; /* ERRORS */ -wrong_size: +wrong_frame: { GST_ELEMENT_ERROR (videobalance, STREAM, FORMAT, - (NULL), ("Invalid buffer size %d, expected %d", size, - videobalance->size)); - gst_buffer_unmap (outbuf, data, size); + (NULL), ("Invalid buffer received")); return GST_FLOW_ERROR; } not_negotiated: - GST_ERROR_OBJECT (videobalance, "Not negotiated yet"); - return GST_FLOW_NOT_NEGOTIATED; + { + GST_ERROR_OBJECT (videobalance, "Not negotiated yet"); + return GST_FLOW_NOT_NEGOTIATED; + } } static void @@ -618,20 +580,6 @@ gst_video_balance_init (GstVideoBalance * videobalance) } } -static gboolean -gst_video_balance_interface_supported (GstImplementsInterface * iface, - GType type) -{ - g_assert (type == GST_TYPE_COLOR_BALANCE); - return TRUE; -} - -static void -gst_video_balance_interface_init (GstImplementsInterfaceClass * klass) -{ - klass->supported = gst_video_balance_interface_supported; -} - static const GList * gst_video_balance_colorbalance_list_channels (GstColorBalance * balance) { diff --git a/gst/videofilter/gstvideobalance.h b/gst/videofilter/gstvideobalance.h index c9484e3..1d3375a 100644 --- a/gst/videofilter/gstvideobalance.h +++ b/gst/videofilter/gstvideobalance.h @@ -61,17 +61,14 @@ struct _GstVideoBalance { gdouble saturation; /* format */ - GstVideoFormat format; - gint width; - gint height; - gint size; + GstVideoInfo info; /* tables */ guint8 tabley[256]; guint8 *tableu[256]; guint8 *tablev[256]; - void (*process) (GstVideoBalance *balance, guint8 *data); + void (*process) (GstVideoBalance *balance, GstVideoFrame *frame); }; struct _GstVideoBalanceClass { diff --git a/gst/videofilter/gstvideoflip.c b/gst/videofilter/gstvideoflip.c index 8e249ae..c08f107 100644 --- a/gst/videofilter/gstvideoflip.c +++ b/gst/videofilter/gstvideoflip.c @@ -65,40 +65,21 @@ GST_DEBUG_CATEGORY_STATIC (video_flip_debug); #define GST_CAT_DEFAULT video_flip_debug static GstStaticPadTemplate gst_video_flip_src_template = - GST_STATIC_PAD_TEMPLATE ("src", +GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV") ";" - GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";" - GST_VIDEO_CAPS_ABGR ";" GST_VIDEO_CAPS_RGBA ";" - GST_VIDEO_CAPS_YUV ("Y444") ";" - GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_RGBx ";" - GST_VIDEO_CAPS_xBGR ";" GST_VIDEO_CAPS_BGRx ";" - GST_VIDEO_CAPS_RGB ";" GST_VIDEO_CAPS_BGR ";" - GST_VIDEO_CAPS_YUV ("I420") ";" - GST_VIDEO_CAPS_YUV ("YV12") ";" GST_VIDEO_CAPS_YUV ("IYUV") ";" - GST_VIDEO_CAPS_YUV ("YUY2") ";" GST_VIDEO_CAPS_YUV ("UYVY") ";" - GST_VIDEO_CAPS_YUV ("YVYU") - - ) + GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ AYUV, " + "ARGB, BGRA, ABGR, RGBA, Y444, xRGB, RGBx,xBGR, BGRx, " + "RGB, BGR, I420, YV12, IYUV YUY2, UYVY, YVYU }")) ); static GstStaticPadTemplate gst_video_flip_sink_template = - GST_STATIC_PAD_TEMPLATE ("sink", +GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV") ";" - GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";" - GST_VIDEO_CAPS_ABGR ";" GST_VIDEO_CAPS_RGBA ";" - GST_VIDEO_CAPS_YUV ("Y444") ";" - GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_RGBx ";" - GST_VIDEO_CAPS_xBGR ";" GST_VIDEO_CAPS_BGRx ";" - GST_VIDEO_CAPS_RGB ";" GST_VIDEO_CAPS_BGR ";" - GST_VIDEO_CAPS_YUV ("I420") ";" - GST_VIDEO_CAPS_YUV ("YV12") ";" GST_VIDEO_CAPS_YUV ("IYUV") ";" - GST_VIDEO_CAPS_YUV ("YUY2") ";" GST_VIDEO_CAPS_YUV ("UYVY") ";" - GST_VIDEO_CAPS_YUV ("YVYU") - ) + GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ AYUV, " + "ARGB, BGRA, ABGR, RGBA, Y444, xRGB, RGBx,xBGR, BGRx, " + "RGB, BGR, I420, YV12, IYUV YUY2, UYVY, YVYU }")) ); #define GST_TYPE_VIDEO_FLIP_METHOD (gst_video_flip_method_get_type()) @@ -204,78 +185,62 @@ static gboolean gst_video_flip_get_unit_size (GstBaseTransform * btrans, GstCaps * caps, gsize * size) { - GstVideoFormat format; - gint width, height; + GstVideoInfo info; - if (!gst_video_format_parse_caps (caps, &format, &width, &height)) + if (!gst_video_info_from_caps (&info, caps)) return FALSE; - *size = gst_video_format_get_size (format, width, height); + *size = info.size; GST_DEBUG_OBJECT (btrans, "our frame size is %d bytes (%dx%d)", *size, - width, height); + info.width, info.height); return TRUE; } static void -gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest, - const guint8 * src) +gst_video_flip_planar_yuv (GstVideoFlip * videoflip, GstVideoFrame * dest, + const GstVideoFrame * src) { gint x, y; guint8 const *s; guint8 *d; - GstVideoFormat format = videoflip->format; - gint sw = videoflip->from_width; - gint sh = videoflip->from_height; - gint dw = videoflip->to_width; - gint dh = videoflip->to_height; gint src_y_stride, src_u_stride, src_v_stride; - gint src_y_offset, src_u_offset, src_v_offset; gint src_y_height, src_u_height, src_v_height; gint src_y_width, src_u_width, src_v_width; gint dest_y_stride, dest_u_stride, dest_v_stride; - gint dest_y_offset, dest_u_offset, dest_v_offset; gint dest_y_height, dest_u_height, dest_v_height; gint dest_y_width, dest_u_width, dest_v_width; - src_y_stride = gst_video_format_get_row_stride (format, 0, sw); - src_u_stride = gst_video_format_get_row_stride (format, 1, sw); - src_v_stride = gst_video_format_get_row_stride (format, 2, sw); + src_y_stride = GST_VIDEO_FRAME_PLANE_STRIDE (src, 0); + src_u_stride = GST_VIDEO_FRAME_PLANE_STRIDE (src, 1); + src_v_stride = GST_VIDEO_FRAME_PLANE_STRIDE (src, 2); - dest_y_stride = gst_video_format_get_row_stride (format, 0, dw); - dest_u_stride = gst_video_format_get_row_stride (format, 1, dw); - dest_v_stride = gst_video_format_get_row_stride (format, 2, dw); + dest_y_stride = GST_VIDEO_FRAME_PLANE_STRIDE (dest, 0); + dest_u_stride = GST_VIDEO_FRAME_PLANE_STRIDE (dest, 1); + dest_v_stride = GST_VIDEO_FRAME_PLANE_STRIDE (dest, 2); - src_y_offset = gst_video_format_get_component_offset (format, 0, sw, sh); - src_u_offset = gst_video_format_get_component_offset (format, 1, sw, sh); - src_v_offset = gst_video_format_get_component_offset (format, 2, sw, sh); + src_y_width = GST_VIDEO_FRAME_COMP_WIDTH (src, 0); + src_u_width = GST_VIDEO_FRAME_COMP_WIDTH (src, 1); + src_v_width = GST_VIDEO_FRAME_COMP_WIDTH (src, 2); - dest_y_offset = gst_video_format_get_component_offset (format, 0, dw, dh); - dest_u_offset = gst_video_format_get_component_offset (format, 1, dw, dh); - dest_v_offset = gst_video_format_get_component_offset (format, 2, dw, dh); + dest_y_width = GST_VIDEO_FRAME_COMP_WIDTH (dest, 0); + dest_u_width = GST_VIDEO_FRAME_COMP_WIDTH (dest, 1); + dest_v_width = GST_VIDEO_FRAME_COMP_WIDTH (dest, 2); - src_y_width = gst_video_format_get_component_width (format, 0, sw); - src_u_width = gst_video_format_get_component_width (format, 1, sw); - src_v_width = gst_video_format_get_component_width (format, 2, sw); + src_y_height = GST_VIDEO_FRAME_COMP_HEIGHT (src, 0); + src_u_height = GST_VIDEO_FRAME_COMP_HEIGHT (src, 1); + src_v_height = GST_VIDEO_FRAME_COMP_HEIGHT (src, 2); - dest_y_width = gst_video_format_get_component_width (format, 0, dw); - dest_u_width = gst_video_format_get_component_width (format, 1, dw); - dest_v_width = gst_video_format_get_component_width (format, 2, dw); - - src_y_height = gst_video_format_get_component_height (format, 0, sh); - src_u_height = gst_video_format_get_component_height (format, 1, sh); - src_v_height = gst_video_format_get_component_height (format, 2, sh); - - dest_y_height = gst_video_format_get_component_height (format, 0, dh); - dest_u_height = gst_video_format_get_component_height (format, 1, dh); - dest_v_height = gst_video_format_get_component_height (format, 2, dh); + dest_y_height = GST_VIDEO_FRAME_COMP_HEIGHT (dest, 0); + dest_u_height = GST_VIDEO_FRAME_COMP_HEIGHT (dest, 1); + dest_v_height = GST_VIDEO_FRAME_COMP_HEIGHT (dest, 2); switch (videoflip->method) { case GST_VIDEO_FLIP_METHOD_90R: /* Flip Y */ - s = src + src_y_offset; - d = dest + dest_y_offset; + s = GST_VIDEO_FRAME_PLANE_DATA (src, 0); + d = GST_VIDEO_FRAME_PLANE_DATA (dest, 0); for (y = 0; y < dest_y_height; y++) { for (x = 0; x < dest_y_width; x++) { d[y * dest_y_stride + x] = @@ -283,8 +248,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest, } } /* Flip U */ - s = src + src_u_offset; - d = dest + dest_u_offset; + s = GST_VIDEO_FRAME_PLANE_DATA (src, 1); + d = GST_VIDEO_FRAME_PLANE_DATA (dest, 1); for (y = 0; y < dest_u_height; y++) { for (x = 0; x < dest_u_width; x++) { d[y * dest_u_stride + x] = @@ -292,8 +257,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest, } } /* Flip V */ - s = src + src_v_offset; - d = dest + dest_v_offset; + s = GST_VIDEO_FRAME_PLANE_DATA (src, 2); + d = GST_VIDEO_FRAME_PLANE_DATA (dest, 2); for (y = 0; y < dest_v_height; y++) { for (x = 0; x < dest_v_width; x++) { d[y * dest_v_stride + x] = @@ -303,8 +268,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest, break; case GST_VIDEO_FLIP_METHOD_90L: /* Flip Y */ - s = src + src_y_offset; - d = dest + dest_y_offset; + s = GST_VIDEO_FRAME_PLANE_DATA (src, 0); + d = GST_VIDEO_FRAME_PLANE_DATA (dest, 0); for (y = 0; y < dest_y_height; y++) { for (x = 0; x < dest_y_width; x++) { d[y * dest_y_stride + x] = @@ -312,8 +277,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest, } } /* Flip U */ - s = src + src_u_offset; - d = dest + dest_u_offset; + s = GST_VIDEO_FRAME_PLANE_DATA (src, 1); + d = GST_VIDEO_FRAME_PLANE_DATA (dest, 1); for (y = 0; y < dest_u_height; y++) { for (x = 0; x < dest_u_width; x++) { d[y * dest_u_stride + x] = @@ -321,8 +286,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest, } } /* Flip V */ - s = src + src_v_offset; - d = dest + dest_v_offset; + s = GST_VIDEO_FRAME_PLANE_DATA (src, 2); + d = GST_VIDEO_FRAME_PLANE_DATA (dest, 2); for (y = 0; y < dest_v_height; y++) { for (x = 0; x < dest_v_width; x++) { d[y * dest_v_stride + x] = @@ -332,8 +297,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest, break; case GST_VIDEO_FLIP_METHOD_180: /* Flip Y */ - s = src + src_y_offset; - d = dest + dest_y_offset; + s = GST_VIDEO_FRAME_PLANE_DATA (src, 0); + d = GST_VIDEO_FRAME_PLANE_DATA (dest, 0); for (y = 0; y < dest_y_height; y++) { for (x = 0; x < dest_y_width; x++) { d[y * dest_y_stride + x] = @@ -341,8 +306,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest, } } /* Flip U */ - s = src + src_u_offset; - d = dest + dest_u_offset; + s = GST_VIDEO_FRAME_PLANE_DATA (src, 1); + d = GST_VIDEO_FRAME_PLANE_DATA (dest, 1); for (y = 0; y < dest_u_height; y++) { for (x = 0; x < dest_u_width; x++) { d[y * dest_u_stride + x] = @@ -350,8 +315,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest, } } /* Flip V */ - s = src + src_v_offset; - d = dest + dest_v_offset; + s = GST_VIDEO_FRAME_PLANE_DATA (src, 2); + d = GST_VIDEO_FRAME_PLANE_DATA (dest, 2); for (y = 0; y < dest_v_height; y++) { for (x = 0; x < dest_v_width; x++) { d[y * dest_v_stride + x] = @@ -361,8 +326,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest, break; case GST_VIDEO_FLIP_METHOD_HORIZ: /* Flip Y */ - s = src + src_y_offset; - d = dest + dest_y_offset; + s = GST_VIDEO_FRAME_PLANE_DATA (src, 0); + d = GST_VIDEO_FRAME_PLANE_DATA (dest, 0); for (y = 0; y < dest_y_height; y++) { for (x = 0; x < dest_y_width; x++) { d[y * dest_y_stride + x] = @@ -370,8 +335,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest, } } /* Flip U */ - s = src + src_u_offset; - d = dest + dest_u_offset; + s = GST_VIDEO_FRAME_PLANE_DATA (src, 1); + d = GST_VIDEO_FRAME_PLANE_DATA (dest, 1); for (y = 0; y < dest_u_height; y++) { for (x = 0; x < dest_u_width; x++) { d[y * dest_u_stride + x] = @@ -379,8 +344,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest, } } /* Flip V */ - s = src + src_v_offset; - d = dest + dest_v_offset; + s = GST_VIDEO_FRAME_PLANE_DATA (src, 2); + d = GST_VIDEO_FRAME_PLANE_DATA (dest, 2); for (y = 0; y < dest_v_height; y++) { for (x = 0; x < dest_v_width; x++) { d[y * dest_v_stride + x] = @@ -390,8 +355,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest, break; case GST_VIDEO_FLIP_METHOD_VERT: /* Flip Y */ - s = src + src_y_offset; - d = dest + dest_y_offset; + s = GST_VIDEO_FRAME_PLANE_DATA (src, 0); + d = GST_VIDEO_FRAME_PLANE_DATA (dest, 0); for (y = 0; y < dest_y_height; y++) { for (x = 0; x < dest_y_width; x++) { d[y * dest_y_stride + x] = @@ -399,8 +364,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest, } } /* Flip U */ - s = src + src_u_offset; - d = dest + dest_u_offset; + s = GST_VIDEO_FRAME_PLANE_DATA (src, 1); + d = GST_VIDEO_FRAME_PLANE_DATA (dest, 1); for (y = 0; y < dest_u_height; y++) { for (x = 0; x < dest_u_width; x++) { d[y * dest_u_stride + x] = @@ -408,8 +373,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest, } } /* Flip V */ - s = src + src_v_offset; - d = dest + dest_v_offset; + s = GST_VIDEO_FRAME_PLANE_DATA (src, 2); + d = GST_VIDEO_FRAME_PLANE_DATA (dest, 2); for (y = 0; y < dest_v_height; y++) { for (x = 0; x < dest_v_width; x++) { d[y * dest_v_stride + x] = @@ -419,24 +384,24 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest, break; case GST_VIDEO_FLIP_METHOD_TRANS: /* Flip Y */ - s = src + src_y_offset; - d = dest + dest_y_offset; + s = GST_VIDEO_FRAME_PLANE_DATA (src, 0); + d = GST_VIDEO_FRAME_PLANE_DATA (dest, 0); for (y = 0; y < dest_y_height; y++) { for (x = 0; x < dest_y_width; x++) { d[y * dest_y_stride + x] = s[x * src_y_stride + y]; } } /* Flip U */ - s = src + src_u_offset; - d = dest + dest_u_offset; + s = GST_VIDEO_FRAME_PLANE_DATA (src, 1); + d = GST_VIDEO_FRAME_PLANE_DATA (dest, 1); for (y = 0; y < dest_u_height; y++) { for (x = 0; x < dest_u_width; x++) { d[y * dest_u_stride + x] = s[x * src_u_stride + y]; } } /* Flip V */ - s = src + src_v_offset; - d = dest + dest_v_offset; + s = GST_VIDEO_FRAME_PLANE_DATA (src, 2); + d = GST_VIDEO_FRAME_PLANE_DATA (dest, 2); for (y = 0; y < dest_u_height; y++) { for (x = 0; x < dest_u_width; x++) { d[y * dest_v_stride + x] = s[x * src_v_stride + y]; @@ -445,8 +410,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest, break; case GST_VIDEO_FLIP_METHOD_OTHER: /* Flip Y */ - s = src + src_y_offset; - d = dest + dest_y_offset; + s = GST_VIDEO_FRAME_PLANE_DATA (src, 0); + d = GST_VIDEO_FRAME_PLANE_DATA (dest, 0); for (y = 0; y < dest_y_height; y++) { for (x = 0; x < dest_y_width; x++) { d[y * dest_y_stride + x] = @@ -454,8 +419,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest, } } /* Flip U */ - s = src + src_u_offset; - d = dest + dest_u_offset; + s = GST_VIDEO_FRAME_PLANE_DATA (src, 1); + d = GST_VIDEO_FRAME_PLANE_DATA (dest, 1); for (y = 0; y < dest_u_height; y++) { for (x = 0; x < dest_u_width; x++) { d[y * dest_u_stride + x] = @@ -463,8 +428,8 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest, } } /* Flip V */ - s = src + src_v_offset; - d = dest + dest_v_offset; + s = GST_VIDEO_FRAME_PLANE_DATA (src, 2); + d = GST_VIDEO_FRAME_PLANE_DATA (dest, 2); for (y = 0; y < dest_v_height; y++) { for (x = 0; x < dest_v_width; x++) { d[y * dest_v_stride + x] = @@ -482,24 +447,26 @@ gst_video_flip_planar_yuv (GstVideoFlip * videoflip, guint8 * dest, } static void -gst_video_flip_packed_simple (GstVideoFlip * videoflip, guint8 * dest, - const guint8 * src) +gst_video_flip_packed_simple (GstVideoFlip * videoflip, GstVideoFrame * dest, + const GstVideoFrame * src) { gint x, y, z; - guint8 const *s = src; - guint8 *d = dest; - GstVideoFormat format = videoflip->format; - gint sw = videoflip->from_width; - gint sh = videoflip->from_height; - gint dw = videoflip->to_width; - gint dh = videoflip->to_height; + guint8 const *s; + guint8 *d; + gint sw = GST_VIDEO_FRAME_WIDTH (src); + gint sh = GST_VIDEO_FRAME_HEIGHT (src); + gint dw = GST_VIDEO_FRAME_WIDTH (dest); + gint dh = GST_VIDEO_FRAME_HEIGHT (dest); gint src_stride, dest_stride; gint bpp; - src_stride = gst_video_format_get_row_stride (format, 0, sw); - dest_stride = gst_video_format_get_row_stride (format, 0, dw); + s = GST_VIDEO_FRAME_PLANE_DATA (src, 0); + d = GST_VIDEO_FRAME_PLANE_DATA (dest, 0); + + src_stride = GST_VIDEO_FRAME_PLANE_STRIDE (src, 0); + dest_stride = GST_VIDEO_FRAME_PLANE_STRIDE (dest, 0); /* This is only true for non-subsampled formats! */ - bpp = gst_video_format_get_pixel_stride (format, 0); + bpp = GST_VIDEO_FRAME_COMP_PSTRIDE (src, 0); switch (videoflip->method) { case GST_VIDEO_FLIP_METHOD_90R: @@ -582,17 +549,16 @@ gst_video_flip_packed_simple (GstVideoFlip * videoflip, guint8 * dest, static void -gst_video_flip_y422 (GstVideoFlip * videoflip, guint8 * dest, - const guint8 * src) +gst_video_flip_y422 (GstVideoFlip * videoflip, GstVideoFrame * dest, + const GstVideoFrame * src) { gint x, y; - guint8 const *s = src; - guint8 *d = dest; - GstVideoFormat format = videoflip->format; - gint sw = videoflip->from_width; - gint sh = videoflip->from_height; - gint dw = videoflip->to_width; - gint dh = videoflip->to_height; + guint8 const *s; + guint8 *d; + gint sw = GST_VIDEO_FRAME_WIDTH (src); + gint sh = GST_VIDEO_FRAME_HEIGHT (src); + gint dw = GST_VIDEO_FRAME_WIDTH (dest); + gint dh = GST_VIDEO_FRAME_HEIGHT (dest); gint src_stride, dest_stride; gint bpp; gint y_offset; @@ -600,13 +566,16 @@ gst_video_flip_y422 (GstVideoFlip * videoflip, guint8 * dest, gint v_offset; gint y_stride; - src_stride = gst_video_format_get_row_stride (format, 0, sw); - dest_stride = gst_video_format_get_row_stride (format, 0, dw); + s = GST_VIDEO_FRAME_PLANE_DATA (src, 0); + d = GST_VIDEO_FRAME_PLANE_DATA (dest, 0); + + src_stride = GST_VIDEO_FRAME_PLANE_STRIDE (src, 0); + dest_stride = GST_VIDEO_FRAME_PLANE_STRIDE (dest, 0); - y_offset = gst_video_format_get_component_offset (format, 0, sw, sh); - u_offset = gst_video_format_get_component_offset (format, 1, sw, sh); - v_offset = gst_video_format_get_component_offset (format, 2, sw, sh); - y_stride = gst_video_format_get_pixel_stride (format, 0); + y_offset = GST_VIDEO_FRAME_COMP_OFFSET (src, 0); + u_offset = GST_VIDEO_FRAME_COMP_OFFSET (src, 1); + v_offset = GST_VIDEO_FRAME_COMP_OFFSET (src, 2); + y_stride = GST_VIDEO_FRAME_COMP_PSTRIDE (src, 0); bpp = y_stride; switch (videoflip->method) { @@ -800,20 +769,17 @@ gst_video_flip_set_caps (GstBaseTransform * btrans, GstCaps * incaps, GstCaps * outcaps) { GstVideoFlip *vf = GST_VIDEO_FLIP (btrans); - GstVideoFormat in_format, out_format; + GstVideoInfo in_info, out_info; gboolean ret = FALSE; vf->process = NULL; - if (!gst_video_format_parse_caps (incaps, &in_format, &vf->from_width, - &vf->from_height) - || !gst_video_format_parse_caps (outcaps, &out_format, &vf->to_width, - &vf->to_height)) + if (!gst_video_info_from_caps (&in_info, incaps) + || !gst_video_info_from_caps (&out_info, outcaps)) goto invalid_caps; - if (in_format != out_format) + if (GST_VIDEO_INFO_FORMAT (&in_info) != GST_VIDEO_INFO_FORMAT (&out_info)) goto invalid_caps; - vf->format = in_format; /* Check that they are correct */ switch (vf->method) { @@ -821,11 +787,11 @@ gst_video_flip_set_caps (GstBaseTransform * btrans, GstCaps * incaps, case GST_VIDEO_FLIP_METHOD_90L: case GST_VIDEO_FLIP_METHOD_TRANS: case GST_VIDEO_FLIP_METHOD_OTHER: - if ((vf->from_width != vf->to_height) || - (vf->from_height != vf->to_width)) { + if ((in_info.width != out_info.height) || + (in_info.height != out_info.width)) { GST_ERROR_OBJECT (vf, "we are inverting width and height but caps " - "are not correct : %dx%d to %dx%d", vf->from_width, - vf->from_height, vf->to_width, vf->to_height); + "are not correct : %dx%d to %dx%d", in_info.width, + in_info.height, out_info.width, out_info.height); goto beach; } break; @@ -835,11 +801,11 @@ gst_video_flip_set_caps (GstBaseTransform * btrans, GstCaps * incaps, case GST_VIDEO_FLIP_METHOD_180: case GST_VIDEO_FLIP_METHOD_HORIZ: case GST_VIDEO_FLIP_METHOD_VERT: - if ((vf->from_width != vf->to_width) || - (vf->from_height != vf->to_height)) { + if ((in_info.width != out_info.width) || + (in_info.height != out_info.height)) { GST_ERROR_OBJECT (vf, "we are keeping width and height but caps " - "are not correct : %dx%d to %dx%d", vf->from_width, - vf->from_height, vf->to_width, vf->to_height); + "are not correct : %dx%d to %dx%d", in_info.width, + in_info.height, out_info.width, out_info.height); goto beach; } break; @@ -849,8 +815,10 @@ gst_video_flip_set_caps (GstBaseTransform * btrans, GstCaps * incaps, } ret = TRUE; + vf->in_info = in_info; + vf->out_info = out_info; - switch (vf->format) { + switch (GST_VIDEO_INFO_FORMAT (&in_info)) { case GST_VIDEO_FORMAT_I420: case GST_VIDEO_FORMAT_YV12: case GST_VIDEO_FORMAT_Y444: @@ -909,32 +877,48 @@ gst_video_flip_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out) { GstVideoFlip *videoflip = GST_VIDEO_FLIP (trans); - guint8 *dest; - guint8 *src; - gsize srcsize, destsize; + GstVideoFrame dest; + GstVideoFrame src; if (G_UNLIKELY (videoflip->process == NULL)) goto not_negotiated; - src = gst_buffer_map (in, &srcsize, NULL, GST_MAP_READ); - dest = gst_buffer_map (out, &destsize, NULL, GST_MAP_WRITE); + if (!gst_video_frame_map (&src, &videoflip->in_info, in, GST_MAP_READ)) + goto invalid_in; + + if (!gst_video_frame_map (&dest, &videoflip->out_info, out, GST_MAP_WRITE)) + goto invalid_out; GST_LOG_OBJECT (videoflip, "videoflip: flipping %dx%d to %dx%d (%s)", - videoflip->from_width, videoflip->from_height, videoflip->to_width, - videoflip->to_height, video_flip_methods[videoflip->method].value_nick); + videoflip->in_info.width, videoflip->in_info.height, + videoflip->out_info.width, videoflip->out_info.height, + video_flip_methods[videoflip->method].value_nick); GST_OBJECT_LOCK (videoflip); - videoflip->process (videoflip, dest, src); + videoflip->process (videoflip, &dest, &src); GST_OBJECT_UNLOCK (videoflip); - gst_buffer_unmap (in, src, srcsize); - gst_buffer_unmap (out, dest, destsize); + gst_video_frame_unmap (&src); + gst_video_frame_unmap (&dest); return GST_FLOW_OK; not_negotiated: - GST_ERROR_OBJECT (videoflip, "Not negotiated yet"); - return GST_FLOW_NOT_NEGOTIATED; + { + GST_ERROR_OBJECT (videoflip, "Not negotiated yet"); + return GST_FLOW_NOT_NEGOTIATED; + } +invalid_in: + { + GST_ERROR_OBJECT (videoflip, "invalid input frame"); + return GST_FLOW_OK; + } +invalid_out: + { + GST_ERROR_OBJECT (videoflip, "invalid output frame"); + gst_video_frame_unmap (&src); + return GST_FLOW_OK; + } } static gboolean @@ -959,31 +943,31 @@ gst_video_flip_src_event (GstBaseTransform * trans, GstEvent * event) switch (vf->method) { case GST_VIDEO_FLIP_METHOD_90R: new_x = y; - new_y = vf->to_width - x; + new_y = vf->out_info.width - x; break; case GST_VIDEO_FLIP_METHOD_90L: - new_x = vf->to_height - y; + new_x = vf->out_info.height - y; new_y = x; break; case GST_VIDEO_FLIP_METHOD_OTHER: - new_x = vf->to_height - y; - new_y = vf->to_width - x; + new_x = vf->out_info.height - y; + new_y = vf->out_info.width - x; break; case GST_VIDEO_FLIP_METHOD_TRANS: new_x = y; new_y = x; break; case GST_VIDEO_FLIP_METHOD_180: - new_x = vf->to_width - x; - new_y = vf->to_height - y; + new_x = vf->out_info.width - x; + new_y = vf->out_info.height - y; break; case GST_VIDEO_FLIP_METHOD_HORIZ: - new_x = vf->to_width - x; + new_x = vf->out_info.width - x; new_y = y; break; case GST_VIDEO_FLIP_METHOD_VERT: new_x = x; - new_y = vf->to_height - y; + new_y = vf->out_info.height - y; break; default: new_x = x; diff --git a/gst/videofilter/gstvideoflip.h b/gst/videofilter/gstvideoflip.h index a998fa7..d520b03 100644 --- a/gst/videofilter/gstvideoflip.h +++ b/gst/videofilter/gstvideoflip.h @@ -73,12 +73,11 @@ struct _GstVideoFlip { GstVideoFilter videofilter; /* < private > */ - GstVideoFormat format; - gint from_width, from_height; - gint to_width, to_height; + GstVideoInfo in_info; + GstVideoInfo out_info; GstVideoFlipMethod method; - void (*process) (GstVideoFlip *videoflip, guint8 *dest, const guint8 *src); + void (*process) (GstVideoFlip *videoflip, GstVideoFrame *dest, const GstVideoFrame *src); }; struct _GstVideoFlipClass {