Ticket #6514: myth-direct-xv.patch
File myth-direct-xv.patch, 10.6 KB (added by , 15 years ago) |
---|
-
videoout_xv.cpp
diff -Naur libmythtv-orig/videoout_xv.cpp libmythtv/videoout_xv.cpp
old new 116 116 xvmc_osd_lock(false), 117 117 xvmc_tex(NULL), 118 118 119 xv_port(-1), xv_ hue_base(0),119 xv_port(-1), xv_using_shm(true), xv_hue_base(0), 120 120 xv_colorkey(0), xv_draw_colorkey(false), 121 121 xv_chroma(0), 122 122 … … 2039 2039 vector<unsigned char*> VideoOutputXv::CreateShmImages(uint num, bool use_xv) 2040 2040 { 2041 2041 VERBOSE(VB_PLAYBACK, LOC + 2042 QString("CreateShmImages(%1): video_dim: %2x%3 ")2043 .arg(num).arg(video_dim.width()).arg(video_dim.height()) );2042 QString("CreateShmImages(%1): video_dim: %2x%3 (%4)") 2043 .arg(num).arg(video_dim.width()).arg(video_dim.height()).arg(xv_using_shm?"Shared":"Direct")); 2044 2044 2045 2045 vector<unsigned char*> bufs; 2046 2046 for (uint i = 0; i < num; i++) 2047 2047 { 2048 XShmSegmentInfo *info = new XShmSegmentInfo;2048 XShmSegmentInfo *info = 0; 2049 2049 void *image = NULL; 2050 2050 int size = 0; 2051 2051 int desiredsize = 0; 2052 2052 2053 if (!use_xv || xv_using_shm) 2054 info = new XShmSegmentInfo; 2055 2053 2056 X11L; 2054 2057 2055 2058 if (use_xv) 2056 2059 { 2057 XvImage *img = 2058 XvShmCreateImage(XJ_disp, xv_port, xv_chroma, 0, 2059 video_dim.width(), video_dim.height(), info); 2060 XvImage *img; 2061 if (xv_using_shm) 2062 img = XvShmCreateImage(XJ_disp, xv_port, xv_chroma, 0, 2063 video_dim.width(), video_dim.height(), info); 2064 else 2065 img = XvCreateImage (XJ_disp, xv_port, xv_chroma, 0, 2066 video_dim.width(), video_dim.height()); 2060 2067 size = img->data_size + 64; 2061 2068 image = img; 2062 2069 desiredsize = video_dim.width() * video_dim.height() * 3 / 2; … … 2068 2075 "requested size."); 2069 2076 XFree(image); 2070 2077 image = NULL; 2071 delete info; 2078 if (info != 0) 2079 delete info; 2072 2080 } 2073 2081 2074 2082 if (image && (3 == img->num_planes)) 2075 2083 { 2076 XJ_shm_infos.push_back(info); 2084 if (xv_using_shm) 2085 XJ_shm_infos.push_back(info); 2077 2086 YUVInfo tmp(img->width, img->height, img->data_size, 2078 2087 img->pitches, img->offsets); 2079 2088 if (xv_chroma == GUID_YV12_PLANAR) … … 2091 2100 "with the correct number of pixel planes."); 2092 2101 XFree(image); 2093 2102 image = NULL; 2094 delete info; 2103 if (info != 0) 2104 delete info; 2095 2105 } 2096 2106 } 2097 2107 else … … 2128 2138 2129 2139 if (image) 2130 2140 { 2131 XJ_shm_infos[i]->shmid = shmget(IPC_PRIVATE, size, IPC_CREAT|0777); 2132 if (XJ_shm_infos[i]->shmid >= 0) 2141 if (info != 0) 2133 2142 { 2134 XJ_shm_infos[i]->shmaddr = (char*) 2135 shmat(XJ_shm_infos[i]->shmid, 0, 0); 2136 if (use_xv) 2137 ((XvImage*)image)->data = XJ_shm_infos[i]->shmaddr; 2138 else 2139 ((XImage*)image)->data = XJ_shm_infos[i]->shmaddr; 2140 xv_buffers[(unsigned char*) XJ_shm_infos[i]->shmaddr] = image; 2141 XJ_shm_infos[i]->readOnly = False; 2143 XJ_shm_infos[i]->shmid = shmget(IPC_PRIVATE, size, IPC_CREAT|0777); 2144 if (XJ_shm_infos[i]->shmid >= 0) 2145 { 2146 XJ_shm_infos[i]->shmaddr = (char*) 2147 shmat(XJ_shm_infos[i]->shmid, 0, 0); 2148 if (use_xv) 2149 ((XvImage*)image)->data = XJ_shm_infos[i]->shmaddr; 2150 else 2151 ((XImage*)image)->data = XJ_shm_infos[i]->shmaddr; 2152 xv_buffers[(unsigned char*) XJ_shm_infos[i]->shmaddr] = image; 2153 XJ_shm_infos[i]->readOnly = False; 2142 2154 2143 X11L;2144 XShmAttach(XJ_disp, XJ_shm_infos[i]);2145 XSync(XJ_disp, False); // needed for FreeBSD?2146 X11U;2155 X11L; 2156 XShmAttach(XJ_disp, XJ_shm_infos[i]); 2157 XSync(XJ_disp, False); // needed for FreeBSD? 2158 X11U; 2147 2159 2148 // Mark for delete immediately.2149 // It won't actually be removed until after we detach it.2150 shmctl(XJ_shm_infos[i]->shmid, IPC_RMID, 0);2160 // Mark for delete immediately. 2161 // It won't actually be removed until after we detach it. 2162 shmctl(XJ_shm_infos[i]->shmid, IPC_RMID, 0); 2151 2163 2152 bufs.push_back((unsigned char*) XJ_shm_infos[i]->shmaddr); 2164 bufs.push_back((unsigned char*) XJ_shm_infos[i]->shmaddr); 2165 } 2166 else 2167 { 2168 VERBOSE(VB_IMPORTANT, LOC_ERR + 2169 "CreateXvShmImages(): shmget() failed." + ENO); 2170 break; 2171 } 2153 2172 } 2154 2173 else 2155 2174 { 2156 VERBOSE(VB_IMPORTANT, LOC_ERR + 2157 "CreateXvShmImages(): shmget() failed." + ENO); 2158 break; 2175 char* mbfr = (char*)malloc( ((XvImage*)image)->data_size ); 2176 if (mbfr != 0) 2177 { 2178 ((XvImage*)image)->data = mbfr; 2179 bufs.push_back((unsigned char*)mbfr); 2180 xv_buffers[(unsigned char*)mbfr] = image; 2181 } 2182 else 2183 { 2184 VERBOSE(VB_IMPORTANT, LOC_ERR + 2185 "CreateXvShmImages(): malloc failed."); 2186 break; 2187 } 2159 2188 } 2160 2189 } 2161 2190 else … … 2176 2205 ok = CreateXvMCBuffers(); 2177 2206 else if (subtype == XVideo && xv_port >= 0) 2178 2207 { 2179 vector<unsigned char*> bufs = 2180 CreateShmImages(vbuffers.allocSize(), true); 2181 2182 ok = (bufs.size() >= vbuffers.allocSize()) && 2183 vbuffers.CreateBuffers(video_dim.width(), video_dim.height(), 2208 vector<unsigned char*> bufs; 2209 xv_using_shm = true; 2210 bufs = CreateShmImages(vbuffers.allocSize(), true); 2211 vector<XErrorEvent> errs = UninstallXErrorHandler(XJ_disp); 2212 InstallXErrorHandler(XJ_disp); 2213 if (bufs.size() < vbuffers.allocSize() || errs.size()) 2214 { 2215 VERBOSE(VB_IMPORTANT, LOC + "Switch to Xv without Xshm"); 2216 DeleteBuffers(XVideo,true); 2217 UninstallXErrorHandler(XJ_disp); 2218 InstallXErrorHandler(XJ_disp); 2219 xv_using_shm = false; 2220 bufs = CreateShmImages(vbuffers.allocSize(), true); 2221 } 2222 if (bufs.size() >= vbuffers.allocSize()) 2223 ok = vbuffers.CreateBuffers(video_dim.width(), video_dim.height(), 2184 2224 bufs, XJ_yuv_infos); 2185 2225 else 2226 ok = false; 2186 2227 X11S(XSync(XJ_disp, False)); 2187 2228 } 2188 2229 else if (subtype == XShm || subtype == Xlib) … … 2199 2240 2200 2241 X11L; 2201 2242 2202 int bytes_per_line = XJ_depth / 8 * display_visible_rect.width();2243 int bytes_per_line; 2203 2244 int scrn = DefaultScreen(XJ_disp); 2204 2245 Visual *visual = DefaultVisual(XJ_disp, scrn); 2205 2246 XJ_non_xv_image = XCreateImage(XJ_disp, visual, XJ_depth, 2206 2247 ZPixmap, /*offset*/0, /*data*/0, 2207 2248 display_visible_rect.width(), 2208 2249 display_visible_rect.height(), 2209 /*bitmap_pad*/0, 2210 bytes_per_line); 2250 /*bitmap_pad*/8,0); 2211 2251 2212 2252 X11U; 2213 2253 … … 2218 2258 <<" " 2219 2259 <<"XJ_depth("<<XJ_depth<<") " 2220 2260 <<"WxH("<<display_visible_rect.width() 2221 <<"x"<<display_visible_rect.height()<<") " 2222 <<"bpl("<<bytes_per_line<<")"); 2261 <<"x"<<display_visible_rect.height()<<")"); 2223 2262 return false; 2224 2263 } 2264 bytes_per_line = XJ_non_xv_image->bytes_per_line; 2225 2265 XJ_non_xv_image->data = (char*) malloc( 2226 2266 bytes_per_line * display_visible_rect.height()); 2227 2267 } … … 2253 2293 2254 2294 if (ok) 2255 2295 CreatePauseFrame(subtype); 2256 2257 2296 return ok; 2258 2297 } 2259 2298 … … 3030 3069 vbuffers.LockFrame(frame, "ShowXVideo"); 3031 3070 int video_height = (3 != field) ? 3032 3071 (video_rect.height()/2) : video_rect.height(); 3033 X11S(XvShmPutImage(XJ_disp, xv_port, XJ_curwin, 3034 XJ_gc, image, 3035 video_rect.left(), src_y, 3036 video_rect.width(), video_height, 3037 display_video_rect.left(), dest_y, 3038 display_video_rect.width(), 3039 display_video_rect.height(), False)); 3072 if (xv_using_shm) 3073 { 3074 X11S(XvShmPutImage(XJ_disp, xv_port, XJ_curwin, 3075 XJ_gc, image, 3076 video_rect.left(), src_y, 3077 video_rect.width(), video_height, 3078 display_video_rect.left(), dest_y, 3079 display_video_rect.width(), 3080 display_video_rect.height(), False)); 3081 } 3082 else 3083 { 3084 X11S(XvPutImage (XJ_disp, xv_port, XJ_curwin, 3085 XJ_gc, image, 3086 video_rect.left(), src_y, 3087 video_rect.width(), video_height, 3088 display_video_rect.left(), dest_y, 3089 display_video_rect.width(), 3090 display_video_rect.height() )); 3091 } 3040 3092 vbuffers.UnlockFrame(frame, "ShowXVideo"); 3041 3093 } 3042 3094 } -
videoout_xv.h
diff -Naur libmythtv-orig/videoout_xv.h libmythtv/videoout_xv.h
old new 253 253 254 254 // Basic Xv drawing info 255 255 int xv_port; 256 bool xv_using_shm; 256 257 int xv_hue_base; 257 258 int xv_colorkey; 258 259 bool xv_draw_colorkey;