hardware/intel/libva
修订版 | dc4441592451ad3d3cfd4a343459ca25dbb634a4 (tree) |
---|---|
时间 | 2016-07-26 19:50:10 |
作者 | Jaap Jan Meijer <jjmeijer88@gmai...> |
Commiter | Jaap Jan Meijer |
Android: fix Android build
@@ -10,7 +10,7 @@ LOCAL_SRC_FILES := \ | ||
10 | 10 | #putsurface_x11.c |
11 | 11 | |
12 | 12 | LOCAL_CFLAGS += \ |
13 | - -DANDROID | |
13 | + -DANDROID -Wno-unused-parameter | |
14 | 14 | |
15 | 15 | LOCAL_C_INCLUDES += \ |
16 | 16 | $(TARGET_OUT_HEADERS)/libva |
@@ -22,7 +22,7 @@ | ||
22 | 22 | |
23 | 23 | bin_PROGRAMS = putsurface |
24 | 24 | |
25 | -AM_CPPFLAGS = \ | |
25 | +INCLUDES = \ | |
26 | 26 | -I$(top_srcdir) \ |
27 | 27 | -I$(top_builddir) \ |
28 | 28 | $(NULL) |
@@ -47,7 +47,7 @@ static void close_display(void *win_display); | ||
47 | 47 | static int create_window(void *win_display, int x, int y, int width, int height); |
48 | 48 | static int check_window_event(void *x11_display, void *win, int *width, int *height, int *quit); |
49 | 49 | |
50 | -#define CAST_DRAWABLE(a) static_cast<ANativeWindow *>((void *)(*(unsigned int *)a)) | |
50 | +#define CAST_DRAWABLE(a) static_cast<ANativeWindow *>((void *)(*(unsigned long *)a)) | |
51 | 51 | #include "putsurface_common.c" |
52 | 52 | |
53 | 53 | static void *open_display() |
@@ -8,11 +8,11 @@ | ||
8 | 8 | * distribute, sub license, and/or sell copies of the Software, and to |
9 | 9 | * permit persons to whom the Software is furnished to do so, subject to |
10 | 10 | * the following conditions: |
11 | - * | |
11 | + * | |
12 | 12 | * The above copyright notice and this permission notice (including the |
13 | 13 | * next paragraph) shall be included in all copies or substantial portions |
14 | 14 | * of the Software. |
15 | - * | |
15 | + * | |
16 | 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
17 | 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
18 | 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. |
@@ -83,13 +83,13 @@ static int box_width = 32; | ||
83 | 83 | static int multi_thread = 0; |
84 | 84 | static int verbose = 0; |
85 | 85 | static int test_color_conversion = 0; |
86 | -static int csc_src_fourcc = 0, csc_dst_fourcc = 0; | |
86 | +static unsigned int csc_src_fourcc = 0, csc_dst_fourcc = 0; | |
87 | 87 | static VAImage csc_dst_fourcc_image; |
88 | 88 | static VASurfaceID csc_render_surface; |
89 | 89 | |
90 | 90 | |
91 | 91 | typedef struct { |
92 | - char* fmt_str; | |
92 | + const char * fmt_str; | |
93 | 93 | unsigned int fourcc; |
94 | 94 | } fourcc_map; |
95 | 95 | fourcc_map va_fourcc_map[] = { |
@@ -104,7 +104,7 @@ fourcc_map va_fourcc_map[] = { | ||
104 | 104 | }; |
105 | 105 | unsigned int map_str_to_vafourcc (char * str) |
106 | 106 | { |
107 | - int i; | |
107 | + unsigned int i; | |
108 | 108 | for (i=0; i< sizeof(va_fourcc_map)/sizeof(fourcc_map); i++) { |
109 | 109 | if (!strcmp(va_fourcc_map[i].fmt_str, str)) { |
110 | 110 | return va_fourcc_map[i].fourcc; |
@@ -114,10 +114,10 @@ unsigned int map_str_to_vafourcc (char * str) | ||
114 | 114 | return 0; |
115 | 115 | |
116 | 116 | } |
117 | -char* map_vafourcc_to_str (unsigned int format) | |
117 | +const char* map_vafourcc_to_str (unsigned int format) | |
118 | 118 | { |
119 | 119 | static char unknown_format[] = "unknown-format"; |
120 | - int i; | |
120 | + unsigned int i; | |
121 | 121 | for (i=0; i< sizeof(va_fourcc_map)/sizeof(fourcc_map); i++) { |
122 | 122 | if (va_fourcc_map[i].fourcc == format) { |
123 | 123 | return va_fourcc_map[i].fmt_str; |
@@ -161,7 +161,7 @@ ensure_image_formats(void) | ||
161 | 161 | if (num_image_formats == 0) |
162 | 162 | return 0; |
163 | 163 | |
164 | - image_formats = malloc(num_image_formats * sizeof(*image_formats)); | |
164 | + image_formats = (VAImageFormat *) malloc(num_image_formats * sizeof(*image_formats)); | |
165 | 165 | if (!image_formats) |
166 | 166 | return 0; |
167 | 167 |
@@ -210,7 +210,7 @@ ensure_surface_attribs(void) | ||
210 | 210 | /* Guess the number of surface attributes, thus including any |
211 | 211 | pixel-format supported by the VA driver */ |
212 | 212 | num_surface_attribs = VASurfaceAttribCount + num_image_formats; |
213 | - surface_attribs = malloc(num_surface_attribs * sizeof(*surface_attribs)); | |
213 | + surface_attribs = (VASurfaceAttrib *) malloc(num_surface_attribs * sizeof(*surface_attribs)); | |
214 | 214 | if (!surface_attribs) |
215 | 215 | return 0; |
216 | 216 |
@@ -219,7 +219,7 @@ ensure_surface_attribs(void) | ||
219 | 219 | if (va_status == VA_STATUS_SUCCESS) |
220 | 220 | va_surface_attribs = surface_attribs; |
221 | 221 | else if (va_status == VA_STATUS_ERROR_MAX_NUM_EXCEEDED) { |
222 | - va_surface_attribs = realloc(surface_attribs, | |
222 | + va_surface_attribs = (VASurfaceAttrib *) realloc(surface_attribs, | |
223 | 223 | num_surface_attribs * sizeof(*va_surface_attribs)); |
224 | 224 | if (!va_surface_attribs) { |
225 | 225 | free(surface_attribs); |
@@ -256,7 +256,8 @@ lookup_surface_attrib(VASurfaceAttribType type, const VAGenericValue *value) | ||
256 | 256 | int csc_preparation () |
257 | 257 | { |
258 | 258 | VAStatus va_status; |
259 | - | |
259 | + VASurfaceAttrib surface_attribs[1], * const s_attrib = &surface_attribs[0]; | |
260 | + | |
260 | 261 | // 1. make sure dst fourcc is supported for vaImage |
261 | 262 | if (!lookup_image_format(csc_dst_fourcc)) { |
262 | 263 | test_color_conversion = 0; |
@@ -265,7 +266,6 @@ int csc_preparation () | ||
265 | 266 | } |
266 | 267 | |
267 | 268 | // 2. make sure src_fourcc is supported for vaSurface |
268 | - VASurfaceAttrib surface_attribs[1], * const s_attrib = &surface_attribs[0]; | |
269 | 269 | s_attrib->type = VASurfaceAttribPixelFormat; |
270 | 270 | s_attrib->flags = VA_SURFACE_ATTRIB_SETTABLE; |
271 | 271 | s_attrib->value.type = VAGenericValueTypeInteger; |
@@ -292,18 +292,18 @@ int csc_preparation () | ||
292 | 292 | image_format.fourcc = csc_dst_fourcc; |
293 | 293 | image_format.byte_order = VA_LSB_FIRST; |
294 | 294 | image_format.bits_per_pixel = 16; |
295 | - | |
295 | + | |
296 | 296 | va_status = vaCreateImage(va_dpy, &image_format, |
297 | 297 | surface_width, surface_height, |
298 | 298 | &csc_dst_fourcc_image); |
299 | 299 | CHECK_VASTATUS(va_status,"vaCreateImage"); |
300 | - | |
300 | + | |
301 | 301 | |
302 | 302 | // 3.3 create a temp VASurface for final rendering(vaPutSurface) |
303 | 303 | s_attrib->value.value.i = VA_FOURCC_NV12; |
304 | - va_status = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420, | |
304 | + va_status = vaCreateSurfaces(va_dpy, VA_RT_FORMAT_YUV420, | |
305 | 305 | surface_width, surface_height, |
306 | - &csc_render_surface, 1, | |
306 | + &csc_render_surface, 1, | |
307 | 307 | surface_attribs, 1); |
308 | 308 | CHECK_VASTATUS(va_status,"vaCreateSurfaces"); |
309 | 309 |
@@ -328,7 +328,7 @@ static VASurfaceID get_next_free_surface(int *index) | ||
328 | 328 | |
329 | 329 | return surface_id[i]; |
330 | 330 | } |
331 | - | |
331 | + | |
332 | 332 | for (i=0; i<SURFACE_NUM; i++) { |
333 | 333 | surface_status = (VASurfaceStatus)0; |
334 | 334 | vaQuerySurfaceStatus(va_dpy, surface_id[i], &surface_status); |
@@ -356,11 +356,11 @@ static int upload_source_YUV_once_for_all() | ||
356 | 356 | int box_width_loc=8; |
357 | 357 | int row_shift_loc=0; |
358 | 358 | int i; |
359 | - | |
359 | + | |
360 | 360 | for (i=0; i<SURFACE_NUM; i++) { |
361 | 361 | printf("\rLoading data into surface %d.....", i); |
362 | 362 | upload_surface(va_dpy, surface_id[i], box_width_loc, row_shift_loc, 0); |
363 | - | |
363 | + | |
364 | 364 | row_shift_loc++; |
365 | 365 | if (row_shift_loc==(2*box_width_loc)) row_shift_loc= 0; |
366 | 366 | } |
@@ -384,9 +384,9 @@ static void update_clipbox(VARectangle *cliprects, int width, int height) | ||
384 | 384 | { |
385 | 385 | if (test_clip == 0) |
386 | 386 | return; |
387 | - | |
387 | + | |
388 | 388 | srand((unsigned)time(NULL)); |
389 | - | |
389 | + | |
390 | 390 | cliprects[0].x = (rand() % width); |
391 | 391 | cliprects[0].y = (rand() % height); |
392 | 392 | cliprects[0].width = (rand() % (width - cliprects[0].x)); |
@@ -412,16 +412,16 @@ static void* putsurface_thread(void *data) | ||
412 | 412 | unsigned int frame_num=0, start_time, putsurface_time; |
413 | 413 | VARectangle cliprects[2]; /* client supplied clip list */ |
414 | 414 | int continue_display = 0; |
415 | - | |
415 | + | |
416 | 416 | if (drawable == drawable_thread0) |
417 | 417 | printf("Enter into thread0\n\n"); |
418 | 418 | if (drawable == drawable_thread1) |
419 | 419 | printf("Enter into thread1\n\n"); |
420 | - | |
420 | + | |
421 | 421 | putsurface_time = 0; |
422 | 422 | while (!quit) { |
423 | 423 | VASurfaceID surface_id = VA_INVALID_SURFACE; |
424 | - | |
424 | + | |
425 | 425 | while (surface_id == VA_INVALID_SURFACE) |
426 | 426 | surface_id = get_next_free_surface(&index); |
427 | 427 |
@@ -432,9 +432,9 @@ static void* putsurface_thread(void *data) | ||
432 | 432 | |
433 | 433 | if (check_event) |
434 | 434 | pthread_mutex_lock(&gmutex); |
435 | - | |
435 | + | |
436 | 436 | start_time = get_tick_count(); |
437 | - if ((continue_display == 0) && getenv("FRAME_STOP")) { | |
437 | + if ((continue_display == 0) && getenv("FRAME_STOP")) { | |
438 | 438 | char c; |
439 | 439 | printf("Press any key to display frame %d...(c/C to continue)\n", frame_num); |
440 | 440 | c = getchar(); |
@@ -447,16 +447,16 @@ static void* putsurface_thread(void *data) | ||
447 | 447 | printf("do additional colorcoversion from %s to %s\n", map_vafourcc_to_str(csc_src_fourcc), map_vafourcc_to_str(csc_dst_fourcc)); |
448 | 448 | } |
449 | 449 | // get image from surface, csc_src_fourcc to csc_dst_fourcc conversion happens |
450 | - vaStatus = vaGetImage(va_dpy, surface_id, 0, 0, | |
450 | + vaStatus = vaGetImage(va_dpy, surface_id, 0, 0, | |
451 | 451 | surface_width, surface_height, csc_dst_fourcc_image.image_id); |
452 | 452 | CHECK_VASTATUS(vaStatus,"vaGetImage"); |
453 | - | |
453 | + | |
454 | 454 | // render csc_dst_fourcc image to temp surface |
455 | 455 | vaStatus = vaPutImage(va_dpy, csc_render_surface, csc_dst_fourcc_image.image_id, |
456 | - 0, 0, surface_width, surface_height, | |
456 | + 0, 0, surface_width, surface_height, | |
457 | 457 | 0, 0, surface_width, surface_height); |
458 | 458 | CHECK_VASTATUS(vaStatus,"vaPutImage"); |
459 | - | |
459 | + | |
460 | 460 | // render the temp surface, it should be same with original surface without color conversion test |
461 | 461 | vaStatus = vaPutSurface(va_dpy, csc_render_surface, CAST_DRAWABLE(drawable), |
462 | 462 | 0,0,surface_width,surface_height, |
@@ -465,7 +465,6 @@ static void* putsurface_thread(void *data) | ||
465 | 465 | (test_clip==0)?0:2, |
466 | 466 | display_field); |
467 | 467 | CHECK_VASTATUS(vaStatus,"vaPutSurface"); |
468 | - | |
469 | 468 | } |
470 | 469 | else { |
471 | 470 | vaStatus = vaPutSurface(va_dpy, surface_id, CAST_DRAWABLE(drawable), |
@@ -476,20 +475,20 @@ static void* putsurface_thread(void *data) | ||
476 | 475 | display_field); |
477 | 476 | CHECK_VASTATUS(vaStatus,"vaPutSurface"); |
478 | 477 | } |
479 | - | |
478 | + | |
480 | 479 | putsurface_time += (get_tick_count() - start_time); |
481 | - | |
480 | + | |
482 | 481 | if (check_event) |
483 | 482 | pthread_mutex_unlock(&gmutex); |
484 | - | |
483 | + | |
485 | 484 | pthread_mutex_unlock(&surface_mutex[index]); /* locked in get_next_free_surface */ |
486 | - | |
485 | + | |
487 | 486 | if ((frame_num % 0xff) == 0) { |
488 | 487 | fprintf(stderr, "%.2f FPS \r", 256000.0 / (float)putsurface_time); |
489 | 488 | putsurface_time = 0; |
490 | 489 | update_clipbox(cliprects, width, height); |
491 | 490 | } |
492 | - | |
491 | + | |
493 | 492 | if (check_event) |
494 | 493 | check_window_event(win_display, drawable, &width, &height, &quit); |
495 | 494 |
@@ -497,7 +496,7 @@ static void* putsurface_thread(void *data) | ||
497 | 496 | row_shift++; |
498 | 497 | if (row_shift==(2*box_width)) row_shift= 0; |
499 | 498 | } |
500 | - | |
499 | + | |
501 | 500 | if (frame_rate != 0) /* rough framerate control */ |
502 | 501 | usleep(1000/frame_rate*1000); |
503 | 502 |
@@ -505,10 +504,10 @@ static void* putsurface_thread(void *data) | ||
505 | 504 | if (frame_num >= frame_num_total) |
506 | 505 | quit = 1; |
507 | 506 | } |
508 | - | |
509 | - if (drawable == drawable_thread1) | |
507 | + | |
508 | + if (drawable == drawable_thread1) | |
510 | 509 | pthread_exit(NULL); |
511 | - | |
510 | + | |
512 | 511 | return 0; |
513 | 512 | } |
514 | 513 | int main(int argc,char **argv) |
@@ -596,8 +595,8 @@ int main(int argc,char **argv) | ||
596 | 595 | case '1': |
597 | 596 | sscanf(optarg, "%s", str_src_fmt); |
598 | 597 | csc_src_fourcc = map_str_to_vafourcc (str_src_fmt); |
599 | - | |
600 | - if (!csc_src_fourcc) { | |
598 | + | |
599 | + if (!csc_src_fourcc) { | |
601 | 600 | printf("invalid fmt1: %s\n", str_src_fmt ); |
602 | 601 | exit(0); |
603 | 602 | } |
@@ -605,8 +604,8 @@ int main(int argc,char **argv) | ||
605 | 604 | case '2': |
606 | 605 | sscanf(optarg, "%s", str_dst_fmt); |
607 | 606 | csc_dst_fourcc = map_str_to_vafourcc (str_dst_fmt); |
608 | - | |
609 | - if (!csc_dst_fourcc) { | |
607 | + | |
608 | + if (!csc_dst_fourcc) { | |
610 | 609 | printf("invalid fmt1: %s\n", str_dst_fmt ); |
611 | 610 | exit(0); |
612 | 611 | } |
@@ -621,7 +620,7 @@ int main(int argc,char **argv) | ||
621 | 620 | if (csc_src_fourcc && csc_dst_fourcc) { |
622 | 621 | test_color_conversion = 1; |
623 | 622 | } |
624 | - | |
623 | + | |
625 | 624 | win_display = (void *)open_display(); |
626 | 625 | if (win_display == NULL) { |
627 | 626 | fprintf(stderr, "Can't open the connection of display!\n"); |
@@ -643,23 +642,23 @@ int main(int argc,char **argv) | ||
643 | 642 | &surface_id[0], SURFACE_NUM, |
644 | 643 | NULL, 0 |
645 | 644 | ); |
646 | - } | |
645 | + } | |
647 | 646 | CHECK_VASTATUS(va_status, "vaCreateSurfaces"); |
648 | 647 | if (multi_thread == 0) /* upload the content for all surfaces */ |
649 | 648 | upload_source_YUV_once_for_all(); |
650 | - | |
649 | + | |
651 | 650 | if (check_event) |
652 | 651 | pthread_mutex_init(&gmutex, NULL); |
653 | - | |
652 | + | |
654 | 653 | for(i = 0; i< SURFACE_NUM; i++) |
655 | 654 | pthread_mutex_init(&surface_mutex[i], NULL); |
656 | - | |
657 | - if (multi_thread == 1) | |
655 | + | |
656 | + if (multi_thread == 1) | |
658 | 657 | ret = pthread_create(&thread1, NULL, putsurface_thread, (void*)drawable_thread1); |
659 | 658 | |
660 | 659 | putsurface_thread((void *)drawable_thread0); |
661 | 660 | |
662 | - if (multi_thread == 1) | |
661 | + if (multi_thread == 1) | |
663 | 662 | pthread_join(thread1, (void **)&ret); |
664 | 663 | printf("thread1 is free\n"); |
665 | 664 |
@@ -667,7 +666,7 @@ int main(int argc,char **argv) | ||
667 | 666 | // destroy temp surface/image |
668 | 667 | va_status = vaDestroySurfaces(va_dpy, &csc_render_surface, 1); |
669 | 668 | CHECK_VASTATUS(va_status,"vaDestroySurfaces"); |
670 | - | |
669 | + | |
671 | 670 | va_status = vaDestroyImage(va_dpy, csc_dst_fourcc_image.image_id); |
672 | 671 | CHECK_VASTATUS(va_status,"vaDestroyImage"); |
673 | 672 | } |
@@ -677,12 +676,12 @@ int main(int argc,char **argv) | ||
677 | 676 | vpp_config_id = VA_INVALID_ID; |
678 | 677 | } |
679 | 678 | |
680 | - vaDestroySurfaces(va_dpy,&surface_id[0],SURFACE_NUM); | |
679 | + vaDestroySurfaces(va_dpy,&surface_id[0],SURFACE_NUM); | |
681 | 680 | vaTerminate(va_dpy); |
682 | 681 | |
683 | 682 | free(va_image_formats); |
684 | 683 | free(va_surface_attribs); |
685 | 684 | close_display(win_display); |
686 | - | |
685 | + | |
687 | 686 | return 0; |
688 | 687 | } |
@@ -35,8 +35,8 @@ ALOG_VERSION := $(filter $(ALOG_VERSION_REQ),$(firstword $(sort $(PLATFORM_VERSI | ||
35 | 35 | |
36 | 36 | include $(CLEAR_VARS) |
37 | 37 | |
38 | -#LIBVA_MINOR_VERSION := 31 | |
39 | -#LIBVA_MAJOR_VERSION := 0 | |
38 | +#LIBVA_MINOR_VERSION := 39 | |
39 | +#LIBVA_MAJOR_VERSION := 1 | |
40 | 40 | |
41 | 41 | LOCAL_SRC_FILES := \ |
42 | 42 | va.c \ |
@@ -67,16 +67,21 @@ LOCAL_C_INCLUDES += \ | ||
67 | 67 | |
68 | 68 | LOCAL_COPY_HEADERS := \ |
69 | 69 | va.h \ |
70 | - va_backend.h \ | |
70 | + va_version.h \ | |
71 | 71 | va_dec_hevc.h \ |
72 | 72 | va_dec_jpeg.h \ |
73 | - va_drmcommon.h \ | |
73 | + va_dec_vp8.h \ | |
74 | + va_dec_vp9.h \ | |
75 | + va_enc_h264.h \ | |
74 | 76 | va_enc_hevc.h \ |
75 | 77 | va_enc_jpeg.h \ |
78 | + va_enc_mpeg2.h \ | |
76 | 79 | va_enc_vp8.h \ |
77 | 80 | va_enc_vp9.h \ |
78 | - va_dec_vp9.h \ | |
79 | - va_version.h | |
81 | + va_backend.h \ | |
82 | + va_drmcommon.h \ | |
83 | + va_vpp.h \ | |
84 | + va_backend_vpp.h \ | |
80 | 85 | |
81 | 86 | LOCAL_COPY_HEADERS_TO := libva/va |
82 | 87 |
@@ -194,7 +194,7 @@ extern "C" { | ||
194 | 194 | VAStatus vaPutSurface ( |
195 | 195 | VADisplay dpy, |
196 | 196 | VASurfaceID surface, |
197 | - sp<ISurface> draw, /* Android Surface/Window */ | |
197 | + sp<ANativeWindow> draw, /* Android Native Window */ | |
198 | 198 | short srcx, |
199 | 199 | short srcy, |
200 | 200 | unsigned short srcw, |
@@ -48,7 +48,8 @@ VADisplay vaGetDisplay ( | ||
48 | 48 | |
49 | 49 | #ifdef __cplusplus |
50 | 50 | #ifdef ANDROID |
51 | -#include <surfaceflinger/ISurface.h> | |
51 | +#include <system/window.h> | |
52 | +#include <utils/StrongPointer.h> | |
52 | 53 | using namespace android; |
53 | 54 | |
54 | 55 | /* |
@@ -61,8 +62,8 @@ using namespace android; | ||
61 | 62 | */ |
62 | 63 | VAStatus vaPutSurface ( |
63 | 64 | VADisplay dpy, |
64 | - VASurfaceID surface, | |
65 | - sp<ISurface> draw, /* Android Window/Surface */ | |
65 | + VASurfaceID surface, | |
66 | + sp<ANativeWindow> draw, /* Android Native Window */ | |
66 | 67 | short srcx, |
67 | 68 | short srcy, |
68 | 69 | unsigned short srcw, |