From: Wim Taymans Date: Wed, 30 May 2012 07:25:12 +0000 (+0200) Subject: video-blend: prepare for 0.11 porting X-Git-Tag: 1.19.3~511^2~6414 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cdf55c7c7ac7bc1480a8dc92448ddc7a6ea17bfb;p=platform%2Fupstream%2Fgstreamer.git video-blend: prepare for 0.11 porting Remove obsolete code. Remove the BlendInfo structure, we can do this better with GstVideoFrame Use GstVideoFrame in the API Prefix functions with gst_ --- diff --git a/gst-libs/gst/video/video-blend.c b/gst-libs/gst/video/video-blend.c index 90d9f44..fed516b 100644 --- a/gst-libs/gst/video/video-blend.c +++ b/gst-libs/gst/video/video-blend.c @@ -59,1085 +59,6 @@ ensure_debug_category (void) #endif /* GST_DISABLE_GST_DEBUG */ -/* Copy/pasted from 0.11 video.c */ -static int -fill_planes (GstBlendVideoFormatInfo * info) -{ - gint width, height; - - width = info->width; - height = info->height; - - switch (info->fmt) { - case GST_VIDEO_FORMAT_YUY2: - case GST_VIDEO_FORMAT_YVYU: - case GST_VIDEO_FORMAT_UYVY: - info->stride[0] = GST_ROUND_UP_4 (width * 2); - info->offset[0] = 0; - break; - case GST_VIDEO_FORMAT_AYUV: - case GST_VIDEO_FORMAT_RGBx: - case GST_VIDEO_FORMAT_RGBA: - case GST_VIDEO_FORMAT_BGRx: - case GST_VIDEO_FORMAT_BGRA: - case GST_VIDEO_FORMAT_xRGB: - case GST_VIDEO_FORMAT_ARGB: - case GST_VIDEO_FORMAT_xBGR: - case GST_VIDEO_FORMAT_ABGR: - case GST_VIDEO_FORMAT_r210: - info->stride[0] = width * 4; - info->offset[0] = 0; - break; - case GST_VIDEO_FORMAT_RGB16: - case GST_VIDEO_FORMAT_BGR16: - case GST_VIDEO_FORMAT_RGB15: - case GST_VIDEO_FORMAT_BGR15: - info->stride[0] = GST_ROUND_UP_4 (width * 2); - info->offset[0] = 0; - break; - case GST_VIDEO_FORMAT_RGB: - case GST_VIDEO_FORMAT_BGR: - case GST_VIDEO_FORMAT_v308: - info->stride[0] = GST_ROUND_UP_4 (width * 3); - info->offset[0] = 0; - break; - case GST_VIDEO_FORMAT_v210: - info->stride[0] = ((width + 47) / 48) * 128; - info->offset[0] = 0; - break; - case GST_VIDEO_FORMAT_v216: - info->stride[0] = GST_ROUND_UP_8 (width * 4); - info->offset[0] = 0; - break; - case GST_VIDEO_FORMAT_GRAY8: - case GST_VIDEO_FORMAT_Y800: - info->stride[0] = GST_ROUND_UP_4 (width); - info->offset[0] = 0; - break; - case GST_VIDEO_FORMAT_GRAY16_BE: - case GST_VIDEO_FORMAT_GRAY16_LE: - case GST_VIDEO_FORMAT_Y16: - info->stride[0] = GST_ROUND_UP_4 (width * 2); - info->offset[0] = 0; - break; - case GST_VIDEO_FORMAT_UYVP: - info->stride[0] = GST_ROUND_UP_4 ((width * 2 * 5 + 3) / 4); - info->offset[0] = 0; - break; - case GST_VIDEO_FORMAT_RGB8_PALETTED: - info->stride[0] = GST_ROUND_UP_4 (width); - info->offset[0] = 0; - break; - case GST_VIDEO_FORMAT_IYU1: - info->stride[0] = GST_ROUND_UP_4 (GST_ROUND_UP_4 (width) + - GST_ROUND_UP_4 (width) / 2); - info->offset[0] = 0; - break; - case GST_VIDEO_FORMAT_ARGB64: - case GST_VIDEO_FORMAT_AYUV64: - info->stride[0] = width * 8; - info->offset[0] = 0; - break; - case GST_VIDEO_FORMAT_I420: - 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]; - 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); - break; - case GST_VIDEO_FORMAT_YV12: /* same as I420, but plane 1+2 swapped */ - 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]; - info->offset[0] = 0; - info->offset[2] = info->stride[0] * GST_ROUND_UP_2 (height); - info->offset[1] = info->offset[2] + - info->stride[1] * (GST_ROUND_UP_2 (height) / 2); - break; - case GST_VIDEO_FORMAT_Y41B: - info->stride[0] = GST_ROUND_UP_4 (width); - info->stride[1] = GST_ROUND_UP_16 (width) / 4; - info->stride[2] = info->stride[1]; - info->offset[0] = 0; - info->offset[1] = info->stride[0] * height; - info->offset[2] = info->offset[1] + info->stride[1] * height; - /* simplification of ROUNDUP4(w)*h + 2*((ROUNDUP16(w)/4)*h */ - break; - case GST_VIDEO_FORMAT_Y42B: - info->stride[0] = GST_ROUND_UP_4 (width); - info->stride[1] = GST_ROUND_UP_8 (width) / 2; - info->stride[2] = info->stride[1]; - info->offset[0] = 0; - info->offset[1] = info->stride[0] * height; - info->offset[2] = info->offset[1] + info->stride[1] * height; - /* simplification of ROUNDUP4(w)*h + 2*(ROUNDUP8(w)/2)*h */ - break; - case GST_VIDEO_FORMAT_Y444: - 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] * height; - info->offset[2] = info->offset[1] * 2; - break; - case GST_VIDEO_FORMAT_NV12: - 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); - break; - case GST_VIDEO_FORMAT_A420: - 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]; - info->stride[3] = 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->offset[3] = info->offset[2] + - info->stride[2] * (GST_ROUND_UP_2 (height) / 2); - break; - case GST_VIDEO_FORMAT_YUV9: - info->stride[0] = GST_ROUND_UP_4 (width); - info->stride[1] = GST_ROUND_UP_4 (GST_ROUND_UP_4 (width) / 4); - info->stride[2] = info->stride[1]; - info->offset[0] = 0; - info->offset[1] = info->stride[0] * height; - info->offset[2] = info->offset[1] + - info->stride[1] * (GST_ROUND_UP_4 (height) / 4); - break; - case GST_VIDEO_FORMAT_YVU9: - info->stride[0] = GST_ROUND_UP_4 (width); - info->stride[1] = GST_ROUND_UP_4 (GST_ROUND_UP_4 (width) / 4); - info->stride[2] = info->stride[1]; - info->offset[0] = 0; - info->offset[2] = info->stride[0] * height; - info->offset[1] = info->offset[2] + - info->stride[1] * (GST_ROUND_UP_4 (height) / 4); - break; - default: - GST_ERROR ("invalid format"); - g_warning ("invalid format"); - break; - } - return 0; -} - -typedef struct -{ - GstVideoFormat format; - void (*getline) (guint8 * dest, const GstBlendVideoFormatInfo * src, - guint xoff, int j); - void (*putline) (GstBlendVideoFormatInfo * dest, - GstBlendVideoFormatInfo * srcinfo, const guint8 * line, guint xoff, - int j); - void (*matrix) (guint8 * tmpline, guint width); -} GetPutLine; - - -#define GET_LINE(info, comp, line) \ - (info)->pixels + info->offset[(comp)] + ((info)->stride[(comp)] * (line)) - -/* Line conversion to AYUV */ - -/* Supports YV12 as well */ -static void -getline_I420 (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - cogorc_getline_I420 (dest, - GET_LINE (src, 0, j) + xoff, - GET_LINE (src, 1, j >> 1) + GST_ROUND_UP_2 (xoff / 2), - GET_LINE (src, 2, j >> 1) + GST_ROUND_UP_2 (xoff / 2), src->width); -} - -/* Supports YV12 as well */ -static void -putline_I420 (GstBlendVideoFormatInfo * dest, - GstBlendVideoFormatInfo * srcinfo, const guint8 * line, guint xoff, int j) -{ - cogorc_putline_I420 (GET_LINE (dest, 0, j) + xoff, - GET_LINE (dest, 1, j >> 1) + GST_ROUND_UP_2 (xoff / 2), - GET_LINE (dest, 2, j >> 1) + GST_ROUND_UP_2 (xoff / 2), - line, srcinfo->width / 2); -} - -static void -getline_YUY2 (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - cogorc_getline_YUY2 (dest, GET_LINE (src, 0, j) + - (GST_ROUND_UP_2 (xoff * 4) / 2), src->width / 2); -} - -static void -putline_YUY2 (GstBlendVideoFormatInfo * dest, GstBlendVideoFormatInfo * srcinfo, - const guint8 * line, guint xoff, int j) -{ - cogorc_putline_YUY2 (GET_LINE (dest, 0, - j) + (GST_ROUND_UP_2 (xoff * 4) / 2), line, srcinfo->width / 2); -} - - -static void -getline_AYUV (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - memcpy (dest, GET_LINE (src, 0, j) + (xoff * 4), (src->width - xoff) * 4); -} - -static void -putline_AYUV (GstBlendVideoFormatInfo * dest, GstBlendVideoFormatInfo * srcinfo, - const guint8 * line, guint xoff, int j) -{ - memcpy (GET_LINE (dest, 0, j) + (xoff * 4), line, srcinfo->width * 4); -} - -static void -getline_UYVY (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - cogorc_getline_UYVY (dest, GET_LINE (src, 0, j) + xoff * 2, src->width / 2); -} - -static void -putline_UYVY (GstBlendVideoFormatInfo * dest, GstBlendVideoFormatInfo * srcinfo, - const guint8 * line, guint xoff, int j) -{ - cogorc_putline_UYVY (GET_LINE (dest, 0, j) + - (GST_ROUND_UP_2 (xoff * 4) / 2), line, srcinfo->width / 2); -} - -static void -getline_v308 (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - int i; - const guint8 *srcline = GET_LINE (src, 0, j) + GST_ROUND_UP_2 (xoff * 3); - - for (i = 0; i < src->width; i++) { - dest[i * 4 + 0] = 0xff; - dest[i * 4 + 1] = srcline[i * 3 + 0]; - dest[i * 4 + 2] = srcline[i * 3 + 1]; - dest[i * 4 + 3] = srcline[i * 3 + 2]; - } -} - -static void -putline_v308 (GstBlendVideoFormatInfo * dest, GstBlendVideoFormatInfo * srcinfo, - const guint8 * line, guint xoff, int j) -{ - int i; - guint8 *destline = GET_LINE (dest, 0, j) + GST_ROUND_UP_2 (xoff * 3); - - for (i = 0; i < srcinfo->width; i++) { - destline[i * 3 + 0] = line[i * 4 + 1]; - destline[i * 3 + 1] = line[i * 4 + 2]; - destline[i * 3 + 2] = line[i * 4 + 3]; - } -} - -static void -getline_v210 (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - int i; - const guint8 *srcline = GET_LINE (src, 0, j) + GST_ROUND_UP_2 (xoff * 4) / 5; - - for (i = 0; i < src->width; i += 6) { - guint32 a0, a1, a2, a3; - guint16 y0, y1, y2, y3, y4, y5; - guint16 u0, u2, u4; - guint16 v0, v2, v4; - - a0 = GST_READ_UINT32_LE (srcline + (i / 6) * 16 + 0); - a1 = GST_READ_UINT32_LE (srcline + (i / 6) * 16 + 4); - a2 = GST_READ_UINT32_LE (srcline + (i / 6) * 16 + 8); - a3 = GST_READ_UINT32_LE (srcline + (i / 6) * 16 + 12); - - u0 = ((a0 >> 0) & 0x3ff) >> 2; - y0 = ((a0 >> 10) & 0x3ff) >> 2; - v0 = ((a0 >> 20) & 0x3ff) >> 2; - y1 = ((a1 >> 0) & 0x3ff) >> 2; - - u2 = ((a1 >> 10) & 0x3ff) >> 2; - y2 = ((a1 >> 20) & 0x3ff) >> 2; - v2 = ((a2 >> 0) & 0x3ff) >> 2; - y3 = ((a2 >> 10) & 0x3ff) >> 2; - - u4 = ((a2 >> 20) & 0x3ff) >> 2; - y4 = ((a3 >> 0) & 0x3ff) >> 2; - v4 = ((a3 >> 10) & 0x3ff) >> 2; - y5 = ((a3 >> 20) & 0x3ff) >> 2; - - dest[4 * (i + 0) + 0] = 0xff; - dest[4 * (i + 0) + 1] = y0; - dest[4 * (i + 0) + 2] = u0; - dest[4 * (i + 0) + 3] = v0; - - dest[4 * (i + 1) + 0] = 0xff; - dest[4 * (i + 1) + 1] = y1; - dest[4 * (i + 1) + 2] = u0; - dest[4 * (i + 1) + 3] = v0; - - dest[4 * (i + 2) + 0] = 0xff; - dest[4 * (i + 2) + 1] = y2; - dest[4 * (i + 2) + 2] = u2; - dest[4 * (i + 2) + 3] = v2; - - dest[4 * (i + 3) + 0] = 0xff; - dest[4 * (i + 3) + 1] = y3; - dest[4 * (i + 3) + 2] = u2; - dest[4 * (i + 3) + 3] = v2; - - dest[4 * (i + 4) + 0] = 0xff; - dest[4 * (i + 4) + 1] = y4; - dest[4 * (i + 4) + 2] = u4; - dest[4 * (i + 4) + 3] = v4; - - dest[4 * (i + 5) + 0] = 0xff; - dest[4 * (i + 5) + 1] = y5; - dest[4 * (i + 5) + 2] = u4; - dest[4 * (i + 5) + 3] = v4; - - } - -} - -static void -putline_v210 (GstBlendVideoFormatInfo * dest, GstBlendVideoFormatInfo * srcinfo, - const guint8 * line, guint xoff, int j) -{ - int i; - guint8 *destline = GET_LINE (dest, 0, j) + GST_ROUND_UP_2 (xoff * 4) / 5; - - - for (i = 0; i < srcinfo->width + 5; i += 6) { - guint32 a0, a1, a2, a3; - guint16 y0, y1, y2, y3, y4, y5; - guint16 u0, u1, u2; - guint16 v0, v1, v2; - - y0 = line[4 * (i + 0) + 1] << 2; - y1 = line[4 * (i + 1) + 1] << 2; - y2 = line[4 * (i + 2) + 1] << 2; - y3 = line[4 * (i + 3) + 1] << 2; - y4 = line[4 * (i + 4) + 1] << 2; - y5 = line[4 * (i + 5) + 1] << 2; - - u0 = (line[4 * (i + 0) + 2] + line[4 * (i + 1) + 2]) << 1; - u1 = (line[4 * (i + 2) + 2] + line[4 * (i + 3) + 2]) << 1; - u2 = (line[4 * (i + 4) + 2] + line[4 * (i + 5) + 2]) << 1; - - v0 = (line[4 * (i + 0) + 3] + line[4 * (i + 1) + 3]) << 1; - v1 = (line[4 * (i + 2) + 3] + line[4 * (i + 3) + 3]) << 1; - v2 = (line[4 * (i + 4) + 3] + line[4 * (i + 5) + 3]) << 1; - - a0 = u0 | (y0 << 10) | (v0 << 20); - a1 = y1 | (u1 << 10) | (y2 << 20); - a2 = v1 | (y3 << 10) | (u2 << 20); - a3 = y4 | (v2 << 10) | (y5 << 20); - - GST_WRITE_UINT32_LE (destline + (i / 6) * 16 + 0, a0); - GST_WRITE_UINT32_LE (destline + (i / 6) * 16 + 4, a1); - GST_WRITE_UINT32_LE (destline + (i / 6) * 16 + 8, a2); - GST_WRITE_UINT32_LE (destline + (i / 6) * 16 + 12, a3); - } -} - -static void -getline_v216 (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - int i; - const guint8 *srcline = GET_LINE (src, 0, j) + GST_ROUND_UP_2 (xoff + 3); - - for (i = 0; i < src->width; i++) { - dest[i * 4 + 0] = 0xff; - dest[i * 4 + 1] = GST_READ_UINT16_LE (srcline + i * 4 + 2) >> 8; - dest[i * 4 + 2] = GST_READ_UINT16_LE (srcline + (i >> 1) * 8 + 0) >> 8; - dest[i * 4 + 3] = GST_READ_UINT16_LE (srcline + (i >> 1) * 8 + 4) >> 8; - } -} - -static void -putline_v216 (GstBlendVideoFormatInfo * dest, GstBlendVideoFormatInfo * srcinfo, - const guint8 * line, guint xoff, int j) -{ - int i; - guint8 *destline = GET_LINE (dest, 0, j) + GST_ROUND_UP_2 (xoff + 3); - - for (i = 0; i < srcinfo->width / 2; i++) { - GST_WRITE_UINT16_LE (destline + i * 8 + 0, line[(i * 2 + 0) * 4 + 2] << 8); - GST_WRITE_UINT16_LE (destline + i * 8 + 2, line[(i * 2 + 0) * 4 + 1] << 8); - GST_WRITE_UINT16_LE (destline + i * 8 + 4, line[(i * 2 + 1) * 4 + 3] << 8); - GST_WRITE_UINT16_LE (destline + i * 8 + 8, line[(i * 2 + 0) * 4 + 1] << 8); - } -} - -static void -getline_Y41B (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - cogorc_getline_YUV9 (dest, - GET_LINE (src, 0, j) + xoff, - GET_LINE (src, 1, j) + (xoff / 4), GET_LINE (src, 2, j) + (xoff / 4), - src->width / 2); -} - -static void -putline_Y41B (GstBlendVideoFormatInfo * dest, - GstBlendVideoFormatInfo * srcinfo, const guint8 * line, guint xoff, int j) -{ - int i; - guint8 *destlineY = GET_LINE (dest, 0, j) + xoff; - guint8 *destlineU = GET_LINE (dest, 1, j) + (xoff / 4); - guint8 *destlineV = GET_LINE (dest, 2, j) + (xoff / 4); - - for (i = 0; i < srcinfo->width - 3; i += 4) { - destlineY[i] = line[i * 4 + 1]; - destlineY[i + 1] = line[i * 4 + 5]; - destlineY[i + 2] = line[i * 4 + 9]; - destlineY[i + 3] = line[i * 4 + 13]; - - destlineU[i >> 2] = - (line[i * 4 + 2] + line[i * 4 + 6] + line[i * 4 + 10] + line[i * 4 + - 14] + 2) >> 2; - destlineV[i >> 2] = - (line[i * 4 + 3] + line[i * 4 + 7] + line[i * 4 + 11] + line[i * 4 + - 15] + 2) >> 2; - } - - if (i == srcinfo->width - 3) { - destlineY[i] = line[i * 4 + 1]; - destlineY[i + 1] = line[i * 4 + 5]; - destlineY[i + 2] = line[i * 4 + 9]; - - destlineU[i >> 2] = - (line[i * 4 + 2] + line[i * 4 + 6] + line[i * 4 + 10] + 1) / 3; - destlineV[i >> 2] = - (line[i * 4 + 3] + line[i * 4 + 7] + line[i * 4 + 11] + 1) / 3; - } else if (i == srcinfo->width - 2) { - destlineY[i] = line[i * 4 + 1]; - destlineY[i + 1] = line[i * 4 + 5]; - - destlineU[i >> 2] = (line[i * 4 + 2] + line[i * 4 + 6] + 1) >> 1; - destlineV[i >> 2] = (line[i * 4 + 3] + line[i * 4 + 7] + 1) >> 1; - } else if (i == srcinfo->width - 1) { - destlineY[i + 1] = line[i * 4 + 5]; - - destlineU[i >> 2] = line[i * 4 + 2]; - destlineV[i >> 2] = line[i * 4 + 3]; - } -} - -static void -getline_Y42B (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - cogorc_getline_Y42B (dest, - GET_LINE (src, 0, j) + xoff, - GET_LINE (src, 1, j) + GST_ROUND_UP_2 (xoff / 2), - GET_LINE (src, 2, j) + GST_ROUND_UP_2 (xoff / 2), src->width / 2); -} - -static void -putline_Y42B (GstBlendVideoFormatInfo * dest, - GstBlendVideoFormatInfo * srcinfo, const guint8 * line, guint xoff, int j) -{ - cogorc_putline_Y42B (GET_LINE (dest, 0, j) + xoff, - GET_LINE (dest, 1, j) + GST_ROUND_UP_2 (xoff / 2), - GET_LINE (dest, 2, j) + GST_ROUND_UP_2 (xoff / 2), line, - srcinfo->width / 2); -} - -static void -getline_Y444 (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - cogorc_getline_Y444 (dest, - GET_LINE (src, 0, j) + xoff, - GET_LINE (src, 1, j) + xoff, GET_LINE (src, 2, j) + xoff, src->width); -} - -static void -putline_Y444 (GstBlendVideoFormatInfo * dest, - GstBlendVideoFormatInfo * srcinfo, const guint8 * line, guint xoff, int j) -{ - cogorc_putline_Y444 (GET_LINE (dest, 0, j) + xoff, - GET_LINE (dest, 1, j) + xoff, - GET_LINE (dest, 2, j) + xoff, line, srcinfo->width); -} - -static void -getline_Y800 (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - cogorc_getline_Y800 (dest, GET_LINE (src, 0, j) + xoff, src->width); -} - -static void -putline_Y800 (GstBlendVideoFormatInfo * dest, - GstBlendVideoFormatInfo * srcinfo, const guint8 * line, guint xoff, int j) -{ - cogorc_putline_Y800 (GET_LINE (dest, 0, j) + xoff, line, srcinfo->width); -} - -static void -getline_Y16 (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - cogorc_getline_Y16 (dest, GET_LINE (src, 0, j) + xoff * 2, src->width); -} - -static void -putline_Y16 (GstBlendVideoFormatInfo * dest, - GstBlendVideoFormatInfo * srcinfo, const guint8 * line, guint xoff, int j) -{ - cogorc_putline_Y16 (GET_LINE (dest, 0, j) + xoff * 2, line, srcinfo->width); -} - -static void -getline_NV12 (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - cogorc_getline_NV12 (dest, - GET_LINE (src, 0, j) + xoff, - GET_LINE (src, 1, j >> 1) + xoff, src->width / 2); -} - -static void -putline_NV12 (GstBlendVideoFormatInfo * dest, - GstBlendVideoFormatInfo * srcinfo, const guint8 * line, guint xoff, int j) -{ - cogorc_putline_NV12 (GET_LINE (dest, 0, j) + xoff, - GET_LINE (dest, 1, j >> 1) + xoff, line, srcinfo->width / 2); -} - -static void -getline_NV21 (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - cogorc_getline_NV21 (dest, - GET_LINE (src, 0, j) + xoff, - GET_LINE (src, 1, j >> 1) + xoff, src->width / 2); -} - -static void -putline_NV21 (GstBlendVideoFormatInfo * dest, - GstBlendVideoFormatInfo * srcinfo, const guint8 * line, guint xoff, int j) -{ - cogorc_putline_NV21 (GET_LINE (dest, 0, j) + xoff, - GET_LINE (dest, 1, j >> 1) + xoff, line, srcinfo->width / 2); -} - -static void -getline_UYVP (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - int i; - const guint8 *srcline = GET_LINE (src, 0, j) - + xoff * 3; - - for (i = 0; i < src->width; i += 2) { - guint16 y0, y1; - guint16 u0; - guint16 v0; - - u0 = (srcline[(i / 2) * 5 + 0] << 2) | (srcline[(i / 2) * 5 + 1] >> 6); - - y0 = ((srcline[(i / 2) * 5 + 1] & 0x3f) << 4) | - (srcline[(i / 2) * 5 + 2] >> 4); - - v0 = ((srcline[(i / 2) * 5 + 2] & 0x0f) << 6) | - (srcline[(i / 2) * 5 + 3] >> 2); - - y1 = ((srcline[(i / 2) * 5 + 3] & 0x03) << 8) | srcline[(i / 2) * 5 + 4]; - - dest[i * 4 + 0] = 0xff; - dest[i * 4 + 1] = y0 >> 2; - dest[i * 4 + 2] = u0 >> 2; - dest[i * 4 + 3] = v0 >> 2; - dest[i * 4 + 4] = 0xff; - dest[i * 4 + 5] = y1 >> 2; - dest[i * 4 + 6] = u0 >> 2; - dest[i * 4 + 7] = v0 >> 2; - } -} - -static void -putline_UYVP (GstBlendVideoFormatInfo * dest, - GstBlendVideoFormatInfo * srcinfo, const guint8 * line, guint xoff, int j) -{ - int i; - guint8 *destline = GET_LINE (dest, 0, j) + xoff * 3; - - for (i = 0; i < srcinfo->width; i += 2) { - guint16 y0, y1; - guint16 u0; - guint16 v0; - - y0 = line[4 * (i + 0) + 1]; - y1 = line[4 * (i + 1) + 1]; - u0 = (line[4 * (i + 0) + 2] + line[4 * (i + 1) + 2] + 1) >> 1; - v0 = (line[4 * (i + 0) + 3] + line[4 * (i + 1) + 3] + 1) >> 1; - - destline[(i / 2) * 5 + 0] = u0; - destline[(i / 2) * 5 + 1] = y0 >> 2; - destline[(i / 2) * 5 + 2] = (y0 << 6) | (v0 >> 4); - destline[(i / 2) * 5 + 3] = (v0 << 4) | (y1 >> 2); - destline[(i / 2) * 5 + 4] = (y1 << 2); - } -} - -static void -getline_A420 (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - cogorc_getline_A420 (dest, - GET_LINE (src, 0, j) + xoff, - GET_LINE (src, 1, j >> 1) + GST_ROUND_UP_2 (xoff / 2), - GET_LINE (src, 2, j >> 1) + GST_ROUND_UP_2 (xoff / 2), - GET_LINE (src, 3, j) + GST_ROUND_UP_2 (xoff / 2), src->width); -} - -static void -putline_A420 (GstBlendVideoFormatInfo * dest, - GstBlendVideoFormatInfo * srcinfo, const guint8 * line, guint xoff, int j) -{ - cogorc_putline_A420 (GET_LINE (dest, 0, j) + xoff, - GET_LINE (dest, 1, j >> 1) + GST_ROUND_UP_2 (xoff / 2), - GET_LINE (dest, 2, j >> 1) + GST_ROUND_UP_2 (xoff / 2), - GET_LINE (dest, 3, j) + GST_ROUND_UP_2 (xoff / 2), line, - srcinfo->width / 2); -} - -static void -getline_YUV9 (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - cogorc_getline_YUV9 (dest, - GET_LINE (src, 0, j) + xoff, - GET_LINE (src, 1, j >> 2) + GST_ROUND_UP_4 (xoff / 4), - GET_LINE (src, 2, j >> 2) + GST_ROUND_UP_4 (xoff / 4), src->width / 2); -} - -static void -putline_YUV9 (GstBlendVideoFormatInfo * dest, - GstBlendVideoFormatInfo * srcinfo, const guint8 * line, guint xoff, int j) -{ - int i; - guint8 *destY = GET_LINE (dest, 0, j) + xoff; - guint8 *destU = GET_LINE (dest, 1, j >> 2) + GST_ROUND_UP_4 (xoff / 4); - guint8 *destV = GET_LINE (dest, 2, j >> 2) + GST_ROUND_UP_4 (xoff / 4); - guint width = srcinfo->width; - - for (i = 0; i < width - 3; i += 4) { - destY[i] = line[i * 4 + 1]; - destY[i + 1] = line[i * 4 + 5]; - destY[i + 2] = line[i * 4 + 9]; - destY[i + 3] = line[i * 4 + 13]; - if (j % 4 == 0) { - destU[i >> 2] = - (line[i * 4 + 2] + line[i * 4 + 6] + line[i * 4 + 10] + line[i * 4 + - 14]) >> 2; - destV[i >> 2] = - (line[i * 4 + 3] + line[i * 4 + 7] + line[i * 4 + 11] + line[i * 4 + - 15]) >> 2; - } - } - - if (i == width - 3) { - destY[i] = line[i * 4 + 1]; - destY[i + 1] = line[i * 4 + 5]; - destY[i + 2] = line[i * 4 + 9]; - if (j % 4 == 0) { - destU[i >> 2] = - (line[i * 4 + 2] + line[i * 4 + 6] + line[i * 4 + 10]) / 3; - destV[i >> 2] = - (line[i * 4 + 3] + line[i * 4 + 7] + line[i * 4 + 11]) / 3; - } - } else if (i == width - 2) { - destY[i] = line[i * 4 + 1]; - destY[i + 1] = line[i * 4 + 5]; - if (j % 4 == 0) { - destU[i >> 2] = (line[i * 4 + 2] + line[i * 4 + 6]) >> 1; - destV[i >> 2] = (line[i * 4 + 3] + line[i * 4 + 7]) >> 1; - } - } else if (i == width - 1) { - destY[i] = line[i * 4 + 1]; - destU[i >> 2] = line[i * 4 + 2]; - destV[i >> 2] = line[i * 4 + 3]; - } -} - -static void -getline_IYU1 (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - int i; - const guint8 *srcline = - GET_LINE (src, 0, j) + GST_ROUND_UP_2 ((xoff * 3) / 2); - guint width = src->width; - - for (i = 0; i < width - 3; i += 4) { - dest[i * 4 + 0] = 0xff; - dest[i * 4 + 4] = 0xff; - dest[i * 4 + 8] = 0xff; - dest[i * 4 + 12] = 0xff; - dest[i * 4 + 1] = srcline[(i >> 2) * 6 + 1]; - dest[i * 4 + 5] = srcline[(i >> 2) * 6 + 2]; - dest[i * 4 + 9] = srcline[(i >> 2) * 6 + 4]; - dest[i * 4 + 13] = srcline[(i >> 2) * 6 + 5]; - dest[i * 4 + 2] = dest[i * 4 + 6] = dest[i * 4 + 10] = dest[i * 4 + 14] = - srcline[(i >> 2) * 6 + 0]; - dest[i * 4 + 3] = dest[i * 4 + 7] = dest[i * 4 + 11] = dest[i * 4 + 15] = - srcline[(i >> 2) * 6 + 3]; - } - - if (i == width - 3) { - dest[i * 4 + 0] = 0xff; - dest[i * 4 + 4] = 0xff; - dest[i * 4 + 8] = 0xff; - dest[i * 4 + 1] = srcline[(i >> 2) * 6 + 1]; - dest[i * 4 + 5] = srcline[(i >> 2) * 6 + 2]; - dest[i * 4 + 9] = srcline[(i >> 2) * 6 + 4]; - dest[i * 4 + 2] = dest[i * 4 + 6] = dest[i * 4 + 10] = - srcline[(i >> 2) * 6 + 0]; - dest[i * 4 + 3] = dest[i * 4 + 7] = dest[i * 4 + 11] = - srcline[(i >> 2) * 6 + 3]; - } else if (i == width - 2) { - dest[i * 4 + 0] = 0xff; - dest[i * 4 + 4] = 0xff; - dest[i * 4 + 1] = srcline[(i >> 2) * 6 + 1]; - dest[i * 4 + 5] = srcline[(i >> 2) * 6 + 2]; - dest[i * 4 + 2] = dest[i * 4 + 6] = srcline[(i >> 2) * 6 + 0]; - dest[i * 4 + 3] = dest[i * 4 + 7] = srcline[(i >> 2) * 6 + 3]; - } else if (i == width - 1) { - dest[i * 4 + 0] = 0xff; - dest[i * 4 + 1] = srcline[(i >> 2) * 6 + 1]; - dest[i * 4 + 2] = srcline[(i >> 2) * 6 + 0]; - dest[i * 4 + 3] = srcline[(i >> 2) * 6 + 3]; - } -} - -static void -putline_IYU1 (GstBlendVideoFormatInfo * dest, - GstBlendVideoFormatInfo * srcinfo, const guint8 * line, guint xoff, int j) -{ - int i; - guint8 *destline = GET_LINE (dest, 0, j) + GST_ROUND_UP_2 ((xoff * 3) / 2); - guint width = srcinfo->width; - - for (i = 0; i < width - 3; i += 4) { - destline[(i >> 2) * 6 + 1] = line[i * 4 + 1]; - destline[(i >> 2) * 6 + 2] = line[i * 4 + 5]; - destline[(i >> 2) * 6 + 4] = line[i * 4 + 9]; - destline[(i >> 2) * 6 + 5] = line[i * 4 + 13]; - destline[(i >> 2) * 6 + 0] = - (line[i * 4 + 2] + line[i * 4 + 6] + line[i * 4 + 10] + line[i * 4 + - 14]) >> 2; - destline[(i >> 2) * 6 + 3] = - (line[i * 4 + 3] + line[i * 4 + 7] + line[i * 4 + 11] + line[i * 4 + - 15]) >> 2; - } - - if (i == width - 3) { - destline[(i >> 2) * 6 + 1] = line[i * 4 + 1]; - destline[(i >> 2) * 6 + 2] = line[i * 4 + 5]; - destline[(i >> 2) * 6 + 4] = line[i * 4 + 9]; - destline[(i >> 2) * 6 + 0] = - (line[i * 4 + 2] + line[i * 4 + 6] + line[i * 4 + 10]) / 3; - destline[(i >> 2) * 6 + 3] = - (line[i * 4 + 3] + line[i * 4 + 7] + line[i * 4 + 11]) / 3; - } else if (i == width - 2) { - destline[(i >> 2) * 6 + 1] = line[i * 4 + 1]; - destline[(i >> 2) * 6 + 2] = line[i * 4 + 5]; - destline[(i >> 2) * 6 + 0] = (line[i * 4 + 2] + line[i * 4 + 6]) >> 1; - destline[(i >> 2) * 6 + 3] = (line[i * 4 + 3] + line[i * 4 + 7]) >> 1; - } else if (i == width - 1) { - destline[(i >> 2) * 6 + 1] = line[i * 4 + 1]; - destline[(i >> 2) * 6 + 0] = line[i * 4 + 2]; - destline[(i >> 2) * 6 + 3] = line[i * 4 + 3]; - } -} - - -/* Line conversion to ARGB */ -static void -getline_RGB (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - int i; - const guint8 *srcline = GET_LINE (src, 0, j) + xoff * 3; - - for (i = 0; i < src->width; i++) { - dest[i * 4 + 0] = 0xff; - dest[i * 4 + 1] = srcline[i * 3 + 0]; - dest[i * 4 + 2] = srcline[i * 3 + 1]; - dest[i * 4 + 3] = srcline[i * 3 + 2]; - } -} - -static void -putline_RGB (GstBlendVideoFormatInfo * dest, GstBlendVideoFormatInfo * srcinfo, - const guint8 * line, guint xoff, int j) -{ - int i; - guint8 *destline = GET_LINE (dest, 0, j) + xoff * 3; - - for (i = 0; i < srcinfo->width; i++) { - destline[i * 3 + 0] = line[i * 4 + 1]; - destline[i * 3 + 1] = line[i * 4 + 2]; - destline[i * 3 + 2] = line[i * 4 + 3]; - } -} - -static void -getline_BGR (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - int i; - const guint8 *srcline = GET_LINE (src, 0, j) + xoff * 3; - - for (i = 0; i < src->width; i++) { - dest[i * 4 + 0] = 0xff; - dest[i * 4 + 1] = srcline[i * 3 + 2]; - dest[i * 4 + 2] = srcline[i * 3 + 1]; - dest[i * 4 + 3] = srcline[i * 3 + 0]; - } -} - -static void -putline_BGR (GstBlendVideoFormatInfo * dest, GstBlendVideoFormatInfo * srcinfo, - const guint8 * line, guint xoff, int j) -{ - int i; - guint8 *destline = GET_LINE (dest, 0, j) + xoff * 3; - - for (i = 0; i < srcinfo->width; i++) { - destline[i * 3 + 0] = line[i * 4 + 3]; - destline[i * 3 + 1] = line[i * 4 + 2]; - destline[i * 3 + 2] = line[i * 4 + 1]; - } -} - -static void -getline_RGBA (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - cogorc_getline_RGBA (dest, GET_LINE (src, 0, j) + (4 * xoff), src->width); -} - -static void -putline_RGBA (GstBlendVideoFormatInfo * dest, GstBlendVideoFormatInfo * srcinfo, - const guint8 * line, guint xoff, int j) -{ - cogorc_putline_RGBA (GET_LINE (dest, 0, j) + (4 * xoff), - line, srcinfo->width); -} - -static void -getline_ARGB (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - - memcpy (dest, GET_LINE (src, 0, j), (src->width - xoff) * 4); -} - -static void -putline_ARGB (GstBlendVideoFormatInfo * dest, GstBlendVideoFormatInfo * srcinfo, - const guint8 * line, guint xoff, int j) -{ - memcpy (GET_LINE (dest, 0, j) + (xoff * 4), line, srcinfo->width * 4); -} - -static void -getline_RGB16 (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - int i; - const guint16 *srcline = (const guint16 *) GET_LINE (src, 0, j) - + (xoff * 3); - - for (i = 0; i < src->width; i++) { - dest[i * 4 + 0] = 0xff; - dest[i * 4 + 1] = ((srcline[i] >> 11) & 0x1f) << 3; - dest[i * 4 + 2] = ((srcline[i] >> 5) & 0x3f) << 2; - dest[i * 4 + 3] = ((srcline[i]) & 0x1f) << 3; - } -} - -static void -putline_RGB16 (GstBlendVideoFormatInfo * dest, - GstBlendVideoFormatInfo * srcinfo, const guint8 * line, guint xoff, int j) -{ - int i; - guint16 *destline = (guint16 *) GET_LINE (dest, 0, j) + (xoff * 3); - - for (i = 0; i < srcinfo->width; i++) { - destline[i] = ((line[i * 4 + 1] >> 3) << 11) | ((line[i * 4 + - 2] >> 2) << 5) | (line[i * 4 + 3] >> 3); - } -} - -static void -getline_RGB15 (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - int i; - const guint16 *srcline = (const guint16 *) GET_LINE (src, 0, j) - + (xoff * 3); - - for (i = 0; i < src->width; i++) { - dest[i * 4 + 0] = 0xff; - dest[i * 4 + 1] = ((srcline[i] >> 10) & 0x1f) << 3; - dest[i * 4 + 2] = ((srcline[i] >> 5) & 0x1f) << 3; - dest[i * 4 + 3] = ((srcline[i]) & 0x1f) << 3; - } -} - -static void -putline_RGB15 (GstBlendVideoFormatInfo * dest, - GstBlendVideoFormatInfo * srcinfo, const guint8 * line, guint xoff, int j) -{ - int i; - guint16 *destline = (guint16 *) GET_LINE (dest, 0, j) + (xoff * 3); - - for (i = 0; i < srcinfo->width; i++) { - destline[i] = ((line[i * 4 + 1] >> 3) << 10) | ((line[i * 4 + - 2] >> 3) << 5) | (line[i * 4 + 3] >> 3); - } -} - -static void -getline_BGR15 (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - int i; - const guint16 *srcline = (const guint16 *) GET_LINE (src, 0, j) - + (xoff * 3); - - for (i = 0; i < src->width; i++) { - dest[i * 4 + 0] = 0xff; - dest[i * 4 + 3] = ((srcline[i] >> 10) & 0x1f) << 3; - dest[i * 4 + 2] = ((srcline[i] >> 5) & 0x1f) << 3; - dest[i * 4 + 1] = ((srcline[i]) & 0x1f) << 3; - } -} - -static void -putline_BGR15 (GstBlendVideoFormatInfo * dest, - GstBlendVideoFormatInfo * srcinfo, const guint8 * line, guint xoff, int j) -{ - int i; - guint16 *destline = (guint16 *) GET_LINE (dest, 0, j) + (xoff * 3); - - for (i = 0; i < srcinfo->width; i++) { - destline[i] = ((line[i * 4 + 3] >> 3) << 10) | ((line[i * 4 + - 2] >> 3) << 5) | (line[i * 4 + 1] >> 3); - } -} - -static void -getline_BGR16 (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - int i; - const guint16 *srcline = (const guint16 *) GET_LINE (src, 0, j) - + (xoff * 3); - - for (i = 0; i < src->width; i++) { - dest[i * 4 + 0] = 0xff; - dest[i * 4 + 3] = ((srcline[i] >> 11) & 0x1f) << 3; - dest[i * 4 + 2] = ((srcline[i] >> 5) & 0x3f) << 2; - dest[i * 4 + 1] = ((srcline[i]) & 0x1f) << 3; - } -} - -static void -putline_BGR16 (GstBlendVideoFormatInfo * dest, - GstBlendVideoFormatInfo * srcinfo, const guint8 * line, guint xoff, int j) -{ - int i; - guint16 *destline = (guint16 *) GET_LINE (dest, 0, j) + (xoff * 3); - - for (i = 0; i < srcinfo->width; i++) { - destline[i] = ((line[i * 4 + 3] >> 3) << 11) | ((line[i * 4 + - 2] >> 2) << 5) | (line[i * 4 + 1] >> 3); - } -} - -static void -getline_BGRA (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - cogorc_getline_BGRA (dest, GET_LINE (src, 0, j) + xoff * 4, src->width); -} - -static void -putline_BGRA (GstBlendVideoFormatInfo * dest, - GstBlendVideoFormatInfo * srcinfo, const guint8 * line, guint xoff, int j) -{ - cogorc_putline_BGRA (GET_LINE (dest, 0, j) + xoff * 4, line, srcinfo->width); -} - -static void -getline_ABGR (guint8 * dest, const GstBlendVideoFormatInfo * src, guint xoff, - int j) -{ - cogorc_getline_ABGR (dest, GET_LINE (src, 0, j) + (xoff * 4), src->width); -} - -static void -putline_ABGR (GstBlendVideoFormatInfo * dest, - GstBlendVideoFormatInfo * srcinfo, const guint8 * line, guint xoff, int j) -{ - cogorc_putline_ABGR (GET_LINE (dest, 0, j) + (xoff * 4), - line, srcinfo->width); -} - -static const GetPutLine lines[] = { - /* YUV lines conversion */ - {GST_VIDEO_FORMAT_I420, getline_I420, putline_I420}, - {GST_VIDEO_FORMAT_YV12, getline_I420, putline_I420}, - {GST_VIDEO_FORMAT_AYUV, getline_AYUV, putline_AYUV}, - {GST_VIDEO_FORMAT_YUY2, getline_YUY2, putline_YUY2}, - {GST_VIDEO_FORMAT_UYVY, getline_UYVY, putline_UYVY}, - {GST_VIDEO_FORMAT_v308, getline_v308, putline_v308}, - {GST_VIDEO_FORMAT_v210, getline_v210, putline_v210}, - {GST_VIDEO_FORMAT_v216, getline_v216, putline_v216}, - {GST_VIDEO_FORMAT_Y41B, getline_Y41B, putline_Y41B}, - {GST_VIDEO_FORMAT_Y42B, getline_Y42B, putline_Y42B}, - {GST_VIDEO_FORMAT_Y444, getline_Y444, putline_Y444}, - {GST_VIDEO_FORMAT_Y800, getline_Y800, putline_Y800}, - {GST_VIDEO_FORMAT_Y16, getline_Y16, putline_Y16}, - {GST_VIDEO_FORMAT_NV12, getline_NV12, putline_NV12}, - {GST_VIDEO_FORMAT_NV21, getline_NV21, putline_NV21}, - {GST_VIDEO_FORMAT_UYVP, getline_UYVP, putline_UYVP}, - {GST_VIDEO_FORMAT_A420, getline_A420, putline_A420}, - {GST_VIDEO_FORMAT_YUV9, getline_YUV9, putline_YUV9}, - {GST_VIDEO_FORMAT_IYU1, getline_IYU1, putline_IYU1}, - - /* ARGB lines conversion */ - {GST_VIDEO_FORMAT_RGB, getline_RGB, putline_RGB}, - {GST_VIDEO_FORMAT_BGR, getline_BGR, putline_BGR}, - {GST_VIDEO_FORMAT_RGBx, getline_RGBA, putline_RGBA}, - {GST_VIDEO_FORMAT_RGBA, getline_RGBA, putline_RGBA}, - {GST_VIDEO_FORMAT_ARGB, getline_ARGB, putline_ARGB}, - {GST_VIDEO_FORMAT_RGB16, getline_RGB16, putline_RGB16}, - {GST_VIDEO_FORMAT_BGR16, getline_BGR16, putline_BGR16}, - {GST_VIDEO_FORMAT_BGR15, getline_BGR15, putline_BGR15}, - {GST_VIDEO_FORMAT_RGB15, getline_RGB15, putline_RGB15}, - {GST_VIDEO_FORMAT_BGRA, getline_BGRA, putline_BGRA}, - {GST_VIDEO_FORMAT_ABGR, getline_ABGR, putline_ABGR}, - {GST_VIDEO_FORMAT_BGRx, getline_BGRA, putline_BGRA} -}; - static void matrix_identity (guint8 * tmpline, guint width) { @@ -1215,28 +136,6 @@ matrix_yuv_to_rgb (guint8 * tmpline, guint width) } } -static gboolean -lookup_getput (GetPutLine * getput, GstVideoFormat fmt) -{ - int i; - - getput->getline = NULL; - getput->putline = NULL; - getput->matrix = matrix_identity; - - for (i = 0; i < sizeof (lines) / sizeof (lines[0]); i++) { - if (lines[i].format == fmt) { - getput->getline = lines[i].getline; - getput->putline = lines[i].putline; - - return TRUE; - } - } - GST_WARNING ("Conversion from %i not supported", fmt); - - return FALSE; -} - #define BLEND00(ret, alpha, v0, v1) \ G_STMT_START { \ ret = (v0 * alpha + v1 * (255 - alpha)) / 255; \ @@ -1249,7 +148,7 @@ G_STMT_START { \ /* returns newly-allocated pixels in src->pixels, which caller must g_free() */ void -video_blend_scale_linear_RGBA (GstBlendVideoFormatInfo * src, +gst_video_blend_scale_linear_RGBA (GstVideoFrame * src, gint dest_height, gint dest_width) { const guint8 *src_pixels; @@ -1331,8 +230,8 @@ video_blend_scale_linear_RGBA (GstBlendVideoFormatInfo * src, * Lets you blend the @src image into the @dest image */ gboolean -video_blend (GstBlendVideoFormatInfo * dest, - GstBlendVideoFormatInfo * src, guint x, guint y, gfloat global_alpha) +gst_video_blend (GstVideoFrame * dest, + GstVideoFrame * src, guint x, guint y, gfloat global_alpha) { guint i, j, global_alpha_val, src_width, src_height; GetPutLine getputdest, getputsrc; @@ -1470,36 +369,3 @@ failed: return FALSE; } - -/* video_blend_format_info_init: - * @info: The #GstBlendVideoFormatInfo to initialize - * @pixels: The pixels data in @fmt format - * @height: The height of the image - * @width: the width of the image - * @fmt: The #GstVideoFormat of the image - * - * Initializes a GstBlendVideoFormatInfo. - * This function can be called on already initialized instances. - */ -void -video_blend_format_info_init (GstBlendVideoFormatInfo * info, - guint8 * pixels, guint height, guint width, GstVideoFormat fmt, - gboolean premultiplied_alpha) -{ - guint nb_component = gst_video_format_has_alpha (fmt) ? 4 : 3; - - ensure_debug_category (); - - GST_DEBUG - ("Initializing video bleding info, height %i, width %i, fmt %i nb_component %i", - height, width, fmt, nb_component); - - info->width = width; - info->height = height; - info->pixels = pixels; - info->fmt = fmt; - info->premultiplied_alpha = premultiplied_alpha; - info->size = gst_video_format_get_size (fmt, height, width); - - fill_planes (info); -} diff --git a/gst-libs/gst/video/video-blend.h b/gst-libs/gst/video/video-blend.h index 7e4c50f..d14485a 100644 --- a/gst-libs/gst/video/video-blend.h +++ b/gst-libs/gst/video/video-blend.h @@ -27,51 +27,12 @@ #include #include -#define MAX_VIDEO_PLANES 4 +void gst_video_blend_scale_linear_RGBA (GstVideoFrame * src, + gint dest_height, gint dest_width); -typedef struct _GstBlendVideoFormatInfo GstBlendVideoFormatInfo; - -/* GstBlendVideoFormatInfo: - * @fmt: The #GstVideoFormat describing the video format - * @width: The width of the video - * @height: The height of the video - * @pixels: The buffer containing the pixels of the video - * @size: The size in byte of @pixels - * @offset: The offsets of the different component of the video - * @stride: The stride of the different component of the video - * - * Information describing image properties containing necessary - * fields to do video blending. - */ -struct _GstBlendVideoFormatInfo -{ - GstVideoFormat fmt; - - gint width; - gint height; - - guint8 * pixels; - gsize size; - - gboolean premultiplied_alpha; - - /* YUV components: Y=0, U=1, V=2, A=3 - * RGB components: R=0, G=1, B=2, A=3 */ - gint offset[MAX_VIDEO_PLANES]; - gint stride[MAX_VIDEO_PLANES]; -}; - -void video_blend_format_info_init (GstBlendVideoFormatInfo * info, - guint8 *pixels, guint height, - guint width, GstVideoFormat fmt, - gboolean premultiplied_alpha); - -void video_blend_scale_linear_RGBA (GstBlendVideoFormatInfo * src, - gint dest_height, gint dest_width); - -gboolean video_blend (GstBlendVideoFormatInfo * dest, - GstBlendVideoFormatInfo * src, - guint x, guint y, - gfloat global_alpha); +gboolean gst_video_blend (GstVideoFrame * dest, + GstVideoFrame * src, + guint x, guint y, + gfloat global_alpha); #endif