Mercurial > mplayer.hg
comparison libvo/vo_xvmc.c @ 28643:fcc8d7b273d4
Cosmetics part2. Indent local variable definitions like the rest of the code.
Checked for equality by diff -wB .
author | iive |
---|---|
date | Fri, 20 Feb 2009 22:49:09 +0000 |
parents | fd68de39e9f6 |
children | 751e41eacda9 |
comparison
equal
deleted
inserted
replaced
28642:fd68de39e9f6 | 28643:fcc8d7b273d4 |
---|---|
223 return -1;//fail | 223 return -1;//fail |
224 } | 224 } |
225 | 225 |
226 //print all info needed to add new format | 226 //print all info needed to add new format |
227 static void print_xvimage_format_values(XvImageFormatValues *xifv){ | 227 static void print_xvimage_format_values(XvImageFormatValues *xifv){ |
228 int i; | 228 int i; |
229 | |
229 printf("Format_ID = 0x%X\n",xifv->id); | 230 printf("Format_ID = 0x%X\n",xifv->id); |
230 | 231 |
231 printf(" type = "); | 232 printf(" type = "); |
232 if(xifv->type == XvRGB) printf("RGB\n"); | 233 if(xifv->type == XvRGB) printf("RGB\n"); |
233 else if(xifv->type == XvYUV) printf("YUV\n"); | 234 else if(xifv->type == XvYUV) printf("YUV\n"); |
280 } | 281 } |
281 | 282 |
282 // WARNING This function may changes xv_port and surface_info! | 283 // WARNING This function may changes xv_port and surface_info! |
283 static int xvmc_find_surface_by_format(int format,int width,int height, | 284 static int xvmc_find_surface_by_format(int format,int width,int height, |
284 XvMCSurfaceInfo * surf_info,int query){ | 285 XvMCSurfaceInfo * surf_info,int query){ |
285 int rez; | 286 int rez; |
286 XvAdaptorInfo * ai; | 287 XvAdaptorInfo * ai; |
287 int num_adaptors,i; | 288 int num_adaptors,i; |
288 unsigned long p; | 289 unsigned long p; |
289 int s,mc_surf_num; | 290 int s,mc_surf_num; |
290 XvMCSurfaceInfo * mc_surf_list; | 291 XvMCSurfaceInfo * mc_surf_list; |
291 | 292 |
292 rez = XvQueryAdaptors(mDisplay,DefaultRootWindow(mDisplay),&num_adaptors,&ai); | 293 rez = XvQueryAdaptors(mDisplay,DefaultRootWindow(mDisplay),&num_adaptors,&ai); |
293 if( rez != Success ) return -1; | 294 if( rez != Success ) return -1; |
294 if( mp_msg_test(MSGT_VO,MSGL_DBG3) ) { | 295 if( mp_msg_test(MSGT_VO,MSGL_DBG3) ) { |
295 printf("vo_xvmc: Querying %d adaptors\n",num_adaptors); } | 296 printf("vo_xvmc: Querying %d adaptors\n",num_adaptors); } |
377 top_field_first = mpi->fields & MP_IMGFIELD_TOP_FIRST; | 378 top_field_first = mpi->fields & MP_IMGFIELD_TOP_FIRST; |
378 return VO_TRUE; | 379 return VO_TRUE; |
379 } | 380 } |
380 | 381 |
381 static int preinit(const char *arg){ | 382 static int preinit(const char *arg){ |
382 int xv_version,xv_release,xv_request_base,xv_event_base,xv_error_base; | 383 int xv_version,xv_release,xv_request_base,xv_event_base,xv_error_base; |
383 int mc_eventBase,mc_errorBase; | 384 int mc_eventBase,mc_errorBase; |
384 int mc_ver,mc_rev; | 385 int mc_ver,mc_rev; |
385 strarg_t ck_src_arg = { 0, NULL }; | 386 strarg_t ck_src_arg = { 0, NULL }; |
386 strarg_t ck_method_arg = { 0, NULL }; | 387 strarg_t ck_method_arg = { 0, NULL }; |
387 opt_t subopts [] = | 388 opt_t subopts [] = |
388 { | 389 { |
389 /* name arg type arg var test */ | 390 /* name arg type arg var test */ |
390 { "port", OPT_ARG_INT, &xv_port_request, (opt_test_f)int_pos }, | 391 { "port", OPT_ARG_INT, &xv_port_request, (opt_test_f)int_pos }, |
391 { "adaptor", OPT_ARG_INT, &xv_adaptor, (opt_test_f)int_non_neg }, | 392 { "adaptor", OPT_ARG_INT, &xv_adaptor, (opt_test_f)int_non_neg }, |
392 { "ck", OPT_ARG_STR, &ck_src_arg, xv_test_ck }, | 393 { "ck", OPT_ARG_STR, &ck_src_arg, xv_test_ck }, |
393 { "ck-method", OPT_ARG_STR, &ck_method_arg, xv_test_ckm }, | 394 { "ck-method", OPT_ARG_STR, &ck_method_arg, xv_test_ckm }, |
394 { "benchmark", OPT_ARG_BOOL, &benchmark, NULL }, | 395 { "benchmark", OPT_ARG_BOOL, &benchmark, NULL }, |
395 { "sleep", OPT_ARG_BOOL, &use_sleep, NULL }, | 396 { "sleep", OPT_ARG_BOOL, &use_sleep, NULL }, |
396 { "queue", OPT_ARG_BOOL, &use_queue, NULL }, | 397 { "queue", OPT_ARG_BOOL, &use_queue, NULL }, |
397 { "bobdeint", OPT_ARG_BOOL, &bob_deinterlace, NULL }, | 398 { "bobdeint", OPT_ARG_BOOL, &bob_deinterlace, NULL }, |
398 { NULL } | 399 { NULL } |
399 }; | 400 }; |
400 | 401 |
401 //Obtain display handler | 402 //Obtain display handler |
402 if (!vo_init()) return -1;//vo_xv | 403 if (!vo_init()) return -1;//vo_xv |
403 | 404 |
404 //XvMC is subdivision of XVideo | 405 //XvMC is subdivision of XVideo |
446 } | 447 } |
447 | 448 |
448 static int config(uint32_t width, uint32_t height, | 449 static int config(uint32_t width, uint32_t height, |
449 uint32_t d_width, uint32_t d_height, | 450 uint32_t d_width, uint32_t d_height, |
450 uint32_t flags, char *title, uint32_t format){ | 451 uint32_t flags, char *title, uint32_t format){ |
451 int i,mode_id,rez; | 452 int i,mode_id,rez; |
452 int numblocks,blocks_per_macroblock;//bpmb we have 6,8,12 | 453 int numblocks,blocks_per_macroblock;//bpmb we have 6,8,12 |
453 | 454 |
454 //from vo_xv | 455 //from vo_xv |
455 XVisualInfo vinfo; | 456 XVisualInfo vinfo; |
456 XSetWindowAttributes xswa; | 457 XSetWindowAttributes xswa; |
457 XWindowAttributes attribs; | 458 XWindowAttributes attribs; |
458 unsigned long xswamask; | 459 unsigned long xswamask; |
459 int depth; | 460 int depth; |
460 #ifdef CONFIG_XF86VM | 461 #ifdef CONFIG_XF86VM |
461 int vm = flags & VOFLAG_MODESWITCHING; | 462 int vm = flags & VOFLAG_MODESWITCHING; |
462 #endif | 463 #endif |
463 //end of vo_xv | 464 //end of vo_xv |
464 | 465 |
465 if( !IMGFMT_IS_XVMC(format) ) | 466 if( !IMGFMT_IS_XVMC(format) ) |
466 { | 467 { |
725 free(palette); | 726 free(palette); |
726 } | 727 } |
727 } | 728 } |
728 | 729 |
729 static void clear_osd_subpic(int x0, int y0, int w, int h){ | 730 static void clear_osd_subpic(int x0, int y0, int w, int h){ |
730 int rez; | 731 int rez; |
732 | |
731 rez=XvMCClearSubpicture(mDisplay, &subpicture, | 733 rez=XvMCClearSubpicture(mDisplay, &subpicture, |
732 x0, y0, w,h, | 734 x0, y0, w,h, |
733 subpicture_clear_color); | 735 subpicture_clear_color); |
734 if(rez != Success) | 736 if(rez != Success) |
735 printf("vo_xvmc: XvMCClearSubpicture failed!\n"); | 737 printf("vo_xvmc: XvMCClearSubpicture failed!\n"); |
736 } | 738 } |
737 | 739 |
738 static void OSD_init(void) { | 740 static void OSD_init(void) { |
739 unsigned short osd_height, osd_width; | 741 unsigned short osd_height, osd_width; |
740 int rez; | 742 int rez; |
741 | 743 |
742 if(subpicture_alloc){ | 744 if(subpicture_alloc){ |
743 if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) | 745 if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) |
744 printf("vo_xvmc: destroying subpicture\n"); | 746 printf("vo_xvmc: destroying subpicture\n"); |
745 XvMCDestroySubpicture(mDisplay,&subpicture); | 747 XvMCDestroySubpicture(mDisplay,&subpicture); |
799 allocate_xvimage(subpicture.width, subpicture.height, subpicture_info.id); | 801 allocate_xvimage(subpicture.width, subpicture.height, subpicture_info.id); |
800 subpicture_alloc = 1; | 802 subpicture_alloc = 1; |
801 } | 803 } |
802 | 804 |
803 static void draw_osd_IA44(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ | 805 static void draw_osd_IA44(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ |
804 int ox,oy; | 806 int ox,oy; |
805 int rez; | 807 int rez; |
806 | 808 |
807 if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) | 809 if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) |
808 printf("vo_xvmc:composite AI44 subpicture (%d,%d - %d,%d)\n",x0,y0,w,h); | 810 printf("vo_xvmc:composite AI44 subpicture (%d,%d - %d,%d)\n",x0,y0,w,h); |
809 | 811 |
810 for(ox=0; ox<w; ox++){ | 812 for(ox=0; ox<w; ox++){ |
819 assert(0); | 821 assert(0); |
820 } | 822 } |
821 } | 823 } |
822 | 824 |
823 static void draw_osd_AI44(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ | 825 static void draw_osd_AI44(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ |
824 int ox,oy; | 826 int ox,oy; |
825 int rez; | 827 int rez; |
828 | |
826 if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) | 829 if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) |
827 printf("vo_xvmc:composite AI44 subpicture (%d,%d - %d,%d)\n",x0,y0,w,h); | 830 printf("vo_xvmc:composite AI44 subpicture (%d,%d - %d,%d)\n",x0,y0,w,h); |
828 | 831 |
829 for(ox=0; ox<w; ox++){ | 832 for(ox=0; ox<w; ox++){ |
830 for(oy=0; oy<h; oy++){ | 833 for(oy=0; oy<h; oy++){ |
838 assert(0); | 841 assert(0); |
839 } | 842 } |
840 } | 843 } |
841 | 844 |
842 static void draw_osd(void){ | 845 static void draw_osd(void){ |
843 struct xvmc_pix_fmt *osd_rndr; | 846 struct xvmc_pix_fmt *osd_rndr; |
844 int osd_has_changed; | 847 int osd_has_changed; |
845 int have_osd_to_draw; | 848 int have_osd_to_draw; |
846 int rez; | 849 int rez; |
847 | 850 |
848 if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) | 851 if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) |
849 printf("vo_xvmc: draw_osd ,OSD_mode=%d, surface_to_show=%p\n", | 852 printf("vo_xvmc: draw_osd ,OSD_mode=%d, surface_to_show=%p\n", |
850 subpicture_mode,p_render_surface_to_show); | 853 subpicture_mode,p_render_surface_to_show); |
851 | 854 |
913 | 916 |
914 }//if(BLEND||BACKEND) | 917 }//if(BLEND||BACKEND) |
915 } | 918 } |
916 | 919 |
917 static void xvmc_sync_surface(XvMCSurface * srf){ | 920 static void xvmc_sync_surface(XvMCSurface * srf){ |
918 int status,rez; | 921 int status,rez; |
922 | |
919 rez = XvMCGetSurfaceStatus(mDisplay,srf,&status); | 923 rez = XvMCGetSurfaceStatus(mDisplay,srf,&status); |
920 assert(rez==Success); | 924 assert(rez==Success); |
921 if((status & XVMC_RENDERING) == 0) | 925 if((status & XVMC_RENDERING) == 0) |
922 return;//surface is already complete | 926 return;//surface is already complete |
923 if(use_sleep){ | 927 if(use_sleep){ |
934 XvMCSyncSurface(mDisplay, srf); | 938 XvMCSyncSurface(mDisplay, srf); |
935 } | 939 } |
936 | 940 |
937 static void put_xvmc_image(struct xvmc_pix_fmt *p_render_surface, | 941 static void put_xvmc_image(struct xvmc_pix_fmt *p_render_surface, |
938 int draw_ck){ | 942 int draw_ck){ |
939 int rez; | 943 int rez; |
940 struct vo_rect src_rect, dst_rect; | 944 struct vo_rect src_rect, dst_rect; |
941 int i; | 945 int i; |
942 | 946 |
943 if(p_render_surface == NULL) | 947 if(p_render_surface == NULL) |
944 return; | 948 return; |
945 | 949 |
946 calc_src_dst_rects(image_width, image_height, &src_rect, &dst_rect, NULL, NULL); | 950 calc_src_dst_rects(image_width, image_height, &src_rect, &dst_rect, NULL, NULL); |
965 } | 969 } |
966 XFlush(mDisplay); | 970 XFlush(mDisplay); |
967 } | 971 } |
968 | 972 |
969 static void flip_page(void){ | 973 static void flip_page(void){ |
970 int i,cfs; | 974 int i,cfs; |
971 | |
972 | 975 |
973 if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) | 976 if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) |
974 printf("vo_xvmc: flip_page show(rndr=%p)\n\n",p_render_surface_to_show); | 977 printf("vo_xvmc: flip_page show(rndr=%p)\n\n",p_render_surface_to_show); |
975 | 978 |
976 if(p_render_surface_to_show == NULL) return; | 979 if(p_render_surface_to_show == NULL) return; |
1013 p_render_surface_visible = p_render_surface_to_show; | 1016 p_render_surface_visible = p_render_surface_to_show; |
1014 p_render_surface_to_show = NULL; | 1017 p_render_surface_to_show = NULL; |
1015 } | 1018 } |
1016 | 1019 |
1017 static void check_events(void){ | 1020 static void check_events(void){ |
1018 int e=vo_x11_check_events(mDisplay); | 1021 int e=vo_x11_check_events(mDisplay); |
1022 | |
1019 if(e&VO_EVENT_RESIZE) | 1023 if(e&VO_EVENT_RESIZE) |
1020 { | 1024 { |
1021 e |= VO_EVENT_EXPOSE; | 1025 e |= VO_EVENT_EXPOSE; |
1022 } | 1026 } |
1023 if ( e & VO_EVENT_EXPOSE ) | 1027 if ( e & VO_EVENT_EXPOSE ) |
1025 put_xvmc_image(p_render_surface_visible,1); | 1029 put_xvmc_image(p_render_surface_visible,1); |
1026 } | 1030 } |
1027 } | 1031 } |
1028 | 1032 |
1029 static void xvmc_free(void){ | 1033 static void xvmc_free(void){ |
1030 int i; | 1034 int i; |
1035 | |
1031 if( subpicture_alloc ){ | 1036 if( subpicture_alloc ){ |
1032 | 1037 |
1033 XvMCDestroySubpicture(mDisplay,&subpicture); | 1038 XvMCDestroySubpicture(mDisplay,&subpicture); |
1034 deallocate_xvimage(); | 1039 deallocate_xvimage(); |
1035 | 1040 |
1084 #endif | 1089 #endif |
1085 vo_x11_uninit(); | 1090 vo_x11_uninit(); |
1086 } | 1091 } |
1087 | 1092 |
1088 static int query_format(uint32_t format){ | 1093 static int query_format(uint32_t format){ |
1089 uint32_t flags; | 1094 uint32_t flags; |
1090 XvMCSurfaceInfo qsurface_info; | 1095 XvMCSurfaceInfo qsurface_info; |
1091 int mode_id; | 1096 int mode_id; |
1092 | 1097 |
1093 if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) | 1098 if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) |
1094 printf("vo_xvmc: query_format=%X\n",format); | 1099 printf("vo_xvmc: query_format=%X\n",format); |
1095 | 1100 |
1096 if(!IMGFMT_IS_XVMC(format)) return 0;// no caps supported | 1101 if(!IMGFMT_IS_XVMC(format)) return 0;// no caps supported |
1109 } | 1114 } |
1110 | 1115 |
1111 | 1116 |
1112 static int draw_slice(uint8_t *image[], int stride[], | 1117 static int draw_slice(uint8_t *image[], int stride[], |
1113 int w, int h, int x, int y){ | 1118 int w, int h, int x, int y){ |
1114 struct xvmc_pix_fmt *rndr; | 1119 struct xvmc_pix_fmt *rndr; |
1115 int rez; | 1120 int rez; |
1116 | 1121 |
1117 if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) | 1122 if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) |
1118 printf("vo_xvmc: draw_slice y=%d\n",y); | 1123 printf("vo_xvmc: draw_slice y=%d\n",y); |
1119 | 1124 |
1120 rndr = (struct xvmc_pix_fmt*)image[2]; //this is copy of priv-ate | 1125 rndr = (struct xvmc_pix_fmt*)image[2]; //this is copy of priv-ate |
1170 } | 1175 } |
1171 | 1176 |
1172 //XvMCHide hides the surface on next retrace, so | 1177 //XvMCHide hides the surface on next retrace, so |
1173 //check if the surface is not still displaying | 1178 //check if the surface is not still displaying |
1174 static void check_osd_source(struct xvmc_pix_fmt *src_rndr) { | 1179 static void check_osd_source(struct xvmc_pix_fmt *src_rndr) { |
1175 struct xvmc_pix_fmt *osd_rndr; | 1180 struct xvmc_pix_fmt *osd_rndr; |
1176 int stat; | 1181 int stat; |
1182 | |
1177 //If this is source surface, check does the OSD rendering is compleate | 1183 //If this is source surface, check does the OSD rendering is compleate |
1178 if(src_rndr->state & AV_XVMC_STATE_OSD_SOURCE){ | 1184 if(src_rndr->state & AV_XVMC_STATE_OSD_SOURCE){ |
1179 if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) | 1185 if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) |
1180 printf("vo_xvmc: OSD surface=%p quering\n",src_rndr); | 1186 printf("vo_xvmc: OSD surface=%p quering\n",src_rndr); |
1181 osd_rndr = src_rndr->p_osd_target_surface_render; | 1187 osd_rndr = src_rndr->p_osd_target_surface_render; |
1183 if(!(stat & XVMC_RENDERING)) | 1189 if(!(stat & XVMC_RENDERING)) |
1184 src_rndr->state &= ~AV_XVMC_STATE_OSD_SOURCE; | 1190 src_rndr->state &= ~AV_XVMC_STATE_OSD_SOURCE; |
1185 } | 1191 } |
1186 } | 1192 } |
1187 static int count_free_surfaces(void) { | 1193 static int count_free_surfaces(void) { |
1188 int i,num; | 1194 int i,num; |
1195 | |
1189 num=0; | 1196 num=0; |
1190 for(i=0; i<number_of_surfaces; i++){ | 1197 for(i=0; i<number_of_surfaces; i++){ |
1191 check_osd_source(&surface_render[i]); | 1198 check_osd_source(&surface_render[i]); |
1192 if(surface_render[i].state == 0) | 1199 if(surface_render[i].state == 0) |
1193 num++; | 1200 num++; |
1194 } | 1201 } |
1195 return num; | 1202 return num; |
1196 } | 1203 } |
1197 | 1204 |
1198 static struct xvmc_pix_fmt *find_free_surface(void) { | 1205 static struct xvmc_pix_fmt *find_free_surface(void) { |
1199 int i,t; | 1206 int i,t; |
1200 int stat; | 1207 int stat; |
1201 struct xvmc_pix_fmt *visible_rndr; | 1208 struct xvmc_pix_fmt *visible_rndr; |
1202 | 1209 |
1203 visible_rndr = NULL; | 1210 visible_rndr = NULL; |
1204 for(i=0; i<number_of_surfaces; i++){ | 1211 for(i=0; i<number_of_surfaces; i++){ |
1205 | 1212 |
1206 check_osd_source(&surface_render[i]); | 1213 check_osd_source(&surface_render[i]); |
1229 printf("vo_xvmc: surface[%d].state=%d\n",i,surface_render[i].state); | 1236 printf("vo_xvmc: surface[%d].state=%d\n",i,surface_render[i].state); |
1230 return NULL; | 1237 return NULL; |
1231 } | 1238 } |
1232 | 1239 |
1233 static void xvmc_clean_surfaces(void){ | 1240 static void xvmc_clean_surfaces(void){ |
1234 int i; | 1241 int i; |
1235 | 1242 |
1236 for(i=0; i<number_of_surfaces; i++){ | 1243 for(i=0; i<number_of_surfaces; i++){ |
1237 | 1244 |
1238 surface_render[i].state&=!( AV_XVMC_STATE_DISPLAY_PENDING | | 1245 surface_render[i].state&=!( AV_XVMC_STATE_DISPLAY_PENDING | |
1239 AV_XVMC_STATE_OSD_SOURCE | | 1246 AV_XVMC_STATE_OSD_SOURCE | |
1352 } | 1359 } |
1353 case VOCTRL_UPDATE_SCREENINFO: | 1360 case VOCTRL_UPDATE_SCREENINFO: |
1354 update_xinerama_info(); | 1361 update_xinerama_info(); |
1355 return VO_TRUE; | 1362 return VO_TRUE; |
1356 } | 1363 } |
1357 return VO_NOTIMPL; | 1364 return VO_NOTIMPL; |
1358 } | 1365 } |