Mesa (master): st/vdpau: move common functions to util
Leo Liu
leoliu at kemper.freedesktop.org
Wed Oct 1 17:32:58 UTC 2014
Module: Mesa
Branch: master
Commit: 0eb8f8998114855d8d200a70c357d482e8f444fc
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0eb8f8998114855d8d200a70c357d482e8f444fc
Author: Leo Liu <leo.liu at amd.com>
Date: Mon Sep 22 14:07:13 2014 -0400
st/vdpau: move common functions to util
Break out these functions so that they can be shared with a other
state trackers. They will be used in subsequent patches for the new
VA-API state tracker.
Signed-off-by: Leo Liu <leo.liu at amd.com>
---
src/gallium/auxiliary/util/u_video.h | 74 +++++++++++++++++++++++++
src/gallium/state_trackers/vdpau/surface.c | 81 ++--------------------------
2 files changed, 78 insertions(+), 77 deletions(-)
diff --git a/src/gallium/auxiliary/util/u_video.h b/src/gallium/auxiliary/util/u_video.h
index d1ca736..45b2d6e 100644
--- a/src/gallium/auxiliary/util/u_video.h
+++ b/src/gallium/auxiliary/util/u_video.h
@@ -72,6 +72,80 @@ u_reduce_video_profile(enum pipe_video_profile profile)
}
}
+static INLINE void
+u_copy_nv12_to_yv12(void *const *destination_data,
+ uint32_t const *destination_pitches,
+ int src_plane, int src_field,
+ int src_stride, int num_fields,
+ uint8_t const *src,
+ int width, int height)
+{
+ int x, y;
+ unsigned u_stride = destination_pitches[2] * num_fields;
+ unsigned v_stride = destination_pitches[1] * num_fields;
+ uint8_t *u_dst = (uint8_t *)destination_data[2] + destination_pitches[2] * src_field;
+ uint8_t *v_dst = (uint8_t *)destination_data[1] + destination_pitches[1] * src_field;
+
+ /* TODO: SIMD */
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++) {
+ u_dst[x] = src[2*x];
+ v_dst[x] = src[2*x+1];
+ }
+ u_dst += u_stride;
+ v_dst += v_stride;
+ src += src_stride;
+ }
+}
+
+static INLINE void
+u_copy_yv12_to_nv12(void *const *destination_data,
+ uint32_t const *destination_pitches,
+ int src_plane, int src_field,
+ int src_stride, int num_fields,
+ uint8_t const *src,
+ int width, int height)
+{
+ int x, y;
+ unsigned offset = 2 - src_plane;
+ unsigned stride = destination_pitches[1] * num_fields;
+ uint8_t *dst = (uint8_t *)destination_data[1] + destination_pitches[1] * src_field;
+
+ /* TODO: SIMD */
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < 2 * width; x += 2) {
+ dst[x+offset] = src[x>>1];
+ }
+ dst += stride;
+ src += src_stride;
+ }
+}
+
+static INLINE void
+u_copy_swap422_packed(void *const *destination_data,
+ uint32_t const *destination_pitches,
+ int src_plane, int src_field,
+ int src_stride, int num_fields,
+ uint8_t const *src,
+ int width, int height)
+{
+ int x, y;
+ unsigned stride = destination_pitches[0] * num_fields;
+ uint8_t *dst = (uint8_t *)destination_data[0] + destination_pitches[0] * src_field;
+
+ /* TODO: SIMD */
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < 4 * width; x += 4) {
+ dst[x+0] = src[x+1];
+ dst[x+1] = src[x+0];
+ dst[x+2] = src[x+3];
+ dst[x+3] = src[x+2];
+ }
+ dst += stride;
+ src += src_stride;
+ }
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/src/gallium/state_trackers/vdpau/surface.c b/src/gallium/state_trackers/vdpau/surface.c
index 1932cdd..55d0d76 100644
--- a/src/gallium/state_trackers/vdpau/surface.c
+++ b/src/gallium/state_trackers/vdpau/surface.c
@@ -34,6 +34,7 @@
#include "util/u_debug.h"
#include "util/u_rect.h"
#include "util/u_surface.h"
+#include "util/u_video.h"
#include "vl/vl_defines.h"
#include "vdpau_private.h"
@@ -194,80 +195,6 @@ vlVdpVideoSurfaceSize(vlVdpSurface *p_surf, int component,
*height /= 2;
}
-static void
-vlVdpCopyNV12ToYV12(void *const *destination_data,
- uint32_t const *destination_pitches,
- int src_plane, int src_field,
- int src_stride, int num_fields,
- uint8_t const *src,
- int width, int height)
-{
- int x, y;
- unsigned u_stride = destination_pitches[2] * num_fields;
- unsigned v_stride = destination_pitches[1] * num_fields;
- uint8_t *u_dst = (uint8_t *)destination_data[2] + destination_pitches[2] * src_field;
- uint8_t *v_dst = (uint8_t *)destination_data[1] + destination_pitches[1] * src_field;
-
- /* TODO: SIMD */
- for (y = 0; y < height; y++) {
- for (x = 0; x < width; x++) {
- u_dst[x] = src[2*x];
- v_dst[x] = src[2*x+1];
- }
- u_dst += u_stride;
- v_dst += v_stride;
- src += src_stride;
- }
-}
-
-static void
-vlVdpCopyYV12ToNV12(void *const *destination_data,
- uint32_t const *destination_pitches,
- int src_plane, int src_field,
- int src_stride, int num_fields,
- uint8_t const *src,
- int width, int height)
-{
- int x, y;
- unsigned offset = 2 - src_plane;
- unsigned stride = destination_pitches[1] * num_fields;
- uint8_t *dst = (uint8_t *)destination_data[1] + destination_pitches[1] * src_field;
-
- /* TODO: SIMD */
- for (y = 0; y < height; y++) {
- for (x = 0; x < 2 * width; x += 2) {
- dst[x+offset] = src[x>>1];
- }
- dst += stride;
- src += src_stride;
- }
-}
-
-static void
-vlVdpCopySwap422Packed(void *const *destination_data,
- uint32_t const *destination_pitches,
- int src_plane, int src_field,
- int src_stride, int num_fields,
- uint8_t const *src,
- int width, int height)
-{
- int x, y;
- unsigned stride = destination_pitches[0] * num_fields;
- uint8_t *dst = (uint8_t *)destination_data[0] + destination_pitches[0] * src_field;
-
- /* TODO: SIMD */
- for (y = 0; y < height; y++) {
- for (x = 0; x < 4 * width; x += 4) {
- dst[x+0] = src[x+1];
- dst[x+1] = src[x+0];
- dst[x+2] = src[x+3];
- dst[x+3] = src[x+2];
- }
- dst += stride;
- src += src_stride;
- }
-}
-
/**
* Copy image data from a VdpVideoSurface to application memory in a specified
* YCbCr format.
@@ -343,15 +270,15 @@ vlVdpVideoSurfaceGetBitsYCbCr(VdpVideoSurface surface,
}
if (conversion == CONVERSION_NV12_TO_YV12 && i == 1) {
- vlVdpCopyNV12ToYV12(destination_data, destination_pitches,
+ u_copy_nv12_to_yv12(destination_data, destination_pitches,
i, j, transfer->stride, sv->texture->array_size,
map, box.width, box.height);
} else if (conversion == CONVERSION_YV12_TO_NV12 && i > 0) {
- vlVdpCopyYV12ToNV12(destination_data, destination_pitches,
+ u_copy_yv12_to_nv12(destination_data, destination_pitches,
i, j, transfer->stride, sv->texture->array_size,
map, box.width, box.height);
} else if (conversion == CONVERSION_SWAP_YUYV_UYVY) {
- vlVdpCopySwap422Packed(destination_data, destination_pitches,
+ u_copy_swap422_packed(destination_data, destination_pitches,
i, j, transfer->stride, sv->texture->array_size,
map, box.width, box.height);
} else {
More information about the mesa-commit
mailing list