[MPlayer-dev-eng] [PATCH 2/2] vo_xv: Add NV12/NV21 support
Ville Syrjälä
syrjala at sci.fi
Sun Feb 26 23:57:28 EET 2017
Add support for NV12/NV21. Useful for cases when your hardware doesn't
do YV12/I420.
---
libvo/vo_xv.c | 54 +++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 37 insertions(+), 17 deletions(-)
diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c
index 95600fc85b5e..4185ea244b46 100644
--- a/libvo/vo_xv.c
+++ b/libvo/vo_xv.c
@@ -392,28 +392,41 @@ static int draw_slice(uint8_t * image[], int stride[], int w, int h,
memcpy_pic(dst, image[0], w, h, xvimage[current_buf]->pitches[0],
stride[0]);
- x /= 2;
y /= 2;
- w /= 2;
h /= 2;
- dst = xvimage[current_buf]->data + xvimage[current_buf]->offsets[1] +
- xvimage[current_buf]->pitches[1] * y + x;
- if (image_format != IMGFMT_YV12)
- memcpy_pic(dst, image[1], w, h, xvimage[current_buf]->pitches[1],
- stride[1]);
- else
- memcpy_pic(dst, image[2], w, h, xvimage[current_buf]->pitches[1],
- stride[2]);
+ if (image_format == IMGFMT_NV12 || image_format == IMGFMT_NV21)
+ {
+ x &= ~1;
+ w &= ~1;
- dst = xvimage[current_buf]->data + xvimage[current_buf]->offsets[2] +
- xvimage[current_buf]->pitches[2] * y + x;
- if (image_format == IMGFMT_YV12)
+ dst = xvimage[current_buf]->data + xvimage[current_buf]->offsets[1] +
+ xvimage[current_buf]->pitches[1] * y + x;
memcpy_pic(dst, image[1], w, h, xvimage[current_buf]->pitches[1],
stride[1]);
- else
- memcpy_pic(dst, image[2], w, h, xvimage[current_buf]->pitches[1],
- stride[2]);
+ } else
+ {
+ x /= 2;
+ w /= 2;
+
+ dst = xvimage[current_buf]->data + xvimage[current_buf]->offsets[1] +
+ xvimage[current_buf]->pitches[1] * y + x;
+ if (image_format != IMGFMT_YV12)
+ memcpy_pic(dst, image[1], w, h, xvimage[current_buf]->pitches[1],
+ stride[1]);
+ else
+ memcpy_pic(dst, image[2], w, h, xvimage[current_buf]->pitches[1],
+ stride[2]);
+
+ dst = xvimage[current_buf]->data + xvimage[current_buf]->offsets[2] +
+ xvimage[current_buf]->pitches[2] * y + x;
+ if (image_format == IMGFMT_YV12)
+ memcpy_pic(dst, image[1], w, h, xvimage[current_buf]->pitches[1],
+ stride[1]);
+ else
+ memcpy_pic(dst, image[2], w, h, xvimage[current_buf]->pitches[1],
+ stride[2]);
+ }
return 0;
}
@@ -481,7 +494,14 @@ static uint32_t get_image(mp_image_t * mpi)
xvimage[current_buf]->data + xvimage[current_buf]->offsets[0];
mpi->stride[0] = xvimage[current_buf]->pitches[0];
mpi->width = mpi->stride[0] / (mpi->bpp / 8);
- if (mpi->flags & MP_IMGFLAG_PLANAR)
+ if (mpi->flags & MP_IMGFLAG_PLANAR && mpi->num_planes == 2)
+ {
+ // NV12/NV21
+ mpi->planes[1] =
+ xvimage[current_buf]->data +
+ xvimage[current_buf]->offsets[1];
+ mpi->stride[1] = xvimage[current_buf]->pitches[1];
+ } else if (mpi->flags & MP_IMGFLAG_PLANAR)
{
if (mpi->flags & MP_IMGFLAG_SWAPPED)
{
--
2.10.2
More information about the MPlayer-dev-eng
mailing list