comparison libvo/vo_xvmc.c @ 28568:1a90167d9f0e

The xvmc_pixfmt_render structure was renamed to xvmc_pix_fmt in FFmpeg.
author diego
date Sun, 15 Feb 2009 17:49:42 +0000
parents a0374525d6ad
children fb881ea1a985
comparison
equal deleted inserted replaced
28567:a0374525d6ad 28568:1a90167d9f0e
96 static XvMCMacroBlockArray mv_blocks; 96 static XvMCMacroBlockArray mv_blocks;
97 97
98 #define MAX_SURFACES 8 98 #define MAX_SURFACES 8
99 static int number_of_surfaces=0; 99 static int number_of_surfaces=0;
100 static XvMCSurface surface_array[MAX_SURFACES]; 100 static XvMCSurface surface_array[MAX_SURFACES];
101 static struct xvmc_pixfmt_render * surface_render; 101 static struct xvmc_pix_fmt *surface_render;
102 102
103 static struct xvmc_pixfmt_render * p_render_surface_to_show=NULL; 103 static struct xvmc_pix_fmt *p_render_surface_to_show = NULL;
104 static struct xvmc_pixfmt_render * p_render_surface_visible=NULL; 104 static struct xvmc_pix_fmt *p_render_surface_visible = NULL;
105 105
106 //display queue, kinda render ahead 106 //display queue, kinda render ahead
107 static struct xvmc_pixfmt_render * show_queue[MAX_SURFACES]; 107 static struct xvmc_pix_fmt *show_queue[MAX_SURFACES];
108 static int free_element; 108 static int free_element;
109 109
110 110
111 static void (*draw_osd_fnc)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride); 111 static void (*draw_osd_fnc)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride);
112 static void (*clear_osd_fnc)(int x0,int y0, int w,int h); 112 static void (*clear_osd_fnc)(int x0,int y0, int w,int h);
130 }; 130 };
131 131
132 static void xvmc_free(void); 132 static void xvmc_free(void);
133 static void xvmc_clean_surfaces(void); 133 static void xvmc_clean_surfaces(void);
134 static int count_free_surfaces(void); 134 static int count_free_surfaces(void);
135 static struct xvmc_pixfmt_render * find_free_surface(void); 135 static struct xvmc_pix_fmt *find_free_surface(void);
136 136
137 static const vo_info_t info = { 137 static const vo_info_t info = {
138 "XVideo Motion Compensation", 138 "XVideo Motion Compensation",
139 "xvmc", 139 "xvmc",
140 "Ivan Kalvachev <iive@users.sf.net>", 140 "Ivan Kalvachev <iive@users.sf.net>",
358 mc_surf_list[s].surface_type_id,p,i); 358 mc_surf_list[s].surface_type_id,p,i);
359 return mc_surf_list[s].surface_type_id; 359 return mc_surf_list[s].surface_type_id;
360 } 360 }
361 361
362 static uint32_t xvmc_draw_image(mp_image_t *mpi){ 362 static uint32_t xvmc_draw_image(mp_image_t *mpi){
363 struct xvmc_pixfmt_render * rndr; 363 struct xvmc_pix_fmt *rndr;
364 364
365 assert(mpi!=NULL); 365 assert(mpi!=NULL);
366 assert(mpi->flags &MP_IMGFLAG_DIRECT); 366 assert(mpi->flags &MP_IMGFLAG_DIRECT);
367 // assert(mpi->flags &MP_IMGFLAGS_DRAWBACK); 367 // assert(mpi->flags &MP_IMGFLAGS_DRAWBACK);
368 368
369 rndr = (struct xvmc_pixfmt_render*)mpi->priv;//there is copy in plane[2] 369 rndr = (struct xvmc_pix_fmt*)mpi->priv; //there is copy in plane[2]
370 assert( rndr != NULL ); 370 assert( rndr != NULL );
371 assert( rndr->unique_id == AV_XVMC_RENDER_MAGIC ); 371 assert( rndr->unique_id == AV_XVMC_RENDER_MAGIC );
372 if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) 372 if( mp_msg_test(MSGT_VO,MSGL_DBG4) )
373 printf("vo_xvmc: draw_image(show rndr=%p)\n",rndr); 373 printf("vo_xvmc: draw_image(show rndr=%p)\n",rndr);
374 // the surface have passed vf system without been skiped, it will be displayed 374 // the surface have passed vf system without been skiped, it will be displayed
516 return -1; 516 return -1;
517 } 517 }
518 printf("vo_xvmc: mv_blocks allocated\n"); 518 printf("vo_xvmc: mv_blocks allocated\n");
519 519
520 if(surface_render==NULL) 520 if(surface_render==NULL)
521 surface_render=malloc(MAX_SURFACES*sizeof(struct xvmc_pixfmt_render));//easy mem debug 521 surface_render = malloc(MAX_SURFACES * sizeof(struct xvmc_pix_fmt)); //easy mem debug
522 memset(surface_render,0,MAX_SURFACES*sizeof(struct xvmc_pixfmt_render)); 522 memset(surface_render, 0, MAX_SURFACES * sizeof(struct xvmc_pix_fmt));
523 523
524 for(i=0; i<MAX_SURFACES; i++){ 524 for(i=0; i<MAX_SURFACES; i++){
525 rez=XvMCCreateSurface(mDisplay,&ctx,&surface_array[i]); 525 rez=XvMCCreateSurface(mDisplay,&ctx,&surface_array[i]);
526 if( rez != Success ) 526 if( rez != Success )
527 break; 527 break;
838 assert(0); 838 assert(0);
839 } 839 }
840 } 840 }
841 841
842 static void draw_osd(void){ 842 static void draw_osd(void){
843 struct xvmc_pixfmt_render * osd_rndr; 843 struct xvmc_pix_fmt *osd_rndr;
844 int osd_has_changed; 844 int osd_has_changed;
845 int have_osd_to_draw; 845 int have_osd_to_draw;
846 int rez; 846 int rez;
847 847
848 if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) 848 if( mp_msg_test(MSGT_VO,MSGL_DBG4) )
932 } 932 }
933 933
934 XvMCSyncSurface(mDisplay, srf); 934 XvMCSyncSurface(mDisplay, srf);
935 } 935 }
936 936
937 static void put_xvmc_image(struct xvmc_pixfmt_render * p_render_surface, 937 static void put_xvmc_image(struct xvmc_pix_fmt *p_render_surface,
938 int draw_ck){ 938 int draw_ck){
939 int rez; 939 int rez;
940 struct vo_rect src_rect, dst_rect; 940 struct vo_rect src_rect, dst_rect;
941 int i; 941 int i;
942 942
1053 (p_render_surface_visible != &surface_render[i]) ) 1053 (p_render_surface_visible != &surface_render[i]) )
1054 printf("vo_xvmc::uninit surface_render[%d].status=%d\n",i, 1054 printf("vo_xvmc::uninit surface_render[%d].status=%d\n",i,
1055 surface_render[i].state); 1055 surface_render[i].state);
1056 } 1056 }
1057 1057
1058 memset(surface_render,0,MAX_SURFACES*sizeof(struct xvmc_pixfmt_render));//for debuging 1058 memset(surface_render, 0, MAX_SURFACES * sizeof(struct xvmc_pix_fmt)); //for debugging
1059 free(surface_render);surface_render=NULL; 1059 free(surface_render);surface_render=NULL;
1060 1060
1061 XvMCDestroyContext(mDisplay,&ctx); 1061 XvMCDestroyContext(mDisplay,&ctx);
1062 number_of_surfaces = 0; 1062 number_of_surfaces = 0;
1063 1063
1109 } 1109 }
1110 1110
1111 1111
1112 static int draw_slice(uint8_t *image[], int stride[], 1112 static int draw_slice(uint8_t *image[], int stride[],
1113 int w, int h, int x, int y){ 1113 int w, int h, int x, int y){
1114 struct xvmc_pixfmt_render * rndr; 1114 struct xvmc_pix_fmt *rndr;
1115 int rez; 1115 int rez;
1116 1116
1117 if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) 1117 if( mp_msg_test(MSGT_VO,MSGL_DBG4) )
1118 printf("vo_xvmc: draw_slice y=%d\n",y); 1118 printf("vo_xvmc: draw_slice y=%d\n",y);
1119 1119
1120 rndr = (struct xvmc_pixfmt_render*)image[2];//this is copy of priv-ate 1120 rndr = (struct xvmc_pix_fmt*)image[2]; //this is copy of priv-ate
1121 assert( rndr != NULL ); 1121 assert( rndr != NULL );
1122 assert( rndr->unique_id == AV_XVMC_RENDER_MAGIC ); 1122 assert( rndr->unique_id == AV_XVMC_RENDER_MAGIC );
1123 1123
1124 rez = XvMCRenderSurface(mDisplay,&ctx,rndr->picture_structure, 1124 rez = XvMCRenderSurface(mDisplay,&ctx,rndr->picture_structure,
1125 rndr->p_surface, 1125 rndr->p_surface,
1169 return VO_TRUE; 1169 return VO_TRUE;
1170 } 1170 }
1171 1171
1172 //XvMCHide hides the surface on next retrace, so 1172 //XvMCHide hides the surface on next retrace, so
1173 //check if the surface is not still displaying 1173 //check if the surface is not still displaying
1174 static void check_osd_source(struct xvmc_pixfmt_render * src_rndr){ 1174 static void check_osd_source(struct xvmc_pix_fmt *src_rndr) {
1175 struct xvmc_pixfmt_render * osd_rndr; 1175 struct xvmc_pix_fmt *osd_rndr;
1176 int stat; 1176 int stat;
1177 //If this is source surface, check does the OSD rendering is compleate 1177 //If this is source surface, check does the OSD rendering is compleate
1178 if(src_rndr->state & AV_XVMC_STATE_OSD_SOURCE){ 1178 if(src_rndr->state & AV_XVMC_STATE_OSD_SOURCE){
1179 if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) 1179 if( mp_msg_test(MSGT_VO,MSGL_DBG4) )
1180 printf("vo_xvmc: OSD surface=%p quering\n",src_rndr); 1180 printf("vo_xvmc: OSD surface=%p quering\n",src_rndr);
1193 num++; 1193 num++;
1194 } 1194 }
1195 return num; 1195 return num;
1196 } 1196 }
1197 1197
1198 static struct xvmc_pixfmt_render * find_free_surface(void) { 1198 static struct xvmc_pix_fmt *find_free_surface(void) {
1199 int i,t; 1199 int i,t;
1200 int stat; 1200 int stat;
1201 struct xvmc_pixfmt_render * visible_rndr; 1201 struct xvmc_pix_fmt *visible_rndr;
1202 1202
1203 visible_rndr = NULL; 1203 visible_rndr = NULL;
1204 for(i=0; i<number_of_surfaces; i++){ 1204 for(i=0; i<number_of_surfaces; i++){
1205 1205
1206 check_osd_source(&surface_render[i]); 1206 check_osd_source(&surface_render[i]);
1246 } 1246 }
1247 free_element=0;//clean up the queue 1247 free_element=0;//clean up the queue
1248 } 1248 }
1249 1249
1250 static uint32_t get_image(mp_image_t *mpi){ 1250 static uint32_t get_image(mp_image_t *mpi){
1251 struct xvmc_pixfmt_render * rndr; 1251 struct xvmc_pix_fmt *rndr;
1252 1252
1253 rndr = find_free_surface(); 1253 rndr = find_free_surface();
1254 1254
1255 if(rndr == NULL){ 1255 if(rndr == NULL){
1256 printf("vo_xvmc: get_image failed\n"); 1256 printf("vo_xvmc: get_image failed\n");