static gboolean gst_gamma_set_caps (GstBaseTransform * base, GstCaps * incaps, GstCaps * outcaps) { GstGamma *this; GstStructure *structure; gboolean res; this = GST_GAMMA (base); GST_DEBUG_OBJECT (this, "set_caps: in %" GST_PTR_FORMAT " out %" GST_PTR_FORMAT, incaps, outcaps); structure = gst_caps_get_structure (incaps, 0); res = gst_structure_get_int (structure, "width", &this->width); res &= gst_structure_get_int (structure, "height", &this->height); if (!res) goto done; this->size = GST_VIDEO_I420_SIZE (this->width, this->height); done: return res; }
static gboolean gst_video_flip_get_unit_size (GstBaseTransform * btrans, GstCaps * caps, guint * size) { GstVideoFlip *videoflip; GstStructure *structure; gboolean ret = FALSE; gint width, height; videoflip = GST_VIDEO_FLIP (btrans); structure = gst_caps_get_structure (caps, 0); if (gst_structure_get_int (structure, "width", &width) && gst_structure_get_int (structure, "height", &height)) { *size = GST_VIDEO_I420_SIZE (width, height); ret = TRUE; GST_DEBUG_OBJECT (videoflip, "our frame size is %d bytes (%dx%d)", *size, width, height); } return ret; }
static gboolean gst_cairo_time_overlay_get_unit_size (GstBaseTransform * btrans, GstCaps * caps, guint * size) { GstCairoTimeOverlay *filter; GstStructure *structure; gboolean ret = FALSE; gint width, height; filter = GST_CAIRO_TIME_OVERLAY (btrans); structure = gst_caps_get_structure (caps, 0); if (gst_structure_get_int (structure, "width", &width) && gst_structure_get_int (structure, "height", &height)) { *size = GST_VIDEO_I420_SIZE (width, height); ret = TRUE; GST_DEBUG_OBJECT (filter, "our frame size is %d bytes (%dx%d)", *size, width, height); } return ret; }
static GstFlowReturn gst_video_flip_flip (GstVideoFlip * videoflip, guint8 * dest, guint8 * src, int sw, int sh, int dw, int dh) { GstFlowReturn ret = GST_FLOW_OK; int x, y; guint8 *s = src, *d = dest; switch (videoflip->method) { case GST_VIDEO_FLIP_METHOD_90R: /* Flip Y */ for (y = 0; y < dh; y++) { for (x = 0; x < dw; x++) { d[y * GST_VIDEO_I420_Y_ROWSTRIDE (dw) + x] = s[(sh - 1 - x) * GST_VIDEO_I420_Y_ROWSTRIDE (sw) + y]; } } /* Flip U */ s = src + GST_VIDEO_I420_U_OFFSET (sw, sh); d = dest + GST_VIDEO_I420_U_OFFSET (dw, dh); for (y = 0; y < dh / 2; y++) { for (x = 0; x < dw / 2; x++) { d[y * GST_VIDEO_I420_U_ROWSTRIDE (dw) + x] = s[(sh / 2 - 1 - x) * GST_VIDEO_I420_U_ROWSTRIDE (sw) + y]; } } /* Flip V */ s = src + GST_VIDEO_I420_V_OFFSET (sw, sh); d = dest + GST_VIDEO_I420_V_OFFSET (dw, dh); for (y = 0; y < dh / 2; y++) { for (x = 0; x < dw / 2; x++) { d[y * GST_VIDEO_I420_V_ROWSTRIDE (dw) + x] = s[(sh / 2 - 1 - x) * GST_VIDEO_I420_V_ROWSTRIDE (sw) + y]; } } break; case GST_VIDEO_FLIP_METHOD_90L: /* Flip Y */ for (y = 0; y < dh; y++) { for (x = 0; x < dw; x++) { d[y * GST_VIDEO_I420_Y_ROWSTRIDE (dw) + x] = s[x * GST_VIDEO_I420_Y_ROWSTRIDE (sw) + (sw - 1 - y)]; } } /* Flip U */ s = src + GST_VIDEO_I420_U_OFFSET (sw, sh); d = dest + GST_VIDEO_I420_U_OFFSET (dw, dh); for (y = 0; y < dh / 2; y++) { for (x = 0; x < dw / 2; x++) { d[y * GST_VIDEO_I420_U_ROWSTRIDE (dw) + x] = s[x * GST_VIDEO_I420_U_ROWSTRIDE (sw) + (sw / 2 - 1 - y)]; } } /* Flip V */ s = src + GST_VIDEO_I420_V_OFFSET (sw, sh); d = dest + GST_VIDEO_I420_V_OFFSET (dw, dh); for (y = 0; y < dh / 2; y++) { for (x = 0; x < dw / 2; x++) { d[y * GST_VIDEO_I420_V_ROWSTRIDE (dw) + x] = s[x * GST_VIDEO_I420_V_ROWSTRIDE (sw) + (sw / 2 - 1 - y)]; } } break; case GST_VIDEO_FLIP_METHOD_180: /* Flip Y */ for (y = 0; y < dh; y++) { for (x = 0; x < dw; x++) { d[y * GST_VIDEO_I420_Y_ROWSTRIDE (dw) + x] = s[(sh - 1 - y) * GST_VIDEO_I420_Y_ROWSTRIDE (sw) + (sw - 1 - x)]; } } /* Flip U */ s = src + GST_VIDEO_I420_U_OFFSET (sw, sh); d = dest + GST_VIDEO_I420_U_OFFSET (dw, dh); for (y = 0; y < dh / 2; y++) { for (x = 0; x < dw / 2; x++) { d[y * GST_VIDEO_I420_U_ROWSTRIDE (dw) + x] = s[(sh / 2 - 1 - y) * GST_VIDEO_I420_U_ROWSTRIDE (sw) + (sw / 2 - 1 - x)]; } } /* Flip V */ s = src + GST_VIDEO_I420_V_OFFSET (sw, sh); d = dest + GST_VIDEO_I420_V_OFFSET (dw, dh); for (y = 0; y < dh / 2; y++) { for (x = 0; x < dw / 2; x++) { d[y * GST_VIDEO_I420_V_ROWSTRIDE (dw) + x] = s[(sh / 2 - 1 - y) * GST_VIDEO_I420_V_ROWSTRIDE (sw) + (sw / 2 - 1 - x)]; } } break; case GST_VIDEO_FLIP_METHOD_HORIZ: /* Flip Y */ for (y = 0; y < dh; y++) { for (x = 0; x < dw; x++) { d[y * GST_VIDEO_I420_Y_ROWSTRIDE (dw) + x] = s[y * GST_VIDEO_I420_Y_ROWSTRIDE (sw) + (sw - 1 - x)]; } } /* Flip U */ s = src + GST_VIDEO_I420_U_OFFSET (sw, sh); d = dest + GST_VIDEO_I420_U_OFFSET (dw, dh); for (y = 0; y < dh / 2; y++) { for (x = 0; x < dw / 2; x++) { d[y * GST_VIDEO_I420_U_ROWSTRIDE (dw) + x] = s[y * GST_VIDEO_I420_U_ROWSTRIDE (sw) + (sw / 2 - 1 - x)]; } } /* Flip V */ s = src + GST_VIDEO_I420_V_OFFSET (sw, sh); d = dest + GST_VIDEO_I420_V_OFFSET (dw, dh); for (y = 0; y < dh / 2; y++) { for (x = 0; x < dw / 2; x++) { d[y * GST_VIDEO_I420_V_ROWSTRIDE (dw) + x] = s[y * GST_VIDEO_I420_V_ROWSTRIDE (sw) + (sw / 2 - 1 - x)]; } } break; case GST_VIDEO_FLIP_METHOD_VERT: /* Flip Y */ for (y = 0; y < dh; y++) { for (x = 0; x < dw; x++) { d[y * GST_VIDEO_I420_Y_ROWSTRIDE (dw) + x] = s[(sh - 1 - y) * GST_VIDEO_I420_Y_ROWSTRIDE (sw) + x]; } } /* Flip U */ s = src + GST_VIDEO_I420_U_OFFSET (sw, sh); d = dest + GST_VIDEO_I420_U_OFFSET (dw, dh); for (y = 0; y < dh / 2; y++) { for (x = 0; x < dw / 2; x++) { d[y * GST_VIDEO_I420_U_ROWSTRIDE (dw) + x] = s[(sh / 2 - 1 - y) * GST_VIDEO_I420_U_ROWSTRIDE (sw) + x]; } } /* Flip V */ s = src + GST_VIDEO_I420_V_OFFSET (sw, sh); d = dest + GST_VIDEO_I420_V_OFFSET (dw, dh); for (y = 0; y < dh / 2; y++) { for (x = 0; x < dw / 2; x++) { d[y * GST_VIDEO_I420_V_ROWSTRIDE (dw) + x] = s[(sh / 2 - 1 - y) * GST_VIDEO_I420_V_ROWSTRIDE (sw) + x]; } } break; case GST_VIDEO_FLIP_METHOD_TRANS: /* Flip Y */ for (y = 0; y < dh; y++) { for (x = 0; x < dw; x++) { d[y * GST_VIDEO_I420_Y_ROWSTRIDE (dw) + x] = s[x * GST_VIDEO_I420_Y_ROWSTRIDE (sw) + y]; } } /* Flip U */ s = src + GST_VIDEO_I420_U_OFFSET (sw, sh); d = dest + GST_VIDEO_I420_U_OFFSET (dw, dh); for (y = 0; y < dh / 2; y++) { for (x = 0; x < dw / 2; x++) { d[y * GST_VIDEO_I420_U_ROWSTRIDE (dw) + x] = s[x * GST_VIDEO_I420_U_ROWSTRIDE (sw) + y]; } } /* Flip V */ s = src + GST_VIDEO_I420_V_OFFSET (sw, sh); d = dest + GST_VIDEO_I420_V_OFFSET (dw, dh); for (y = 0; y < dh / 2; y++) { for (x = 0; x < dw / 2; x++) { d[y * GST_VIDEO_I420_V_ROWSTRIDE (dw) + x] = s[x * GST_VIDEO_I420_V_ROWSTRIDE (sw) + y]; } } break; case GST_VIDEO_FLIP_METHOD_OTHER: /* Flip Y */ for (y = 0; y < dh; y++) { for (x = 0; x < dw; x++) { d[y * GST_VIDEO_I420_Y_ROWSTRIDE (dw) + x] = s[(sh - 1 - x) * GST_VIDEO_I420_Y_ROWSTRIDE (sw) + (sw - 1 - y)]; } } /* Flip U */ s = src + GST_VIDEO_I420_U_OFFSET (sw, sh); d = dest + GST_VIDEO_I420_U_OFFSET (dw, dh); for (y = 0; y < dh / 2; y++) { for (x = 0; x < dw / 2; x++) { d[y * GST_VIDEO_I420_U_ROWSTRIDE (dw) + x] = s[(sh / 2 - 1 - x) * GST_VIDEO_I420_U_ROWSTRIDE (sw) + (sw / 2 - 1 - y)]; } } /* Flip V */ s = src + GST_VIDEO_I420_V_OFFSET (sw, sh); d = dest + GST_VIDEO_I420_V_OFFSET (dw, dh); for (y = 0; y < dh / 2; y++) { for (x = 0; x < dw / 2; x++) { d[y * GST_VIDEO_I420_V_ROWSTRIDE (dw) + x] = s[(sh / 2 - 1 - x) * GST_VIDEO_I420_V_ROWSTRIDE (sw) + (sw / 2 - 1 - y)]; } } break; case GST_VIDEO_FLIP_METHOD_IDENTITY: memcpy (d, s, GST_VIDEO_I420_SIZE (dw, dh)); break; default: ret = GST_FLOW_ERROR; break; } return ret; }