diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/msdk/msdk.c | 182 |
1 files changed, 0 insertions, 182 deletions
diff --git a/sys/msdk/msdk.c b/sys/msdk/msdk.c index 962aa58d5..67d74aff0 100644 --- a/sys/msdk/msdk.c +++ b/sys/msdk/msdk.c @@ -59,188 +59,6 @@ static const struct map gst_msdk_video_format_to_mfx_map[] = { {0, 0, 0} }; -static inline guint -msdk_get_free_surface_index (mfxFrameSurface1 * surfaces, guint size) -{ - if (surfaces) { - guint i; - - for (i = 0; i < size; i++) { - if (!surfaces[i].Data.Locked) - return i; - } - } - - return INVALID_INDEX; -} - -mfxFrameSurface1 * -msdk_get_free_surface (mfxFrameSurface1 * surfaces, guint size) -{ - guint idx = INVALID_INDEX; - guint i; - - /* Poll the pool for a maximum of 20 milisecnds */ - for (i = 0; i < 2000; i++) { - idx = msdk_get_free_surface_index (surfaces, size); - - if (idx != INVALID_INDEX) - break; - - g_usleep (10); - } - - return (idx == INVALID_INDEX ? NULL : &surfaces[idx]); -} - -/* FIXME: Only NV12 is supported by now, add other YUV formats */ -void -msdk_frame_to_surface (GstVideoFrame * frame, mfxFrameSurface1 * surface) -{ - guint8 *src, *dst; - guint sstride, dstride; - guint width, height; - guint i, p; - - if (!surface->Data.MemId) { - switch (frame->info.finfo->format) { - case GST_VIDEO_FORMAT_NV12: - surface->Data.Y = GST_VIDEO_FRAME_COMP_DATA (frame, 0); - surface->Data.UV = GST_VIDEO_FRAME_COMP_DATA (frame, 1); - surface->Data.Pitch = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0); - break; - - case GST_VIDEO_FORMAT_YV12: - case GST_VIDEO_FORMAT_I420: - surface->Data.Y = GST_VIDEO_FRAME_COMP_DATA (frame, 0); - surface->Data.U = GST_VIDEO_FRAME_COMP_DATA (frame, 1); - surface->Data.V = GST_VIDEO_FRAME_COMP_DATA (frame, 2); - surface->Data.Pitch = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0); - break; - - case GST_VIDEO_FORMAT_YUY2: - surface->Data.Y = GST_VIDEO_FRAME_PLANE_DATA (frame, 0); - surface->Data.Pitch = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0); - surface->Data.U = surface->Data.Y + 1; - surface->Data.V = surface->Data.Y + 3; - break; - case GST_VIDEO_FORMAT_UYVY: - surface->Data.Y = GST_VIDEO_FRAME_PLANE_DATA (frame, 0); - surface->Data.Pitch = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0); - surface->Data.U = surface->Data.Y; - surface->Data.Y = surface->Data.U + 1; - surface->Data.V = surface->Data.U + 2; - break; - - case GST_VIDEO_FORMAT_BGRA: - surface->Data.R = GST_VIDEO_FRAME_COMP_DATA (frame, 0); - surface->Data.G = surface->Data.R - 1; - surface->Data.B = surface->Data.R - 2; - surface->Data.Pitch = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0); - break; - - default: - g_assert_not_reached (); - break; - } - - return; - } - - - switch (frame->info.finfo->format) { - case GST_VIDEO_FORMAT_NV12: - width = GST_VIDEO_FRAME_COMP_WIDTH (frame, 0); - for (p = 0; p < 2; p++) { - height = GST_VIDEO_FRAME_COMP_HEIGHT (frame, p); - src = GST_VIDEO_FRAME_COMP_DATA (frame, p); - sstride = GST_VIDEO_FRAME_COMP_STRIDE (frame, p); - dst = p == 0 ? surface->Data.Y : surface->Data.UV; - dstride = surface->Data.Pitch; - - for (i = 0; i < height; i++) { - memcpy (dst, src, width); - src += sstride; - dst += dstride; - } - } - break; - - case GST_VIDEO_FORMAT_YV12: - case GST_VIDEO_FORMAT_I420: - for (p = 0; p < 3; p++) { - width = GST_VIDEO_FRAME_COMP_WIDTH (frame, p); - height = GST_VIDEO_FRAME_COMP_HEIGHT (frame, p); - src = GST_VIDEO_FRAME_COMP_DATA (frame, p); - sstride = GST_VIDEO_FRAME_COMP_STRIDE (frame, p); - switch (p) { - case 0: - dst = surface->Data.Y; - break; - case 1: - dst = surface->Data.U; - break; - case 2: - dst = surface->Data.V; - break; - default: - g_assert_not_reached (); - break; - } - dstride = surface->Data.Pitch; - if (p > 0) - dstride = dstride / 2; - - for (i = 0; i < height; i++) { - memcpy (dst, src, width); - src += sstride; - dst += dstride; - } - } - break; - - case GST_VIDEO_FORMAT_YUY2: - case GST_VIDEO_FORMAT_UYVY: - width = GST_VIDEO_FRAME_COMP_WIDTH (frame, 0); - height = GST_VIDEO_FRAME_COMP_HEIGHT (frame, 0); - src = GST_VIDEO_FRAME_COMP_DATA (frame, 0); - sstride = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0); - dst = surface->Data.Y; - dstride = surface->Data.Pitch; - - width *= 2; - width = MIN (sstride, width); - - for (i = 0; i < height; i++) { - memcpy (dst, src, width); - src += sstride; - dst += dstride; - } - break; - - case GST_VIDEO_FORMAT_BGRA: - width = GST_VIDEO_FRAME_COMP_WIDTH (frame, 0); - height = GST_VIDEO_FRAME_COMP_HEIGHT (frame, 0); - src = GST_VIDEO_FRAME_COMP_DATA (frame, 0); - sstride = GST_VIDEO_FRAME_COMP_STRIDE (frame, 0); - dst = surface->Data.B; - dstride = surface->Data.Pitch; - - width *= 4; - - for (i = 0; i < height; i++) { - memcpy (dst, src, width); - src += sstride; - dst += dstride; - } - break; - - default: - g_assert_not_reached (); - break; - } -} - const gchar * msdk_status_to_string (mfxStatus status) { |