Ticket #1801: mplayer_vdpau-hack.diff
| File mplayer_vdpau-hack.diff, 9.1 KB (added by , 16 years ago) |
|---|
-
libvo/vo_vdpau.c
old new 72 72 mp_msg(MSGT_VO, MSGL_WARN, "[vdpau] %s: %s\n", \ 73 73 message, vdp_get_error_string(vdp_st)); 74 74 75 /* Round up to the next power of two */ 76 #define ROUND_POT(x) pow(2, ceil(log(x)/log(2))) 77 75 78 /* number of video and output surfaces */ 76 79 #define NUM_OUTPUT_SURFACES 3 77 80 #define MAX_VIDEO_SURFACES 50 … … 79 82 /* number of palette entries */ 80 83 #define PALETTE_SIZE 256 81 84 82 /* Initial maximum number of EOSD surfaces */ 83 #define EOSD_SURFACES_INITIAL 512 85 /* Initial maximum number of EOSD render targets */ 86 #define EOSD_TARGETS_INITIAL 512 87 88 /* Size of the surfaces the EOSD bitmaps will be placed into */ 89 #define EOSD_SURFACE_SIZE 512 84 90 85 91 /* 86 92 * Global variable declaration - VDPAU specific … … 188 194 // Pool of surfaces 189 195 struct { 190 196 VdpBitmapSurface surface; 191 int w ;192 int h;193 char in_use;197 int w, h; 198 int x, y; 199 int max_y; 194 200 } *eosd_surfaces; 195 201 196 202 // List of surfaces to be rendered … … 202 208 } *eosd_targets; 203 209 204 210 static int eosd_render_count; 205 static int eosd_surface_count; 211 static int eosd_surfaces_size; 212 static int eosd_targets_size; 206 213 207 214 // Video equalizer 208 215 static VdpProcamp procamp; … … 617 624 for (i = 0; i <= NUM_OUTPUT_SURFACES; i++) 618 625 output_surfaces[i] = VDP_INVALID_HANDLE; 619 626 vdp_device = VDP_INVALID_HANDLE; 620 for (i = 0; i < eosd_surface _count; i++)627 for (i = 0; i < eosd_surfaces_size; i++) 621 628 eosd_surfaces[i].surface = VDP_INVALID_HANDLE; 622 629 output_surface_width = output_surface_height = -1; 623 630 eosd_render_count = 0; … … 857 864 static void generate_eosd(EOSD_ImageList *imgs) 858 865 { 859 866 VdpStatus vdp_st; 860 VdpRect dest Rect;867 VdpRect dest_rect; 861 868 int j, found; 862 869 ASS_Image *img = imgs->imgs; 863 870 ASS_Image *i; … … 870 877 if (!img) 871 878 return; 872 879 873 if (imgs->changed == 1) 874 goto eosd_skip_upload; 875 876 for (j = 0; j < eosd_surface_count; j++) 877 eosd_surfaces[j].in_use = 0; 880 if (imgs->changed != 1) { 881 for (j = 0; j < eosd_surfaces_size; j++) { 882 eosd_surfaces[j].x = 0; 883 eosd_surfaces[j].y = 0; 884 eosd_surfaces[j].max_y = 0; 885 } 878 886 879 887 for (i = img; i; i = i->next) { 880 // Try to reuse a suitable surface888 // Find surface with enough free space 881 889 found = -1; 882 for (j = 0; j < eosd_surface _count; j++) {883 if ( eosd_surfaces[j].surface != VDP_INVALID_HANDLE && !eosd_surfaces[j].in_use &&884 eosd_surfaces[j].w >= i->w && eosd_surfaces[j].h >= i->h) {890 for (j = 0; j < eosd_surfaces_size; j++) { 891 if ((eosd_surfaces[j].y + i->h < eosd_surfaces[j].h && eosd_surfaces[j].x + i->w < eosd_surfaces[j].w) 892 || (eosd_surfaces[j].max_y + i->h < eosd_surfaces[j].h)) { 885 893 found = j; 886 894 break; 887 895 } 888 896 } 889 // No ne found,allocate a new surface897 // No free space; allocate a new surface 890 898 if (found < 0) { 891 for (j = 0; j < eosd_surface_count; j++) { 892 if (!eosd_surfaces[j].in_use) { 893 if (eosd_surfaces[j].surface != VDP_INVALID_HANDLE) 894 vdp_bitmap_surface_destroy(eosd_surfaces[j].surface); 895 found = j; 896 break; 897 } 898 } 899 // Allocate new space for surface/target arrays 900 if (found < 0) { 901 j = found = eosd_surface_count; 902 eosd_surface_count = eosd_surface_count ? eosd_surface_count*2 : EOSD_SURFACES_INITIAL; 903 eosd_surfaces = realloc(eosd_surfaces, eosd_surface_count * sizeof(*eosd_surfaces)); 904 eosd_targets = realloc(eosd_targets, eosd_surface_count * sizeof(*eosd_targets)); 905 for (j = found; j < eosd_surface_count; j++) { 906 eosd_surfaces[j].surface = VDP_INVALID_HANDLE; 907 eosd_surfaces[j].in_use = 0; 908 } 909 } 899 found = eosd_surfaces_size; 900 eosd_surfaces = realloc(eosd_surfaces, ++eosd_surfaces_size * sizeof(*eosd_surfaces)); 901 eosd_surfaces[found].w = (i->w <= EOSD_SURFACE_SIZE) ? EOSD_SURFACE_SIZE : ROUND_POT(i->w); 902 eosd_surfaces[found].h = (i->h <= EOSD_SURFACE_SIZE) ? EOSD_SURFACE_SIZE : ROUND_POT(i->h); 903 eosd_surfaces[found].x = eosd_surfaces[found].y = 0; 904 eosd_surfaces[found].max_y = 0; 905 printf("allocate %d (%dx%d)\n", found, eosd_surfaces[found].w, eosd_surfaces[found].h); 910 906 vdp_st = vdp_bitmap_surface_create(vdp_device, VDP_RGBA_FORMAT_A8, 911 i->w, i->h, VDP_TRUE, &eosd_surfaces[found].surface);907 eosd_surfaces[found].w, eosd_surfaces[found].h, VDP_TRUE, &eosd_surfaces[found].surface); 912 908 CHECK_ST_WARNING("EOSD: error when creating surface") 913 eosd_surfaces[found].w = i->w;914 eosd_surfaces[found].h = i->h;915 909 } 916 eosd_surfaces[found].in_use = 1; 910 // Allocate new space for targets, if needed 911 if (eosd_render_count >= eosd_targets_size) { 912 eosd_targets_size = eosd_targets_size ? eosd_targets_size*2 : EOSD_TARGETS_INITIAL; 913 eosd_targets = realloc(eosd_targets, eosd_targets_size * sizeof(*eosd_targets)); 914 } 915 // Set up render target 916 if ((eosd_surfaces[found].x + i->w) > eosd_surfaces[found].w) { 917 eosd_surfaces[found].y = eosd_surfaces[found].max_y; 918 eosd_surfaces[found].x = 0; 919 } 920 dest_rect.x0 = eosd_surfaces[found].x; 921 dest_rect.y0 = eosd_surfaces[found].y; 922 dest_rect.x1 = dest_rect.x0 + i->w; 923 dest_rect.y1 = dest_rect.y0 + i->h; 924 eosd_surfaces[found].max_y = FFMAX(eosd_surfaces[found].max_y, eosd_surfaces[found].y + i->h); 925 eosd_surfaces[found].x += i->w; 926 // Render destination and color 917 927 eosd_targets[eosd_render_count].surface = eosd_surfaces[found].surface; 918 destRect.x0 = 0; 919 destRect.y0 = 0; 920 destRect.x1 = i->w; 921 destRect.y1 = i->h; 922 vdp_st = vdp_bitmap_surface_putbits_native(eosd_targets[eosd_render_count].surface, 923 (const void *) &i->bitmap, &i->stride, &destRect); 928 eosd_targets[eosd_render_count].source.x0 = dest_rect.x0; 929 eosd_targets[eosd_render_count].source.y0 = dest_rect.y0; 930 eosd_targets[eosd_render_count].source.x1 = dest_rect.x1; 931 eosd_targets[eosd_render_count].source.y1 = dest_rect.y1; 932 eosd_targets[eosd_render_count].color.alpha = 1.0 - ((i->color >> 0) & 0xff) / 255.0; 933 eosd_targets[eosd_render_count].color.blue = ((i->color >> 8) & 0xff) / 255.0; 934 eosd_targets[eosd_render_count].color.green = ((i->color >> 16) & 0xff) / 255.0; 935 eosd_targets[eosd_render_count].color.red = ((i->color >> 24) & 0xff) / 255.0; 936 vdp_st = vdp_bitmap_surface_putbits_native(eosd_surfaces[found].surface, 937 (const void *) &i->bitmap, &i->stride, &dest_rect); 924 938 CHECK_ST_WARNING("EOSD: putbits failed") 925 939 eosd_render_count++; 926 940 } 941 } 927 942 928 eosd_skip_upload:929 943 eosd_render_count = 0; 930 for (i = img; i; i = i->next) { 931 // Render dest, color, etc. 932 eosd_targets[eosd_render_count].color.alpha = 1.0 - ((i->color >> 0) & 0xff) / 255.0; 933 eosd_targets[eosd_render_count].color.blue = ((i->color >> 8) & 0xff) / 255.0; 934 eosd_targets[eosd_render_count].color.green = ((i->color >> 16) & 0xff) / 255.0; 935 eosd_targets[eosd_render_count].color.red = ((i->color >> 24) & 0xff) / 255.0; 944 for(i = img; i; i = i->next) { 936 945 eosd_targets[eosd_render_count].dest.x0 = i->dst_x; 937 946 eosd_targets[eosd_render_count].dest.y0 = i->dst_y; 938 947 eosd_targets[eosd_render_count].dest.x1 = i->w + i->dst_x; 939 948 eosd_targets[eosd_render_count].dest.y1 = i->h + i->dst_y; 940 eosd_targets[eosd_render_count].source.x0 = 0;941 eosd_targets[eosd_render_count].source.y0 = 0;942 eosd_targets[eosd_render_count].source.x1 = i->w;943 eosd_targets[eosd_render_count].source.y1 = i->h;944 949 eosd_render_count++; 945 950 } 946 951 } … … 1135 1140 CHECK_ST_WARNING("Error when calling vdp_output_surface_destroy") 1136 1141 } 1137 1142 1138 for (i = 0; i<eosd_surface_count; i++) { 1139 if (eosd_surfaces[i].surface != VDP_INVALID_HANDLE) { 1140 vdp_st = vdp_bitmap_surface_destroy(eosd_surfaces[i].surface); 1141 CHECK_ST_WARNING("Error when calling vdp_bitmap_surface_destroy") 1142 } 1143 eosd_surfaces[i].surface = VDP_INVALID_HANDLE; 1143 for (i = 0; i < eosd_surfaces_size; i++) { 1144 vdp_st = vdp_bitmap_surface_destroy(eosd_surfaces[i].surface); 1145 CHECK_ST_WARNING("Error when calling vdp_bitmap_surface_destroy") 1144 1146 } 1145 1147 1146 1148 vdp_st = vdp_device_destroy(vdp_device); … … 1268 1270 index_data = NULL; 1269 1271 index_data_size = 0; 1270 1272 1271 eosd_surface _count= eosd_render_count = 0;1273 eosd_surfaces_size = eosd_targets_size = eosd_render_count = 0; 1272 1274 eosd_surfaces = NULL; 1273 1275 eosd_targets = NULL; 1274 1276
