# HG changeset patch # User iive # Date 1235168011 0 # Node ID fd68de39e9f627b187a4af78245a523a0dadf098 # Parent 531d876a808ffc21d240bf8e51ec6e5709221e50 Cosmetics part 1. Reindent to 4 spaces. Checked for equality with diff -b. diff -r 531d876a808f -r fd68de39e9f6 libvo/vo_xvmc.c --- a/libvo/vo_xvmc.c Fri Feb 20 19:17:10 2009 +0000 +++ b/libvo/vo_xvmc.c Fri Feb 20 22:13:31 2009 +0000 @@ -119,15 +119,15 @@ static const struct{ - int id;//id as xvimages or as mplayer RGB|{8,15,16,24,32} - void (* init_func_ptr)(); - void (* draw_func_ptr)(); - void (* clear_func_ptr)(); - } osd_render[]={ - {0x34344149,init_osd_yuv_pal,draw_osd_AI44,clear_osd_subpic}, - {0x34344941,init_osd_yuv_pal,draw_osd_IA44,clear_osd_subpic}, - {0,NULL,NULL,NULL} - }; + int id;//id as xvimages or as mplayer RGB|{8,15,16,24,32} + void (* init_func_ptr)(); + void (* draw_func_ptr)(); + void (* clear_func_ptr)(); + } osd_render[]={ + {0x34344149,init_osd_yuv_pal,draw_osd_AI44,clear_osd_subpic}, + {0x34344941,init_osd_yuv_pal,draw_osd_IA44,clear_osd_subpic}, + {0,NULL,NULL,NULL} + }; static void xvmc_free(void); static void xvmc_clean_surfaces(void); @@ -135,10 +135,10 @@ static struct xvmc_pix_fmt *find_free_surface(void); static const vo_info_t info = { - "XVideo Motion Compensation", - "xvmc", - "Ivan Kalvachev ", - "" + "XVideo Motion Compensation", + "xvmc", + "Ivan Kalvachev ", + "" }; const LIBVO_EXTERN(xvmc); @@ -158,130 +158,130 @@ * mit-shm this will bomb... trzing to fix ::atmos */ #ifdef HAVE_SHM - if ( mLocalDisplay && XShmQueryExtension( mDisplay ) ) Shmem_Flag = 1; - else - { - Shmem_Flag = 0; - mp_msg(MSGT_VO,MSGL_INFO, "Shared memory not supported\nReverting to normal Xv\n" ); - } - if ( Shmem_Flag ) - { - xvimage = (XvImage *) XvShmCreateImage(mDisplay, xv_port, xv_format, + if ( mLocalDisplay && XShmQueryExtension( mDisplay ) ) Shmem_Flag = 1; + else + { + Shmem_Flag = 0; + mp_msg(MSGT_VO,MSGL_INFO, "Shared memory not supported\nReverting to normal Xv\n" ); + } + if ( Shmem_Flag ) + { + xvimage = (XvImage *) XvShmCreateImage(mDisplay, xv_port, xv_format, NULL, xvimage_width, xvimage_height, &Shminfo); - Shminfo.shmid = shmget(IPC_PRIVATE, xvimage->data_size, IPC_CREAT | 0777); - Shminfo.shmaddr = (char *) shmat(Shminfo.shmid, 0, 0); - Shminfo.readOnly = False; + Shminfo.shmid = shmget(IPC_PRIVATE, xvimage->data_size, IPC_CREAT | 0777); + Shminfo.shmaddr = (char *) shmat(Shminfo.shmid, 0, 0); + Shminfo.readOnly = False; - xvimage->data = Shminfo.shmaddr; - XShmAttach(mDisplay, &Shminfo); - XSync(mDisplay, False); - shmctl(Shminfo.shmid, IPC_RMID, 0); - } - else + xvimage->data = Shminfo.shmaddr; + XShmAttach(mDisplay, &Shminfo); + XSync(mDisplay, False); + shmctl(Shminfo.shmid, IPC_RMID, 0); + } + else #endif - { - xvimage = (XvImage *) XvCreateImage(mDisplay, xv_port, xv_format, NULL, xvimage_width, xvimage_height); - xvimage->data = malloc(xvimage->data_size); - XSync(mDisplay,False); - } + { + xvimage = (XvImage *) XvCreateImage(mDisplay, xv_port, xv_format, NULL, xvimage_width, xvimage_height); + xvimage->data = malloc(xvimage->data_size); + XSync(mDisplay,False); + } // memset(xvimage->data,128,xvimage->data_size); - return; + return; } static void deallocate_xvimage(void) { #ifdef HAVE_SHM - if ( Shmem_Flag ) - { - XShmDetach( mDisplay,&Shminfo ); - shmdt( Shminfo.shmaddr ); - } - else + if ( Shmem_Flag ) + { + XShmDetach( mDisplay,&Shminfo ); + shmdt( Shminfo.shmaddr ); + } + else #endif - { - free(xvimage->data); - } - XFree(xvimage); + { + free(xvimage->data); + } + XFree(xvimage); - XSync(mDisplay, False); - return; + XSync(mDisplay, False); + return; } //end of vo_xv shm/xvimage code static int xvmc_check_surface_format(uint32_t format, XvMCSurfaceInfo * surf_info){ - if ( format == IMGFMT_XVMC_IDCT_MPEG2 ){ - if( surf_info->mc_type != (XVMC_IDCT|XVMC_MPEG_2) ) return -1; - if( surf_info->chroma_format != XVMC_CHROMA_FORMAT_420 ) return -1; - return 0; - } - if ( format == IMGFMT_XVMC_MOCO_MPEG2 ){ - if(surf_info->mc_type != XVMC_MPEG_2) return -1; - if(surf_info->chroma_format != XVMC_CHROMA_FORMAT_420) return -1; - return 0; - } + if ( format == IMGFMT_XVMC_IDCT_MPEG2 ){ + if( surf_info->mc_type != (XVMC_IDCT|XVMC_MPEG_2) ) return -1; + if( surf_info->chroma_format != XVMC_CHROMA_FORMAT_420 ) return -1; + return 0; + } + if ( format == IMGFMT_XVMC_MOCO_MPEG2 ){ + if(surf_info->mc_type != XVMC_MPEG_2) return -1; + if(surf_info->chroma_format != XVMC_CHROMA_FORMAT_420) return -1; + return 0; + } return -1;//fail } //print all info needed to add new format static void print_xvimage_format_values(XvImageFormatValues *xifv){ int i; - printf("Format_ID = 0x%X\n",xifv->id); + printf("Format_ID = 0x%X\n",xifv->id); - printf(" type = "); - if(xifv->type == XvRGB) printf("RGB\n"); - else if(xifv->type == XvYUV) printf("YUV\n"); - else printf("Unknown\n"); + printf(" type = "); + if(xifv->type == XvRGB) printf("RGB\n"); + else if(xifv->type == XvYUV) printf("YUV\n"); + else printf("Unknown\n"); - printf(" byte_order = "); - if(xifv->byte_order == LSBFirst) printf("LSB First\n"); - else if(xifv->type == MSBFirst) printf("MSB First\n"); - else printf("Unknown\n");//yes Linux support other types too + printf(" byte_order = "); + if(xifv->byte_order == LSBFirst) printf("LSB First\n"); + else if(xifv->type == MSBFirst) printf("MSB First\n"); + else printf("Unknown\n");//yes Linux support other types too - printf(" guid = "); - for(i=0;i<16;i++) - printf("%02X ",(unsigned char)xifv->guid[i]); - printf("\n"); + printf(" guid = "); + for(i=0;i<16;i++) + printf("%02X ",(unsigned char)xifv->guid[i]); + printf("\n"); - printf(" bits_per_pixel = %d\n",xifv->bits_per_pixel); + printf(" bits_per_pixel = %d\n",xifv->bits_per_pixel); - printf(" format = "); - if(xifv->format == XvPacked) printf("XvPacked\n"); - else if(xifv->format == XvPlanar) printf("XvPlanar\n"); - else printf("Unknown\n"); + printf(" format = "); + if(xifv->format == XvPacked) printf("XvPacked\n"); + else if(xifv->format == XvPlanar) printf("XvPlanar\n"); + else printf("Unknown\n"); - printf(" num_planes = %d\n",xifv->num_planes); + printf(" num_planes = %d\n",xifv->num_planes); - if(xifv->type == XvRGB){ - printf(" red_mask = %0X\n", xifv->red_mask); - printf(" green_mask = %0X\n",xifv->green_mask); - printf(" blue_mask = %0X\n", xifv->blue_mask); - } - if(xifv->type == XvYUV){ - printf(" y_sample_bits = %d\n u_sample_bits = %d\n v_sample_bits = %d\n", - xifv->y_sample_bits,xifv->u_sample_bits,xifv->v_sample_bits); - printf(" horz_y_period = %d\n horz_u_period = %d\n horz_v_period = %d\n", - xifv->horz_y_period,xifv->horz_u_period,xifv->horz_v_period); - printf(" vert_y_period = %d\n vert_u_period = %d\n vert_v_period = %d\n", - xifv->vert_y_period,xifv->vert_u_period,xifv->vert_v_period); + if(xifv->type == XvRGB){ + printf(" red_mask = %0X\n", xifv->red_mask); + printf(" green_mask = %0X\n",xifv->green_mask); + printf(" blue_mask = %0X\n", xifv->blue_mask); + } + if(xifv->type == XvYUV){ + printf(" y_sample_bits = %d\n u_sample_bits = %d\n v_sample_bits = %d\n", + xifv->y_sample_bits,xifv->u_sample_bits,xifv->v_sample_bits); + printf(" horz_y_period = %d\n horz_u_period = %d\n horz_v_period = %d\n", + xifv->horz_y_period,xifv->horz_u_period,xifv->horz_v_period); + printf(" vert_y_period = %d\n vert_u_period = %d\n vert_v_period = %d\n", + xifv->vert_y_period,xifv->vert_u_period,xifv->vert_v_period); - printf(" component_order = "); - for(i=0;i<32;i++) - if(xifv->component_order[i]>=32) - printf("%c",xifv->component_order[i]); - printf("\n"); + printf(" component_order = "); + for(i=0;i<32;i++) + if(xifv->component_order[i]>=32) + printf("%c",xifv->component_order[i]); + printf("\n"); - printf(" scanline = "); - if(xifv->scanline_order == XvTopToBottom) printf("XvTopToBottom\n"); - else if(xifv->scanline_order == XvBottomToTop) printf("XvBottomToTop\n"); - else printf("Unknown\n"); - } - printf("\n"); + printf(" scanline = "); + if(xifv->scanline_order == XvTopToBottom) printf("XvTopToBottom\n"); + else if(xifv->scanline_order == XvBottomToTop) printf("XvBottomToTop\n"); + else printf("Unknown\n"); + } + printf("\n"); } // WARNING This function may changes xv_port and surface_info! static int xvmc_find_surface_by_format(int format,int width,int height, - XvMCSurfaceInfo * surf_info,int query){ + XvMCSurfaceInfo * surf_info,int query){ int rez; XvAdaptorInfo * ai; int num_adaptors,i; @@ -289,93 +289,93 @@ int s,mc_surf_num; XvMCSurfaceInfo * mc_surf_list; - rez = XvQueryAdaptors(mDisplay,DefaultRootWindow(mDisplay),&num_adaptors,&ai); - if( rez != Success ) return -1; - if( mp_msg_test(MSGT_VO,MSGL_DBG3) ) { - printf("vo_xvmc: Querying %d adaptors\n",num_adaptors); } - for(i=0; i mc_surf_list[s].max_width ) continue; - if( height > mc_surf_list[s].max_height ) continue; - if( xvmc_check_surface_format(format,&mc_surf_list[s])<0 ) continue; + for(s=0; s mc_surf_list[s].max_width ) continue; + if( height > mc_surf_list[s].max_height ) continue; + if( xvmc_check_surface_format(format,&mc_surf_list[s])<0 ) continue; //we have match! - /* respect the users wish */ - if ( xv_port_request != 0 && xv_port_request != p ) - { - continue; - } + /* respect the users wish */ + if ( xv_port_request != 0 && xv_port_request != p ) + { + continue; + } - if(!query){ - rez = XvGrabPort(mDisplay,p,CurrentTime); - if(rez != Success){ - if ( mp_msg_test(MSGT_VO,MSGL_DBG3) ) { - printf("vo_xvmc: Fail to grab port %ld\n",p); } - continue; - } - printf("vo_xvmc: Using Xv Adaptor #%d (%s)\n", i, ai[i].name); - printf("vo_xvmc: Port %ld grabed\n",p); - xv_port = p; - } - goto surface_found; - }//for mc surf - XFree(mc_surf_list);//if mc_surf_num==0 is list==NULL ? - }//for ports - }//for adaptors - XvFreeAdaptorInfo(ai); + if(!query){ + rez = XvGrabPort(mDisplay,p,CurrentTime); + if(rez != Success){ + if ( mp_msg_test(MSGT_VO,MSGL_DBG3) ) { + printf("vo_xvmc: Fail to grab port %ld\n",p); } + continue; + } + printf("vo_xvmc: Using Xv Adaptor #%d (%s)\n", i, ai[i].name); + printf("vo_xvmc: Port %ld grabed\n",p); + xv_port = p; + } + goto surface_found; + }//for mc surf + XFree(mc_surf_list);//if mc_surf_num==0 is list==NULL ? + }//for ports + }//for adaptors + XvFreeAdaptorInfo(ai); - if(!query) printf("vo_xvmc: Could not find free matching surface. Sorry.\n"); - return 0; + if(!query) printf("vo_xvmc: Could not find free matching surface. Sorry.\n"); + return 0; // somebody know cleaner way to escape from 3 internal loops? surface_found: - XvFreeAdaptorInfo(ai); + XvFreeAdaptorInfo(ai); - memcpy(surf_info,&mc_surf_list[s],sizeof(XvMCSurfaceInfo)); - if( mp_msg_test(MSGT_VO,MSGL_DBG3) || !query) - printf("vo_xvmc: Found matching surface with id=%X on %ld port at %d adapter\n", - mc_surf_list[s].surface_type_id,p,i); - return mc_surf_list[s].surface_type_id; + memcpy(surf_info,&mc_surf_list[s],sizeof(XvMCSurfaceInfo)); + if( mp_msg_test(MSGT_VO,MSGL_DBG3) || !query) + printf("vo_xvmc: Found matching surface with id=%X on %ld port at %d adapter\n", + mc_surf_list[s].surface_type_id,p,i); + return mc_surf_list[s].surface_type_id; } static uint32_t xvmc_draw_image(mp_image_t *mpi){ - struct xvmc_pix_fmt *rndr; + struct xvmc_pix_fmt *rndr; - assert(mpi!=NULL); - assert(mpi->flags &MP_IMGFLAG_DIRECT); + assert(mpi!=NULL); + assert(mpi->flags &MP_IMGFLAG_DIRECT); // assert(mpi->flags &MP_IMGFLAGS_DRAWBACK); - rndr = (struct xvmc_pix_fmt*)mpi->priv; //there is copy in plane[2] - assert( rndr != NULL ); - assert( rndr->xvmc_id == AV_XVMC_ID ); - if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) - printf("vo_xvmc: draw_image(show rndr=%p)\n",rndr); + rndr = (struct xvmc_pix_fmt*)mpi->priv; //there is copy in plane[2] + assert( rndr != NULL ); + assert( rndr->xvmc_id == AV_XVMC_ID ); + if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) + printf("vo_xvmc: draw_image(show rndr=%p)\n",rndr); // the surface have passed vf system without been skiped, it will be displayed - rndr->state |= AV_XVMC_STATE_DISPLAY_PENDING; - p_render_surface_to_show = rndr; - top_field_first = mpi->fields & MP_IMGFIELD_TOP_FIRST; - return VO_TRUE; + rndr->state |= AV_XVMC_STATE_DISPLAY_PENDING; + p_render_surface_to_show = rndr; + top_field_first = mpi->fields & MP_IMGFIELD_TOP_FIRST; + return VO_TRUE; } static int preinit(const char *arg){ @@ -386,63 +386,63 @@ strarg_t ck_method_arg = { 0, NULL }; opt_t subopts [] = { - /* name arg type arg var test */ - { "port", OPT_ARG_INT, &xv_port_request, (opt_test_f)int_pos }, - { "adaptor", OPT_ARG_INT, &xv_adaptor, (opt_test_f)int_non_neg }, - { "ck", OPT_ARG_STR, &ck_src_arg, xv_test_ck }, - { "ck-method", OPT_ARG_STR, &ck_method_arg, xv_test_ckm }, - { "benchmark", OPT_ARG_BOOL, &benchmark, NULL }, - { "sleep", OPT_ARG_BOOL, &use_sleep, NULL }, - { "queue", OPT_ARG_BOOL, &use_queue, NULL }, - { "bobdeint", OPT_ARG_BOOL, &bob_deinterlace, NULL }, - { NULL } + /* name arg type arg var test */ + { "port", OPT_ARG_INT, &xv_port_request, (opt_test_f)int_pos }, + { "adaptor", OPT_ARG_INT, &xv_adaptor, (opt_test_f)int_non_neg }, + { "ck", OPT_ARG_STR, &ck_src_arg, xv_test_ck }, + { "ck-method", OPT_ARG_STR, &ck_method_arg, xv_test_ckm }, + { "benchmark", OPT_ARG_BOOL, &benchmark, NULL }, + { "sleep", OPT_ARG_BOOL, &use_sleep, NULL }, + { "queue", OPT_ARG_BOOL, &use_queue, NULL }, + { "bobdeint", OPT_ARG_BOOL, &bob_deinterlace, NULL }, + { NULL } }; - //Obtain display handler - if (!vo_init()) return -1;//vo_xv + //Obtain display handler + if (!vo_init()) return -1;//vo_xv - //XvMC is subdivision of XVideo - if (Success != XvQueryExtension(mDisplay,&xv_version,&xv_release,&xv_request_base, - &xv_event_base,&xv_error_base) ){ - mp_msg(MSGT_VO,MSGL_ERR,"Sorry, Xv(MC) not supported by this X11 version/driver\n"); - mp_msg(MSGT_VO,MSGL_ERR,"********** Try with -vo x11 or -vo sdl ***********\n"); - return -1; - } - printf("vo_xvmc: X-Video extension %d.%d\n",xv_version,xv_release); + //XvMC is subdivision of XVideo + if (Success != XvQueryExtension(mDisplay,&xv_version,&xv_release,&xv_request_base, + &xv_event_base,&xv_error_base) ){ + mp_msg(MSGT_VO,MSGL_ERR,"Sorry, Xv(MC) not supported by this X11 version/driver\n"); + mp_msg(MSGT_VO,MSGL_ERR,"********** Try with -vo x11 or -vo sdl ***********\n"); + return -1; + } + printf("vo_xvmc: X-Video extension %d.%d\n",xv_version,xv_release); - if( True != XvMCQueryExtension(mDisplay,&mc_eventBase,&mc_errorBase) ){ - printf("vo_xvmc: No X-Video MotionCompensation Extension on %s\n", - XDisplayName(NULL)); - return -1; - } + if( True != XvMCQueryExtension(mDisplay,&mc_eventBase,&mc_errorBase) ){ + printf("vo_xvmc: No X-Video MotionCompensation Extension on %s\n", + XDisplayName(NULL)); + return -1; + } - if(Success == XvMCQueryVersion(mDisplay, &mc_ver, &mc_rev) ){ - printf("vo_xvmc: X-Video MotionCompensation Extension version %i.%i\n", + if(Success == XvMCQueryVersion(mDisplay, &mc_ver, &mc_rev) ){ + printf("vo_xvmc: X-Video MotionCompensation Extension version %i.%i\n", mc_ver,mc_rev); - } - else{ - printf("vo_xvmc: Error querying version info!\n"); - return -1; - } - surface_render = NULL; - xv_port = 0; - number_of_surfaces = 0; - subpicture_alloc = 0; + } + else{ + printf("vo_xvmc: Error querying version info!\n"); + return -1; + } + surface_render = NULL; + xv_port = 0; + number_of_surfaces = 0; + subpicture_alloc = 0; - benchmark = 0; //disable PutImageto allow faster display than screen refresh - use_sleep = 0; - use_queue = 0; - bob_deinterlace = 0; + benchmark = 0; //disable PutImageto allow faster display than screen refresh + use_sleep = 0; + use_queue = 0; + bob_deinterlace = 0; - /* parse suboptions */ - if ( subopt_parse( arg, subopts ) != 0 ) - { - return -1; - } + /* parse suboptions */ + if ( subopt_parse( arg, subopts ) != 0 ) + { + return -1; + } - xv_setup_colorkeyhandling( ck_method_arg.str, ck_src_arg.str ); + xv_setup_colorkeyhandling( ck_method_arg.str, ck_src_arg.str ); - return 0; + return 0; } static int config(uint32_t width, uint32_t height, @@ -462,381 +462,381 @@ #endif //end of vo_xv - if( !IMGFMT_IS_XVMC(format) ) - { - assert(0);//should never happen, abort on debug or - return 1;//return error on relese - } + if( !IMGFMT_IS_XVMC(format) ) + { + assert(0);//should never happen, abort on debug or + return 1;//return error on relese + } // Find free port that supports MC, by querying adaptors - if( xv_port != 0 || number_of_surfaces != 0 ){ - if( height==image_height && width==image_width && image_format==format){ - xvmc_clean_surfaces(); - goto skip_surface_allocation; - } - xvmc_free(); - }; - numblocks=((width+15)/16)*((height+15)/16); + if( xv_port != 0 || number_of_surfaces != 0 ){ + if( height==image_height && width==image_width && image_format==format){ + xvmc_clean_surfaces(); + goto skip_surface_allocation; + } + xvmc_free(); + }; + numblocks=((width+15)/16)*((height+15)/16); // Find Supported Surface Type - mode_id = xvmc_find_surface_by_format(format,width,height,&surface_info,0);//false=1 to grab port, not query - if ( mode_id == 0 ) - { - return -1; - } + mode_id = xvmc_find_surface_by_format(format,width,height,&surface_info,0);//false=1 to grab port, not query + if ( mode_id == 0 ) + { + return -1; + } - rez = XvMCCreateContext(mDisplay, xv_port,mode_id,width,height,XVMC_DIRECT,&ctx); - if( rez != Success ){ - printf("vo_xvmc: XvMCCreateContext failed with error %d\n",rez); - return -1; - } - if( ctx.flags & XVMC_DIRECT ){ - printf("vo_xvmc: Allocated Direct Context\n"); - }else{ - printf("vo_xvmc: Allocated Indirect Context!\n"); - } + rez = XvMCCreateContext(mDisplay, xv_port,mode_id,width,height,XVMC_DIRECT,&ctx); + if( rez != Success ){ + printf("vo_xvmc: XvMCCreateContext failed with error %d\n",rez); + return -1; + } + if( ctx.flags & XVMC_DIRECT ){ + printf("vo_xvmc: Allocated Direct Context\n"); + }else{ + printf("vo_xvmc: Allocated Indirect Context!\n"); + } - blocks_per_macroblock = 6; - if(surface_info.chroma_format == XVMC_CHROMA_FORMAT_422) - blocks_per_macroblock = 8; - if(surface_info.chroma_format == XVMC_CHROMA_FORMAT_444) - blocks_per_macroblock = 12; + blocks_per_macroblock = 6; + if(surface_info.chroma_format == XVMC_CHROMA_FORMAT_422) + blocks_per_macroblock = 8; + if(surface_info.chroma_format == XVMC_CHROMA_FORMAT_444) + blocks_per_macroblock = 12; - rez = XvMCCreateBlocks(mDisplay,&ctx,numblocks*blocks_per_macroblock,&data_blocks); - if( rez != Success ){ - XvMCDestroyContext(mDisplay,&ctx); - return -1; - } - printf("vo_xvmc: data_blocks allocated\n"); + rez = XvMCCreateBlocks(mDisplay,&ctx,numblocks*blocks_per_macroblock,&data_blocks); + if( rez != Success ){ + XvMCDestroyContext(mDisplay,&ctx); + return -1; + } + printf("vo_xvmc: data_blocks allocated\n"); - rez = XvMCCreateMacroBlocks(mDisplay,&ctx,numblocks,&mv_blocks); - if( rez != Success ){ - XvMCDestroyBlocks(mDisplay,&data_blocks); - XvMCDestroyContext(mDisplay,&ctx); - return -1; - } - printf("vo_xvmc: mv_blocks allocated\n"); + rez = XvMCCreateMacroBlocks(mDisplay,&ctx,numblocks,&mv_blocks); + if( rez != Success ){ + XvMCDestroyBlocks(mDisplay,&data_blocks); + XvMCDestroyContext(mDisplay,&ctx); + return -1; + } + printf("vo_xvmc: mv_blocks allocated\n"); - if(surface_render==NULL) - surface_render = malloc(MAX_SURFACES * sizeof(struct xvmc_pix_fmt)); //easy mem debug - memset(surface_render, 0, MAX_SURFACES * sizeof(struct xvmc_pix_fmt)); + if(surface_render==NULL) + surface_render = malloc(MAX_SURFACES * sizeof(struct xvmc_pix_fmt)); //easy mem debug + memset(surface_render, 0, MAX_SURFACES * sizeof(struct xvmc_pix_fmt)); - for(i=0; i 0){ + if(subpicture.num_palette_entries > 0){ - snum = subpicture.num_palette_entries; - seb = subpicture.entry_bytes; - palette = malloc(snum*seb);//check fail - if(palette == NULL) return; - for(i=0; i(0),(1*(1<<1)/2) - U = 1 << (subpicture_info.u_sample_bits - 1); - V = 1 << (subpicture_info.v_sample_bits - 1); - for(j=0; j(0),(1*(1<<1)/2) + U = 1 << (subpicture_info.u_sample_bits - 1); + V = 1 << (subpicture_info.v_sample_bits - 1); + for(j=0; j surface_info.subpicture_max_width) - osd_width = surface_info.subpicture_max_width; - if(osd_height > surface_info.subpicture_max_height) - osd_height = surface_info.subpicture_max_height; - if(osd_width == 0 || osd_height == 0) - return;//if called before window size is known + if(osd_width > surface_info.subpicture_max_width) + osd_width = surface_info.subpicture_max_width; + if(osd_height > surface_info.subpicture_max_height) + osd_height = surface_info.subpicture_max_height; + if(osd_width == 0 || osd_height == 0) + return;//if called before window size is known - if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) - printf("vo_xvmc: creating subpicture (%d,%d) format %X\n", - osd_width,osd_height,subpicture_info.id); + if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) + printf("vo_xvmc: creating subpicture (%d,%d) format %X\n", + osd_width,osd_height,subpicture_info.id); - rez = XvMCCreateSubpicture(mDisplay,&ctx,&subpicture, - osd_width,osd_height,subpicture_info.id); - if(rez != Success){ - subpicture_mode = NO_SUBPICTURE; - printf("vo_xvmc: Create Subpicture failed, OSD disabled\n"); - return; - } - if( mp_msg_test(MSGT_VO,MSGL_DBG4) ){ - int i; - printf("vo_xvmc: Created Subpicture:\n"); - printf(" xvimage_id=0x%X\n",subpicture.xvimage_id); - printf(" width=%d\n",subpicture.width); - printf(" height=%d\n",subpicture.height); - printf(" num_palette_entries=0x%X\n",subpicture.num_palette_entries); - printf(" entry_bytes=0x%X\n",subpicture.entry_bytes); + rez = XvMCCreateSubpicture(mDisplay,&ctx,&subpicture, + osd_width,osd_height,subpicture_info.id); + if(rez != Success){ + subpicture_mode = NO_SUBPICTURE; + printf("vo_xvmc: Create Subpicture failed, OSD disabled\n"); + return; + } + if( mp_msg_test(MSGT_VO,MSGL_DBG4) ){ + int i; + printf("vo_xvmc: Created Subpicture:\n"); + printf(" xvimage_id=0x%X\n",subpicture.xvimage_id); + printf(" width=%d\n",subpicture.width); + printf(" height=%d\n",subpicture.height); + printf(" num_palette_entries=0x%X\n",subpicture.num_palette_entries); + printf(" entry_bytes=0x%X\n",subpicture.entry_bytes); - printf(" component_order=\""); - for(i=0; i<4; i++) - if(subpicture.component_order[i] >= 32) - printf("%c", subpicture.component_order[i]); - printf("\"\n"); - } + printf(" component_order=\""); + for(i=0; i<4; i++) + if(subpicture.component_order[i] >= 32) + printf("%c", subpicture.component_order[i]); + printf("\"\n"); + } - //call init for the surface type - init_osd_fnc();//init palete,clear color etc ... - if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) - printf("vo_xvmc: clearing subpicture\n"); - clear_osd_fnc(0, 0, subpicture.width, subpicture.height); + //call init for the surface type + init_osd_fnc();//init palete,clear color etc ... + if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) + printf("vo_xvmc: clearing subpicture\n"); + clear_osd_fnc(0, 0, subpicture.width, subpicture.height); - allocate_xvimage(subpicture.width, subpicture.height, subpicture_info.id); - subpicture_alloc = 1; + allocate_xvimage(subpicture.width, subpicture.height, subpicture_info.id); + subpicture_alloc = 1; } static void draw_osd_IA44(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ int ox,oy; int rez; - if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) - printf("vo_xvmc:composite AI44 subpicture (%d,%d - %d,%d)\n",x0,y0,w,h); + if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) + printf("vo_xvmc:composite AI44 subpicture (%d,%d - %d,%d)\n",x0,y0,w,h); - for(ox=0; oxdata[oy*xvimage->width+ox] = (src[oy*stride+ox]>>4) | ((0-srca[oy*stride+ox])&0xf0); - } - } - rez = XvMCCompositeSubpicture(mDisplay, &subpicture, xvimage, 0, 0, - w,h,x0,y0); - if(rez != Success){ - printf("vo_xvmc: composite subpicture failed\n"); - assert(0); - } + for(ox=0; oxdata[oy*xvimage->width+ox] = (src[oy*stride+ox]>>4) | ((0-srca[oy*stride+ox])&0xf0); + } + } + rez = XvMCCompositeSubpicture(mDisplay, &subpicture, xvimage, 0, 0, + w,h,x0,y0); + if(rez != Success){ + printf("vo_xvmc: composite subpicture failed\n"); + assert(0); + } } static void draw_osd_AI44(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride){ int ox,oy; int rez; - if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) - printf("vo_xvmc:composite AI44 subpicture (%d,%d - %d,%d)\n",x0,y0,w,h); + if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) + printf("vo_xvmc:composite AI44 subpicture (%d,%d - %d,%d)\n",x0,y0,w,h); - for(ox=0; oxdata[oy*xvimage->width+ox] = (src[oy*stride+ox]&0xf0) | (((0-srca[oy*stride+ox])>>4)&0xf); - } - } - rez = XvMCCompositeSubpicture(mDisplay, &subpicture, xvimage, 0, 0, - w,h,x0,y0); - if(rez != Success){ - printf("vo_xvmc: composite subpicture failed\n"); - assert(0); - } + for(ox=0; oxdata[oy*xvimage->width+ox] = (src[oy*stride+ox]&0xf0) | (((0-srca[oy*stride+ox])>>4)&0xf); + } + } + rez = XvMCCompositeSubpicture(mDisplay, &subpicture, xvimage, 0, 0, + w,h,x0,y0); + if(rez != Success){ + printf("vo_xvmc: composite subpicture failed\n"); + assert(0); + } } static void draw_osd(void){ @@ -845,93 +845,93 @@ int have_osd_to_draw; int rez; - if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) - printf("vo_xvmc: draw_osd ,OSD_mode=%d, surface_to_show=%p\n", - subpicture_mode,p_render_surface_to_show); + if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) + printf("vo_xvmc: draw_osd ,OSD_mode=%d, surface_to_show=%p\n", + subpicture_mode,p_render_surface_to_show); - if(subpicture_mode == BLEND_SUBPICTURE || - subpicture_mode == BACKEND_SUBPICTURE ){ + if(subpicture_mode == BLEND_SUBPICTURE || + subpicture_mode == BACKEND_SUBPICTURE ){ - if(!subpicture_alloc) //allocate subpicture when dimensions are known - OSD_init(); - if(!subpicture_alloc) - return;//dimensions still unknown. + if(!subpicture_alloc) //allocate subpicture when dimensions are known + OSD_init(); + if(!subpicture_alloc) + return;//dimensions still unknown. - osd_has_changed = vo_update_osd(subpicture.width, subpicture.height); - have_osd_to_draw = vo_osd_check_range_update(0, 0, subpicture.width, + osd_has_changed = vo_update_osd(subpicture.width, subpicture.height); + have_osd_to_draw = vo_osd_check_range_update(0, 0, subpicture.width, subpicture.height); - if(!have_osd_to_draw) - return;//nothing to draw,no subpic, no blend + if(!have_osd_to_draw) + return;//nothing to draw,no subpic, no blend - if(osd_has_changed){ - //vo_remove_text(subpicture.width, subpicture.height,clear_osd_fnc) - clear_osd_fnc(0,0,subpicture.width,subpicture.height); - vo_draw_text(subpicture.width, subpicture.height, draw_osd_fnc); - } - XvMCSyncSubpicture(mDisplay,&subpicture);//todo usleeep wait! + if(osd_has_changed){ + //vo_remove_text(subpicture.width, subpicture.height,clear_osd_fnc) + clear_osd_fnc(0,0,subpicture.width,subpicture.height); + vo_draw_text(subpicture.width, subpicture.height, draw_osd_fnc); + } + XvMCSyncSubpicture(mDisplay,&subpicture);//todo usleeep wait! - if(subpicture_mode == BLEND_SUBPICTURE){ - osd_rndr = find_free_surface(); - if(osd_rndr == NULL) - return;// no free surface to draw OSD in + if(subpicture_mode == BLEND_SUBPICTURE){ + osd_rndr = find_free_surface(); + if(osd_rndr == NULL) + return;// no free surface to draw OSD in - rez = XvMCBlendSubpicture2(mDisplay, - p_render_surface_to_show->p_surface, osd_rndr->p_surface, - &subpicture, - 0, 0, subpicture.width, subpicture.height, - 0, 0, image_width, image_height); - if(rez!=Success){ - printf("vo_xvmc: BlendSubpicture failed rez=%d\n",rez); - assert(0); - return; - } + rez = XvMCBlendSubpicture2(mDisplay, + p_render_surface_to_show->p_surface, osd_rndr->p_surface, + &subpicture, + 0, 0, subpicture.width, subpicture.height, + 0, 0, image_width, image_height); + if(rez!=Success){ + printf("vo_xvmc: BlendSubpicture failed rez=%d\n",rez); + assert(0); + return; + } // XvMCFlushSurface(mDisplay,osd_rndr->p_surface);//fixme- should I? - //When replaceing the surface with osd one, save the flags too! - osd_rndr->picture_structure = p_render_surface_to_show->picture_structure; + //When replaceing the surface with osd one, save the flags too! + osd_rndr->picture_structure = p_render_surface_to_show->picture_structure; //add more if needed osd_rndr-> = p_render_surface_to_show->; - p_render_surface_to_show->state &= ~AV_XVMC_STATE_DISPLAY_PENDING; - p_render_surface_to_show->state |= AV_XVMC_STATE_OSD_SOURCE; - p_render_surface_to_show->p_osd_target_surface_render = osd_rndr; + p_render_surface_to_show->state &= ~AV_XVMC_STATE_DISPLAY_PENDING; + p_render_surface_to_show->state |= AV_XVMC_STATE_OSD_SOURCE; + p_render_surface_to_show->p_osd_target_surface_render = osd_rndr; - p_render_surface_to_show = osd_rndr; - p_render_surface_to_show->state = AV_XVMC_STATE_DISPLAY_PENDING; + p_render_surface_to_show = osd_rndr; + p_render_surface_to_show->state = AV_XVMC_STATE_DISPLAY_PENDING; - if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) - printf("vo_xvmc:draw_osd: surface_to_show changed to %p\n",osd_rndr); - }//endof if(BLEND) - if(subpicture_mode == BACKEND_SUBPICTURE){ - rez = XvMCBlendSubpicture(mDisplay, - p_render_surface_to_show->p_surface, - &subpicture, - 0, 0, subpicture.width, subpicture.height, - 0, 0, image_width, image_height); + if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) + printf("vo_xvmc:draw_osd: surface_to_show changed to %p\n",osd_rndr); + }//endof if(BLEND) + if(subpicture_mode == BACKEND_SUBPICTURE){ + rez = XvMCBlendSubpicture(mDisplay, + p_render_surface_to_show->p_surface, + &subpicture, + 0, 0, subpicture.width, subpicture.height, + 0, 0, image_width, image_height); - } + } - }//if(BLEND||BACKEND) + }//if(BLEND||BACKEND) } static void xvmc_sync_surface(XvMCSurface * srf){ int status,rez; - rez = XvMCGetSurfaceStatus(mDisplay,srf,&status); - assert(rez==Success); - if((status & XVMC_RENDERING) == 0) - return;//surface is already complete - if(use_sleep){ - rez = XvMCFlushSurface(mDisplay, srf); - assert(rez==Success); + rez = XvMCGetSurfaceStatus(mDisplay,srf,&status); + assert(rez==Success); + if((status & XVMC_RENDERING) == 0) + return;//surface is already complete + if(use_sleep){ + rez = XvMCFlushSurface(mDisplay, srf); + assert(rez==Success); - do{ - usec_sleep(1000);//1ms (may be 20ms on linux) - XvMCGetSurfaceStatus(mDisplay,srf,&status); - } while (status & XVMC_RENDERING); - return;//done - } + do{ + usec_sleep(1000);//1ms (may be 20ms on linux) + XvMCGetSurfaceStatus(mDisplay,srf,&status); + } while (status & XVMC_RENDERING); + return;//done + } - XvMCSyncSurface(mDisplay, srf); + XvMCSyncSurface(mDisplay, srf); } static void put_xvmc_image(struct xvmc_pix_fmt *p_render_surface, @@ -940,149 +940,149 @@ struct vo_rect src_rect, dst_rect; int i; - if(p_render_surface == NULL) - return; + if(p_render_surface == NULL) + return; - calc_src_dst_rects(image_width, image_height, &src_rect, &dst_rect, NULL, NULL); + calc_src_dst_rects(image_width, image_height, &src_rect, &dst_rect, NULL, NULL); - if(draw_ck) - vo_xv_draw_colorkey(dst_rect.left, dst_rect.top, dst_rect.width, dst_rect.height); + if(draw_ck) + vo_xv_draw_colorkey(dst_rect.left, dst_rect.top, dst_rect.width, dst_rect.height); - if(benchmark) - return; + if(benchmark) + return; - for (i = 1; i <= bob_deinterlace + 1; i++) { - int field = top_field_first ? i : i ^ 3; - rez = XvMCPutSurface(mDisplay, p_render_surface->p_surface, - vo_window, - src_rect.left, src_rect.top, src_rect.width, src_rect.height, - dst_rect.left, dst_rect.top, dst_rect.width, dst_rect.height, - bob_deinterlace ? field : 3); - if(rez != Success){ - printf("vo_xvmc: PutSurface failer, critical error %d!\n",rez); - assert(0); - } - } - XFlush(mDisplay); + for (i = 1; i <= bob_deinterlace + 1; i++) { + int field = top_field_first ? i : i ^ 3; + rez = XvMCPutSurface(mDisplay, p_render_surface->p_surface, + vo_window, + src_rect.left, src_rect.top, src_rect.width, src_rect.height, + dst_rect.left, dst_rect.top, dst_rect.width, dst_rect.height, + bob_deinterlace ? field : 3); + if(rez != Success){ + printf("vo_xvmc: PutSurface failer, critical error %d!\n",rez); + assert(0); + } + } + XFlush(mDisplay); } static void flip_page(void){ int i,cfs; - if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) - printf("vo_xvmc: flip_page show(rndr=%p)\n\n",p_render_surface_to_show); + if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) + printf("vo_xvmc: flip_page show(rndr=%p)\n\n",p_render_surface_to_show); - if(p_render_surface_to_show == NULL) return; - assert( p_render_surface_to_show->xvmc_id == AV_XVMC_ID ); + if(p_render_surface_to_show == NULL) return; + assert( p_render_surface_to_show->xvmc_id == AV_XVMC_ID ); //fixme assert( p_render_surface_to_show != p_render_surface_visible); - if(use_queue){ - // fill the queue until only n free surfaces remain - // after that start displaying - cfs = count_free_surfaces(); - show_queue[free_element++] = p_render_surface_to_show; - if(cfs > 3){//well have 3 free surfaces after add queue - if(free_element > 1)//a little voodoo magic - xvmc_sync_surface(show_queue[0]->p_surface); - return; - } - p_render_surface_to_show=show_queue[0]; - if( mp_msg_test(MSGT_VO,MSGL_DBG5) ) - printf("vo_xvmc: flip_queue free_element=%d\n",free_element); - free_element--; - for(i=0; i 3){//well have 3 free surfaces after add queue + if(free_element > 1)//a little voodoo magic + xvmc_sync_surface(show_queue[0]->p_surface); + return; + } + p_render_surface_to_show=show_queue[0]; + if( mp_msg_test(MSGT_VO,MSGL_DBG5) ) + printf("vo_xvmc: flip_queue free_element=%d\n",free_element); + free_element--; + for(i=0; ip_surface); + xvmc_sync_surface(p_render_surface_to_show->p_surface); //the visible surface won't be displayed anymore, mark it as free - if(p_render_surface_visible != NULL) - p_render_surface_visible->state &= ~AV_XVMC_STATE_DISPLAY_PENDING; + if(p_render_surface_visible != NULL) + p_render_surface_visible->state &= ~AV_XVMC_STATE_DISPLAY_PENDING; //!!fixme assert(p_render_surface_to_show->state & AV_XVMC_STATE_DISPLAY_PENDING); - //show it, displaying is always vsynced, so skip it for benchmark - put_xvmc_image(p_render_surface_to_show,first_frame); - first_frame=0;//make sure we won't draw it anymore + //show it, displaying is always vsynced, so skip it for benchmark + put_xvmc_image(p_render_surface_to_show,first_frame); + first_frame=0;//make sure we won't draw it anymore - p_render_surface_visible = p_render_surface_to_show; - p_render_surface_to_show = NULL; + p_render_surface_visible = p_render_surface_to_show; + p_render_surface_to_show = NULL; } static void check_events(void){ int e=vo_x11_check_events(mDisplay); - if(e&VO_EVENT_RESIZE) - { - e |= VO_EVENT_EXPOSE; - } - if ( e & VO_EVENT_EXPOSE ) - { - put_xvmc_image(p_render_surface_visible,1); - } + if(e&VO_EVENT_RESIZE) + { + e |= VO_EVENT_EXPOSE; + } + if ( e & VO_EVENT_EXPOSE ) + { + put_xvmc_image(p_render_surface_visible,1); + } } static void xvmc_free(void){ int i; - if( subpicture_alloc ){ + if( subpicture_alloc ){ - XvMCDestroySubpicture(mDisplay,&subpicture); - deallocate_xvimage(); + XvMCDestroySubpicture(mDisplay,&subpicture); + deallocate_xvimage(); - subpicture_alloc = 0; + subpicture_alloc = 0; - if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) - printf("vo_xvmc: subpicture destroyed\n"); - } + if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) + printf("vo_xvmc: subpicture destroyed\n"); + } - if( number_of_surfaces ){ + if( number_of_surfaces ){ - XvMCDestroyMacroBlocks(mDisplay,&mv_blocks); - XvMCDestroyBlocks(mDisplay,&data_blocks); + XvMCDestroyMacroBlocks(mDisplay,&mv_blocks); + XvMCDestroyBlocks(mDisplay,&data_blocks); - for(i=0; ixvmc_id == AV_XVMC_ID ); + rndr = (struct xvmc_pix_fmt*)image[2]; //this is copy of priv-ate + assert( rndr != NULL ); + assert( rndr->xvmc_id == AV_XVMC_ID ); - rez = XvMCRenderSurface(mDisplay,&ctx,rndr->picture_structure, - rndr->p_surface, - rndr->p_past_surface, - rndr->p_future_surface, - rndr->flags, - rndr->filled_mv_blocks_num,rndr->start_mv_blocks_num, - &mv_blocks,&data_blocks); + rez = XvMCRenderSurface(mDisplay,&ctx,rndr->picture_structure, + rndr->p_surface, + rndr->p_past_surface, + rndr->p_future_surface, + rndr->flags, + rndr->filled_mv_blocks_num,rndr->start_mv_blocks_num, + &mv_blocks,&data_blocks); #if 1 - if(rez != Success) - { - int i; - printf("vo_xvmc::slice: RenderSirface returned %d\n",rez); + if(rez != Success) + { + int i; + printf("vo_xvmc::slice: RenderSirface returned %d\n",rez); - printf("vo_xvmc::slice: pict=%d,flags=%x,start_blocks=%d,num_blocks=%d\n", - rndr->picture_structure,rndr->flags,rndr->start_mv_blocks_num, - rndr->filled_mv_blocks_num); - printf("vo_xvmc::slice: this_surf=%p, past_surf=%p, future_surf=%p\n", - rndr->p_surface,rndr->p_past_surface,rndr->p_future_surface); + printf("vo_xvmc::slice: pict=%d,flags=%x,start_blocks=%d,num_blocks=%d\n", + rndr->picture_structure,rndr->flags,rndr->start_mv_blocks_num, + rndr->filled_mv_blocks_num); + printf("vo_xvmc::slice: this_surf=%p, past_surf=%p, future_surf=%p\n", + rndr->p_surface,rndr->p_past_surface,rndr->p_future_surface); - for(i=0; ifilled_mv_blocks_num; i++){ - XvMCMacroBlock* testblock; - testblock = &mv_blocks.macro_blocks[i]; + for(i=0; ifilled_mv_blocks_num; i++){ + XvMCMacroBlock* testblock; + testblock = &mv_blocks.macro_blocks[i]; - printf("vo_xvmc::slice: mv_block - x=%d,y=%d,mb_type=0x%x,mv_type=0x%x,mv_field_select=%d\n", - testblock->x,testblock->y,testblock->macroblock_type, - testblock->motion_type,testblock->motion_vertical_field_select); - printf("vo_xvmc::slice: dct_type=%d,data_index=0x%x,cbp=%d,pad0=%d\n", - testblock->dct_type,testblock->index,testblock->coded_block_pattern, - testblock->pad0); - printf("vo_xvmc::slice: PMV[0][0][0/1]=(%d,%d)\n", - testblock->PMV[0][0][0],testblock->PMV[0][0][1]); - } - } + printf("vo_xvmc::slice: mv_block - x=%d,y=%d,mb_type=0x%x,mv_type=0x%x,mv_field_select=%d\n", + testblock->x,testblock->y,testblock->macroblock_type, + testblock->motion_type,testblock->motion_vertical_field_select); + printf("vo_xvmc::slice: dct_type=%d,data_index=0x%x,cbp=%d,pad0=%d\n", + testblock->dct_type,testblock->index,testblock->coded_block_pattern, + testblock->pad0); + printf("vo_xvmc::slice: PMV[0][0][0/1]=(%d,%d)\n", + testblock->PMV[0][0][0],testblock->PMV[0][0][1]); + } + } #endif - assert(rez==Success); - if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) printf("vo_xvmc: flush surface\n"); - rez = XvMCFlushSurface(mDisplay, rndr->p_surface); - assert(rez==Success); + assert(rez==Success); + if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) printf("vo_xvmc: flush surface\n"); + rez = XvMCFlushSurface(mDisplay, rndr->p_surface); + assert(rez==Success); // rndr->start_mv_blocks_num += rndr->filled_mv_blocks_num; - rndr->start_mv_blocks_num = 0; - rndr->filled_mv_blocks_num = 0; + rndr->start_mv_blocks_num = 0; + rndr->filled_mv_blocks_num = 0; - rndr->next_free_data_block_num = 0; + rndr->next_free_data_block_num = 0; - return VO_TRUE; + return VO_TRUE; } //XvMCHide hides the surface on next retrace, so @@ -1174,25 +1174,25 @@ static void check_osd_source(struct xvmc_pix_fmt *src_rndr) { struct xvmc_pix_fmt *osd_rndr; int stat; - //If this is source surface, check does the OSD rendering is compleate - if(src_rndr->state & AV_XVMC_STATE_OSD_SOURCE){ - if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) + //If this is source surface, check does the OSD rendering is compleate + if(src_rndr->state & AV_XVMC_STATE_OSD_SOURCE){ + if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) printf("vo_xvmc: OSD surface=%p quering\n",src_rndr); - osd_rndr = src_rndr->p_osd_target_surface_render; - XvMCGetSurfaceStatus(mDisplay, osd_rndr->p_surface, &stat); - if(!(stat & XVMC_RENDERING)) + osd_rndr = src_rndr->p_osd_target_surface_render; + XvMCGetSurfaceStatus(mDisplay, osd_rndr->p_surface, &stat); + if(!(stat & XVMC_RENDERING)) src_rndr->state &= ~AV_XVMC_STATE_OSD_SOURCE; - } + } } static int count_free_surfaces(void) { int i,num; - num=0; - for(i=0; ip_surface,&stat); - if( (stat & XVMC_DISPLAYING) == 0 ) - return visible_rndr; - } - } + //all surfaces are busy, but there is one that will be free + //on next monitor retrace, we just have to wait + if(visible_rndr != NULL){ + printf("vo_xvmc: waiting retrace\n"); + for(t=0;t<1000;t++){ + usec_sleep(1000);//1ms + XvMCGetSurfaceStatus(mDisplay, visible_rndr->p_surface,&stat); + if( (stat & XVMC_DISPLAYING) == 0 ) + return visible_rndr; + } + } //todo remove when stable - printf("vo_xvmc: no free surfaces, this should not happen in g1\n"); - for(i=0;istart_mv_blocks_num == 0); assert(rndr->filled_mv_blocks_num == 0); assert(rndr->next_free_data_block_num == 0); - mpi->flags |= MP_IMGFLAG_DIRECT; + mpi->flags |= MP_IMGFLAG_DIRECT; //keep strides 0 to avoid field manipulations - mpi->stride[0] = 0; - mpi->stride[1] = 0; - mpi->stride[2] = 0; + mpi->stride[0] = 0; + mpi->stride[1] = 0; + mpi->stride[2] = 0; // these are shared!! so watch out // do call RenderSurface before overwriting - mpi->planes[0] = (char*)data_blocks.blocks; - mpi->planes[1] = (char*)mv_blocks.macro_blocks; - mpi->priv = - mpi->planes[2] = (char*)rndr; + mpi->planes[0] = (char*)data_blocks.blocks; + mpi->planes[1] = (char*)mv_blocks.macro_blocks; + mpi->priv = + mpi->planes[2] = (char*)rndr; - rndr->picture_structure = 0; - rndr->flags = 0; - rndr->state = 0; - rndr->start_mv_blocks_num = 0; - rndr->filled_mv_blocks_num = 0; - rndr->next_free_data_block_num = 0; + rndr->picture_structure = 0; + rndr->flags = 0; + rndr->state = 0; + rndr->start_mv_blocks_num = 0; + rndr->filled_mv_blocks_num = 0; + rndr->next_free_data_block_num = 0; - if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) - printf("vo_xvmc: get_image: rndr=%p (surface=%p) \n", - rndr,rndr->p_surface); + if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) + printf("vo_xvmc: get_image: rndr=%p (surface=%p) \n", + rndr,rndr->p_surface); return VO_TRUE; } static int control(uint32_t request, void *data, ... ) { - switch (request){ - case VOCTRL_GET_DEINTERLACE: - *(int*)data = bob_deinterlace; - return VO_TRUE; - case VOCTRL_SET_DEINTERLACE: - bob_deinterlace = *(int*)data; - return VO_TRUE; - case VOCTRL_QUERY_FORMAT: - return query_format(*((uint32_t*)data)); - case VOCTRL_DRAW_IMAGE: - return xvmc_draw_image((mp_image_t *)data); - case VOCTRL_GET_IMAGE: - return get_image((mp_image_t *)data); - //vo_xv - case VOCTRL_GUISUPPORT: - return VO_TRUE; - case VOCTRL_ONTOP: - vo_x11_ontop(); - return VO_TRUE; - case VOCTRL_FULLSCREEN: - vo_x11_fullscreen(); - // indended, fallthrough to update panscan on fullscreen/windowed switch - case VOCTRL_SET_PANSCAN: - if ( ( vo_fs && ( vo_panscan != vo_panscan_amount ) ) || ( !vo_fs && vo_panscan_amount ) ) - { - int old_y = vo_panscan_y; - panscan_calc(); + switch (request){ + case VOCTRL_GET_DEINTERLACE: + *(int*)data = bob_deinterlace; + return VO_TRUE; + case VOCTRL_SET_DEINTERLACE: + bob_deinterlace = *(int*)data; + return VO_TRUE; + case VOCTRL_QUERY_FORMAT: + return query_format(*((uint32_t*)data)); + case VOCTRL_DRAW_IMAGE: + return xvmc_draw_image((mp_image_t *)data); + case VOCTRL_GET_IMAGE: + return get_image((mp_image_t *)data); + //vo_xv + case VOCTRL_GUISUPPORT: + return VO_TRUE; + case VOCTRL_ONTOP: + vo_x11_ontop(); + return VO_TRUE; + case VOCTRL_FULLSCREEN: + vo_x11_fullscreen(); + // indended, fallthrough to update panscan on fullscreen/windowed switch + case VOCTRL_SET_PANSCAN: + if ( ( vo_fs && ( vo_panscan != vo_panscan_amount ) ) || ( !vo_fs && vo_panscan_amount ) ) + { + int old_y = vo_panscan_y; + panscan_calc(); - if(old_y != vo_panscan_y) - { - //this also draws the colorkey - put_xvmc_image(p_render_surface_visible,1); + if(old_y != vo_panscan_y) + { + //this also draws the colorkey + put_xvmc_image(p_render_surface_visible,1); + } } - } - return VO_TRUE; - case VOCTRL_GET_PANSCAN: - if ( !vo_config_count || !vo_fs ) return VO_FALSE; - return VO_TRUE; - case VOCTRL_SET_EQUALIZER: - { - va_list ap; - int value; + return VO_TRUE; + case VOCTRL_GET_PANSCAN: + if ( !vo_config_count || !vo_fs ) return VO_FALSE; + return VO_TRUE; + case VOCTRL_SET_EQUALIZER: + { + va_list ap; + int value; - va_start(ap, data); - value = va_arg(ap, int); - va_end(ap); + va_start(ap, data); + value = va_arg(ap, int); + va_end(ap); + + return vo_xv_set_eq(xv_port, data, value); + } - return vo_xv_set_eq(xv_port, data, value); - } - - case VOCTRL_GET_EQUALIZER: - { - va_list ap; - int *value; + case VOCTRL_GET_EQUALIZER: + { + va_list ap; + int *value; - va_start(ap, data); - value = va_arg(ap, int*); - va_end(ap); + va_start(ap, data); + value = va_arg(ap, int*); + va_end(ap); - return vo_xv_get_eq(xv_port, data, value); - } - case VOCTRL_UPDATE_SCREENINFO: - update_xinerama_info(); - return VO_TRUE; - } + return vo_xv_get_eq(xv_port, data, value); + } + case VOCTRL_UPDATE_SCREENINFO: + update_xinerama_info(); + return VO_TRUE; + } return VO_NOTIMPL; }