summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/util
diff options
context:
space:
mode:
authorBoyuan Zhang <[email protected]>2016-07-21 19:40:15 -0400
committerChristian König <[email protected]>2016-07-25 13:39:18 +0200
commit23b4ab1738f0f4470449c848b37b43568df4a60c (patch)
treeeab21243979a3cef745d22f5387be0126c350b7c /src/gallium/auxiliary/util
parent5bcaa1b9e9707aea7be73b406345bb9e46f92a18 (diff)
vl/util: add copy func for yv12image to nv12surface v2
Add function to copy from yv12 image to nv12 surface for VAAPI putimage call. We need this function in VaPutImage call where copying from yv12 image to nv12 surface for encoding. Existing function can't be used because it only work for copying from yv12 surface to nv12 image in Vaapi. v2: cleanup variable types and commit message Signed-off-by: Boyuan Zhang <[email protected]> Signed-off-by: Christian König <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r--src/gallium/auxiliary/util/u_video.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_video.h b/src/gallium/auxiliary/util/u_video.h
index 9196afc11be..7e743de253e 100644
--- a/src/gallium/auxiliary/util/u_video.h
+++ b/src/gallium/auxiliary/util/u_video.h
@@ -130,6 +130,43 @@ u_copy_yv12_to_nv12(void *const *destination_data,
}
static inline void
+u_copy_yv12_img_to_nv12_surf(ubyte *const *src,
+ ubyte *dst,
+ unsigned width,
+ unsigned height,
+ unsigned src_stride,
+ unsigned dst_stride,
+ int field)
+{
+ if (field == 0) {
+ ubyte *src_0 = src[field];
+ for (int i = 0; i < height ; i++) {
+ memcpy(dst, src_0, width);
+ dst += dst_stride;
+ src_0 += src_stride;
+ }
+ } else if (field == 1) {
+ const ubyte *src_1 = src[field];
+ const ubyte *src_2 = src[field+1];
+ bool odd = false;
+ for (unsigned i = 0; i < height ; i++) {
+ for (unsigned j = 0; j < width*2 ; j++) {
+ if (odd == false) {
+ dst[j] = src_1[j/2];
+ odd = true;
+ } else {
+ dst[j] = src_2[j/2];
+ odd = false;
+ }
+ }
+ dst += dst_stride;
+ src_1 += src_stride;
+ src_2 += src_stride;
+ }
+ }
+}
+
+static inline void
u_copy_swap422_packed(void *const *destination_data,
uint32_t const *destination_pitches,
int src_plane, int src_field,