diff options
author | Thomas Hellstrom <[email protected]> | 2016-03-03 09:25:44 +0100 |
---|---|---|
committer | Thomas Hellstrom <[email protected]> | 2017-02-24 16:44:33 +0100 |
commit | 3a418322ec6d540b1334f42688839aefb5d88d6d (patch) | |
tree | 803c0fe0488406a45ed151f0abee4cf6af5d7e8a /src/gallium/auxiliary/util | |
parent | 5398d006de3d2bd668e3fc4b80a3de0c101a3e43 (diff) |
st/vdpau: Provide YV12 to NV12 putBits conversion v2
mplayer likes putting YV12 data, and if there is a buffer format mismatch,
the vdpau state tracker would try to reallocate the video surface as an
YV12 surface. A virtual driver doesn't like reallocating and doesn't like YV12
surfaces, so if we can't support YV12, try an YV12 to NV12 conversion
instead.
Also advertize that we actually can do the getBits and putBits conversion.
v2: A previous version of this patch prioritized conversion before
reallocating. This has been changed to prioritize reallocating in this version.
Cc: Christian König <[email protected]>
Acked-by: Christian König <[email protected]>
Signed-off-by: Thomas Hellstrom <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r-- | src/gallium/auxiliary/util/u_video.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/util/u_video.h b/src/gallium/auxiliary/util/u_video.h index 99a8fd6e4f3..7cd6268d1fc 100644 --- a/src/gallium/auxiliary/util/u_video.h +++ b/src/gallium/auxiliary/util/u_video.h @@ -107,6 +107,48 @@ u_copy_nv12_to_yv12(void *const *destination_data, } } +/** + * \brief Copy YV12 chroma data while converting it NV12 + * + * Given a set of YV12 source pointers and -pitches, copy the data to a + * layout typical for NV12 video buffers. + * + * \param source data[in] The plane data pointers. Array of 3. + * \param source_pitches[in] The plane pitches. Array of 3. + * \param dst_plane[in] The destination plane to copy to. For NV12 always 1. + * \param dst_field[in] The destination field if interlaced. + * \param dst_stride[in] The destination stride for this plane. + * \param num_fields[in] The number of fields in the video buffer. + * \param dst[in] The destination plane pointer. + * \param width[in] The source plane width. + * \param height[in] The source plane height. + */ +static inline void +u_copy_nv12_from_yv12(const void *const *source_data, + uint32_t const *source_pitches, + int dst_plane, int dst_field, + int dst_stride, int num_fields, + uint8_t *dst, + int width, int height) +{ + int x, y; + unsigned u_stride = source_pitches[2] * num_fields; + unsigned v_stride = source_pitches[1] * num_fields; + uint8_t *u_src = (uint8_t *)source_data[2] + source_pitches[2] * dst_field; + uint8_t *v_src = (uint8_t *)source_data[1] + source_pitches[1] * dst_field; + + /* TODO: SIMD */ + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + dst[2*x] = u_src[x]; + dst[2*x+1] = v_src[x]; + } + u_src += u_stride; + v_src += v_stride; + dst += dst_stride; + } +} + static inline void u_copy_yv12_to_nv12(void *const *destination_data, uint32_t const *destination_pitches, |