Re: [Mesa-dev] [PATCH 2/9] vl/util: add copy func for yv12image to nv12surface
Hi Christian, A couple of small suggestions. Feel free to amend before pushing or ignore if they're too picky. On 22 July 2016 at 15:14, Christian König wrote: > From: Boyuan Zhang > > 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. > Please wrap this a bit, just like you've done for the other patches. > Signed-off-by: Boyuan Zhang > --- > src/gallium/auxiliary/util/u_video.h | 37 > > 1 file changed, 37 insertions(+) > > diff --git a/src/gallium/auxiliary/util/u_video.h > b/src/gallium/auxiliary/util/u_video.h > index 9196afc..86a7adc 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) { > + ubyte *src_1 = src[field]; > + ubyte *src_2 = src[field+1]; > + bool odd = false; > + for (int i = 0; i < height ; i++) { > + for (int j = 0; j < width*2 ; j++) { Please make the i, j unsigned and constify src_X. Thanks Emil ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/9] vl/util: add copy func for yv12image to nv12surface
From: Boyuan Zhang 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. Signed-off-by: Boyuan Zhang --- src/gallium/auxiliary/util/u_video.h | 37 1 file changed, 37 insertions(+) diff --git a/src/gallium/auxiliary/util/u_video.h b/src/gallium/auxiliary/util/u_video.h index 9196afc..86a7adc 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) { + ubyte *src_1 = src[field]; + ubyte *src_2 = src[field+1]; + bool odd = false; + for (int i = 0; i < height ; i++) { + for (int 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, -- 2.5.0 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 2/9] vl/util: add copy func for yv12image to nv12surface
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. Signed-off-by: Boyuan Zhang --- src/gallium/auxiliary/util/u_video.h | 37 1 file changed, 37 insertions(+) diff --git a/src/gallium/auxiliary/util/u_video.h b/src/gallium/auxiliary/util/u_video.h index 9196afc..86a7adc 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) { + ubyte *src_1 = src[field]; + ubyte *src_2 = src[field+1]; + bool odd = false; + for (int i = 0; i < height ; i++) { + for (int 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, -- 2.7.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev