diff options
author | Xiang, Haihao <haihao.xiang@intel.com> | 2012-01-31 16:24:30 +0800 |
---|---|---|
committer | Xiang, Haihao <haihao.xiang@intel.com> | 2012-02-01 14:19:48 +0800 |
commit | 26b7035c60bc355d78f708f719c60637898e0cf9 (patch) | |
tree | 8048d298ed440d5505cca67b84961185fdb29fcc | |
parent | 05577797b9b11830db742226f9cd2b5a1b657e5f (diff) |
test/encode/avcenc: support I420/YV12 format
Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
-rw-r--r-- | test/encode/avcenc.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/test/encode/avcenc.c b/test/encode/avcenc.c index a4f343f..80aa6d4 100644 --- a/test/encode/avcenc.c +++ b/test/encode/avcenc.c @@ -267,6 +267,10 @@ static void avcenc_update_picture_parameter(int slice_type, int frame_num, int d CHECK_VASTATUS(va_status,"vaCreateBuffer"); } +#ifndef VA_FOURCC_I420 +#define VA_FOURCC_I420 0x30323449 +#endif + static void upload_yuv_to_surface(FILE *yuv_fp, VASurfaceID surface_id) { VAImage surface_image; @@ -315,9 +319,22 @@ static void upload_yuv_to_surface(FILE *yuv_fp, VASurfaceID surface_id) u_src += (picture_width / 2); v_src += (picture_width / 2); } - } else { - /* FIXME: fix this later */ - assert(0); + } else if (surface_image.format.fourcc == VA_FOURCC_YV12 || + surface_image.format.fourcc == VA_FOURCC_I420) { + const int U = surface_image.format.fourcc == VA_FOURCC_I420 ? 1 : 2; + const int V = surface_image.format.fourcc == VA_FOURCC_I420 ? 2 : 1; + + u_dst = surface_p + surface_image.offsets[U]; + v_dst = surface_p + surface_image.offsets[V]; + + for (row = 0; row < surface_image.height / 2; row++) { + memcpy(u_dst, u_src, surface_image.width / 2); + memcpy(v_dst, v_src, surface_image.width / 2); + u_dst += surface_image.pitches[U]; + v_dst += surface_image.pitches[V]; + u_src += (picture_width / 2); + v_src += (picture_width / 2); + } } vaUnmapBuffer(va_dpy, surface_image.buf); |