Thanks for your review. I will use 'default format' to replace YV12 in comment.
Since there is no VAConfigID in putsurface test, we can't create VAConfigAttrib. So a surface with specified format can't be created in this context. > -----Original Message----- > From: Xiang, Haihao > Sent: Thursday, May 31, 2012 1:08 PM > To: Zhao, Halley > Cc: [email protected] > Subject: Re: [Libva] [PATCH] test: add putsurface option for color > conversion test > > On Wed, 2012-05-30 at 17:21 +0800, Halley Zhao wrote: > > From: Zhao halley <[email protected]> > > > > --- > > test/putsurface/putsurface_common.c | 93 > ++++++++++++++++++++++++++++++++--- > > 1 files changed, 85 insertions(+), 8 deletions(-) mode change > 100644 > > => 100755 test/putsurface/putsurface_common.c > > > > diff --git a/test/putsurface/putsurface_common.c > > b/test/putsurface/putsurface_common.c > > old mode 100644 > > new mode 100755 > > index 54ae8d3..2ab4245 > > --- a/test/putsurface/putsurface_common.c > > +++ b/test/putsurface/putsurface_common.c > > @@ -76,6 +76,7 @@ static pthread_mutex_t gmutex; static int > > box_width = 32; static int multi_thread = 0; static int verbose = > > 0; > > +static int test_color_conversion = 0; > > > > static VASurfaceID get_next_free_surface(int *index) { @@ -206,13 > > +207,70 @@ static void* putsurface_thread(void *data) > > if (c == 'c' || c == 'C') > > continue_display = 1; > > } > > - vaStatus = vaPutSurface(va_dpy, surface_id, > CAST_DRAWABLE(drawable), > > - 0,0,surface_width,surface_height, > > - 0,0,width,height, > > - (test_clip==0)?NULL:&cliprects[0], > > - (test_clip==0)?0:2, > > - display_field); > > - CHECK_VASTATUS(vaStatus,"vaPutSurface"); > > + if (test_color_conversion) { > > + VAImageFormat image_format; > > + VAImage image ; > > + VASurfaceID new_surface; > > + > > + // create VAImage with YUY2 format > > + image_format.fourcc = VA_FOURCC_YUY2; > > + image_format.byte_order = VA_LSB_FIRST; > > + image_format.bits_per_pixel = 16; > > + > > + vaStatus = vaCreateImage(va_dpy, &image_format, > > + surface_width, surface_height, > > + &image); > > + CHECK_VASTATUS(vaStatus,"vaCreateImage"); > > + > > + // get image from surface (default YV12 format), so > > +YV12->YUY2 conversion happens > > The default surface format is driver dependent, are you sure all > drivers use YV12 as default value ? You can create a VA surface with a > specified format by the new vaCreateSurfaces(). > > > > + vaStatus = vaGetImage(va_dpy, surface_id, 0, 0, > surface_width, surface_height, image.image_id); > > + CHECK_VASTATUS(vaStatus,"vaGetImage"); > > + > > + // create a temp VASurface > > + vaStatus = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420, > > + surface_width, > surface_height, > > + &new_surface, 1, > > + NULL, 0); > > + CHECK_VASTATUS(vaStatus,"vaCreateSurfaces"); > > + > > + // decide surface format here by derive an image (so > surface format is the default one, ie. YV12) > > + VAImage temp_image; > > + vaStatus = vaDeriveImage(va_dpy,new_surface,&temp_image); > > + vaDestroyImage(va_dpy,temp_image.image_id); > > + > > + > > + // render YUY2 image to YV12 surface, so YUY2->YV12 > conversion happens. > > + vaStatus = vaPutImage(va_dpy, new_surface, > image.image_id, > > + 0, 0, surface_width, > surface_height, > > + 0, 0, surface_width, > surface_height); > > + CHECK_VASTATUS(vaStatus,"vaPutImage"); > > + > > + // render the temp surface, it should be same with > original surface without color conversion test > > + vaStatus = vaPutSurface(va_dpy, new_surface, > CAST_DRAWABLE(drawable), > > + 0,0,surface_width,surface_height, > > + 0,0,width,height, > > + > (test_clip==0)?NULL:&cliprects[0], > > + (test_clip==0)?0:2, > > + display_field); > > + CHECK_VASTATUS(vaStatus,"vaPutSurface"); > > + > > + // destroy temp surface/image > > + vaStatus = vaDestroySurfaces(va_dpy, &new_surface, 1); > > + CHECK_VASTATUS(vaStatus,"vaDestroySurfaces"); > > + > > + vaStatus = vaDestroyImage(va_dpy, image.image_id); > > + CHECK_VASTATUS(vaStatus,"vaDestroyImage"); > > + } > > + else { > > + vaStatus = vaPutSurface(va_dpy, surface_id, > CAST_DRAWABLE(drawable), > > + 0,0,surface_width,surface_height, > > + 0,0,width,height, > > + > (test_clip==0)?NULL:&cliprects[0], > > + (test_clip==0)?0:2, > > + display_field); > > + CHECK_VASTATUS(vaStatus,"vaPutSurface"); > > + } > > + > > putsurface_time += (get_tick_count() - start_time); > > > > if (check_event) > > @@ -258,7 +316,7 @@ int main(int argc,char **argv) > > char c; > > int i; > > > > - while ((c =getopt(argc,argv,"w:h:g:r:d:f:tcep?n:v") ) != EOF) { > > + while ((c =getopt(argc,argv,"w:h:g:r:d:f:tcep?nx:v") ) != EOF) { > > switch (c) { > > case '?': > > printf("putsurface <options>\n"); @@ -269,6 +327,7 > @@ > > int main(int argc,char **argv) > > printf(" -t multi-threads\n"); > > printf(" -c test clipbox\n"); > > printf(" -f <1/2> top field, or bottom > field\n"); > > + printf(" -x test color > conversion(NV12/YV12 --> YUY2 --> NV12/YV12) \n"); > > printf(" -v verbose output\n"); > > exit(0); > > break; > > @@ -319,6 +378,10 @@ int main(int argc,char **argv) > > } else > > printf("The validate input for -f is: 1(top > field)/2(bottom field)\n"); > > break; > > + case 'x': > > + test_color_conversion = atoi(optarg); > > + printf("do additional NV12/YV12 <--> YUY2 conversion > for test\n"); > > + break; > > case 'v': > > verbose = 1; > > printf("Enable verbose output\n"); @@ -346,6 +409,20 > > @@ int main(int argc,char **argv) > > CHECK_VASTATUS(va_status, "vaCreateSurfaces"); > > if (multi_thread == 0) /* upload the content for all surfaces */ > > upload_source_YUV_once_for_all(); > > + > > + if (test_color_conversion) { > > + #define MAX_IMAGE_FORMAT_COUNT 10 > > + VAImageFormat format_list[MAX_IMAGE_FORMAT_COUNT]; > > + int num_formats = 0, find_yuy2 = 0; > > + > > + va_status = vaQueryImageFormats(va_dpy, > format_list,&num_formats); > > + for (i=0; i<num_formats; i++) { > > + if (format_list[i].fourcc == VA_FOURCC_YUY2) { > > + find_yuy2 = 1; > > + } > > + } > > + if (!find_yuy2) test_color_conversion = 0; > > + } > > > > if (check_event) > > pthread_mutex_init(&gmutex, NULL); > _______________________________________________ Libva mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libva
