comparison libvo/vo_fbdev.c @ 10578:b9d289fd8a57

10000l, the old code was slow as hell, copying stuff extra times and actually broken -- blanking the whole screen at each 'page flip' with -dr enabled. benchmarks: before: 56% cpu for decode 56% cpu for vo with no -dr 25% cpu for vo with -dr after: 56% cpu for decode 25% cpu for vo without -dr 0% cpu for vo with -dr if vo_fbdev is going to do pageflip, it needs to do it for REAL, using vertical scroll registers (like g2), not copying a temp buffer (which will shear anyway and is super-slow).
author rfelker
date Tue, 12 Aug 2003 08:24:24 +0000
parents e4cdc9ca94c5
children 7901f7d6e0eb
comparison
equal deleted inserted replaced
10577:7e5733a8c33b 10578:b9d289fd8a57
557 static int fb_yres; 557 static int fb_yres;
558 static void (*draw_alpha_p)(int w, int h, unsigned char *src, 558 static void (*draw_alpha_p)(int w, int h, unsigned char *src,
559 unsigned char *srca, int stride, unsigned char *dst, 559 unsigned char *srca, int stride, unsigned char *dst,
560 int dstride); 560 int dstride);
561 561
562 static uint8_t *next_frame;
563 static int in_width; 562 static int in_width;
564 static int in_height; 563 static int in_height;
565 static int out_width; 564 static int out_width;
566 static int out_height; 565 static int out_height;
567 static int first_row; 566 static int first_row;
948 } 947 }
949 948
950 fb_line_len = fb_finfo.line_length; 949 fb_line_len = fb_finfo.line_length;
951 fb_size = fb_finfo.smem_len; 950 fb_size = fb_finfo.smem_len;
952 frame_buffer = NULL; 951 frame_buffer = NULL;
953 next_frame = NULL;
954 #ifdef CONFIG_VIDIX 952 #ifdef CONFIG_VIDIX
955 if(vidix_name) 953 if(vidix_name)
956 { 954 {
957 unsigned image_width,image_height,x_offset,y_offset; 955 unsigned image_width,image_height,x_offset,y_offset;
958 if(zoom || fs){ 956 if(zoom || fs){
1000 998
1001 mp_msg(MSGT_VO, MSGL_DBG2, "frame_buffer @ %p\n", frame_buffer); 999 mp_msg(MSGT_VO, MSGL_DBG2, "frame_buffer @ %p\n", frame_buffer);
1002 mp_msg(MSGT_VO, MSGL_DBG2, "center @ %p\n", center); 1000 mp_msg(MSGT_VO, MSGL_DBG2, "center @ %p\n", center);
1003 mp_msg(MSGT_VO, MSGL_V, "pixel per line: %d\n", fb_line_len / fb_pixel_size); 1001 mp_msg(MSGT_VO, MSGL_V, "pixel per line: %d\n", fb_line_len / fb_pixel_size);
1004 1002
1005 if (!(next_frame = (uint8_t *) malloc(in_width * in_height * fb_pixel_size))) {
1006 mp_msg(MSGT_VO, MSGL_ERR, "Can't malloc next_frame: %s\n", strerror(errno));
1007 return 1;
1008 }
1009 if (fs || vm) 1003 if (fs || vm)
1010 memset(frame_buffer, '\0', fb_line_len * fb_yres); 1004 memset(frame_buffer, '\0', fb_line_len * fb_yres);
1011 } 1005 }
1012 if (vt_doit && (vt_fd = open("/dev/tty", O_WRONLY)) == -1) { 1006 if (vt_doit && (vt_fd = open("/dev/tty", O_WRONLY)) == -1) {
1013 mp_msg(MSGT_VO, MSGL_ERR, "can't open /dev/tty: %s\n", strerror(errno)); 1007 mp_msg(MSGT_VO, MSGL_ERR, "can't open /dev/tty: %s\n", strerror(errno));
1043 1037
1044 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, 1038 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
1045 unsigned char *srca, int stride) 1039 unsigned char *srca, int stride)
1046 { 1040 {
1047 unsigned char *dst; 1041 unsigned char *dst;
1048 int dstride; 1042
1049 1043 dst = center + (fb_line_len * y0 + x0) * fb_pixel_size;
1050 dst = next_frame + (in_width * y0 + x0) * fb_pixel_size; 1044
1051 dstride = in_width * fb_pixel_size; 1045 (*draw_alpha_p)(w, h, src, srca, stride, dst, fb_line_len);
1052
1053 (*draw_alpha_p)(w, h, src, srca, stride, dst, dstride);
1054 } 1046 }
1055 1047
1056 static uint32_t draw_frame(uint8_t *src[]) { return 1; } 1048 static uint32_t draw_frame(uint8_t *src[]) { return 1; }
1057 1049
1058 static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, int x, 1050 static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, int x,
1059 int y) 1051 int y)
1060 { 1052 {
1061 uint8_t *d; 1053 uint8_t *d;
1062 uint8_t *s; 1054 uint8_t *s;
1063 int next; 1055
1064 1056 d = center + (fb_line_len * y + x) * fb_pixel_size;
1065 d = next_frame + (in_width * y + x) * fb_pixel_size;
1066 next = in_width * fb_pixel_size;
1067 1057
1068 s = src[0]; 1058 s = src[0];
1069 while (h) { 1059 while (h) {
1070 memcpy(d, s, w * fb_pixel_size); 1060 memcpy(d, s, w * fb_pixel_size);
1071 d += next; 1061 d += fb_line_len;
1072 s += stride[0]; 1062 s += stride[0];
1073 h--; 1063 h--;
1074 } 1064 }
1075 1065
1076 return 0; 1066 return 0;
1080 { 1070 {
1081 } 1071 }
1082 1072
1083 static void flip_page(void) 1073 static void flip_page(void)
1084 { 1074 {
1085 int i, out_offset = 0, in_offset = 0;
1086
1087 for (i = 0; i < in_height; i++) {
1088 memcpy(center + out_offset, next_frame + in_offset,
1089 in_width * fb_pixel_size);
1090 out_offset += fb_line_len;
1091 in_offset += in_width * fb_pixel_size;
1092 }
1093 } 1075 }
1094 1076
1095 static void draw_osd(void) 1077 static void draw_osd(void)
1096 { 1078 {
1097 vo_draw_text(in_width, in_height, draw_alpha); 1079 vo_draw_text(in_width, in_height, draw_alpha);
1102 if (fb_cmap_changed) { 1084 if (fb_cmap_changed) {
1103 if (ioctl(fb_dev_fd, FBIOPUTCMAP, &fb_oldcmap)) 1085 if (ioctl(fb_dev_fd, FBIOPUTCMAP, &fb_oldcmap))
1104 mp_msg(MSGT_VO, MSGL_WARN, "Can't restore original cmap\n"); 1086 mp_msg(MSGT_VO, MSGL_WARN, "Can't restore original cmap\n");
1105 fb_cmap_changed = 0; 1087 fb_cmap_changed = 0;
1106 } 1088 }
1107 if(next_frame) free(next_frame);
1108 if (ioctl(fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo)) 1089 if (ioctl(fb_dev_fd, FBIOGET_VSCREENINFO, &fb_vinfo))
1109 mp_msg(MSGT_VO, MSGL_WARN, "ioctl FBIOGET_VSCREENINFO: %s\n", strerror(errno)); 1090 mp_msg(MSGT_VO, MSGL_WARN, "ioctl FBIOGET_VSCREENINFO: %s\n", strerror(errno));
1110 fb_orig_vinfo.xoffset = fb_vinfo.xoffset; 1091 fb_orig_vinfo.xoffset = fb_vinfo.xoffset;
1111 fb_orig_vinfo.yoffset = fb_vinfo.yoffset; 1092 fb_orig_vinfo.yoffset = fb_vinfo.yoffset;
1112 if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_orig_vinfo)) 1093 if (ioctl(fb_dev_fd, FBIOPUT_VSCREENINFO, &fb_orig_vinfo))
1118 if (vt_doit) 1099 if (vt_doit)
1119 vt_set_textarea(0, fb_orig_vinfo.yres); 1100 vt_set_textarea(0, fb_orig_vinfo.yres);
1120 close(fb_tty_fd); 1101 close(fb_tty_fd);
1121 close(fb_dev_fd); 1102 close(fb_dev_fd);
1122 if(frame_buffer) munmap(frame_buffer, fb_size); 1103 if(frame_buffer) munmap(frame_buffer, fb_size);
1123 frame_buffer = next_frame = NULL; 1104 frame_buffer = NULL;
1124 #ifdef CONFIG_VIDIX 1105 #ifdef CONFIG_VIDIX
1125 if(vidix_name) vidix_term(); 1106 if(vidix_name) vidix_term();
1126 #endif 1107 #endif
1127 fb_preinit(1); 1108 fb_preinit(1);
1128 } 1109 }