static int get_colourkey( void ) { Atom atom; XvAttribute *attr; int value; int nattr; attr = XvQueryPortAttributes( display, xv_port, &nattr ); if( attr ) { if( nattr ) { int k; for( k = 0; k < nattr; k++ ) { if( (attr[ k ].flags & XvSettable) && (attr[ k ].flags & XvGettable)) { if( !strcmp( attr[ k ].name, "XV_COLORKEY" ) ) { atom = XInternAtom( display, "XV_COLORKEY", False ); if( atom != None ) { XvGetPortAttribute( display, xv_port, atom, &value ); XvSetPortAttribute( display, xv_port, atom, value ); XvGetPortAttribute( display, xv_port, atom, &value ); XFree( attr ); return value; } } } } } XFree( attr ); } return 0; }
/***************************************************************************** * XVideoSetAttribute ***************************************************************************** * This function can be used to set attributes, e.g. XV_BRIGHTNESS and * XV_CONTRAST. "f_value" should be in the range of 0 to 1. *****************************************************************************/ static void XVideoSetAttribute( vout_thread_t *p_vout, char *attr_name, float f_value ) { int i_attrib; XvAttribute *p_attrib; Display *p_display = p_vout->p_sys->p_display; int i_xvport = p_vout->p_sys->i_xvport; p_attrib = XvQueryPortAttributes( p_display, i_xvport, &i_attrib ); do { i_attrib--; if( i_attrib >= 0 && !strcmp( p_attrib[ i_attrib ].name, attr_name ) ) { int i_sv = f_value * ( p_attrib[ i_attrib ].max_value - p_attrib[ i_attrib ].min_value + 1 ) + p_attrib[ i_attrib ].min_value; XvSetPortAttribute( p_display, i_xvport, XInternAtom( p_display, attr_name, False ), i_sv ); break; } } while( i_attrib > 0 ); if( p_attrib ) XFree( p_attrib ); }
static void init_xv_settings(video_canvas_t *canvas) { /* Find XVideo color setting limits. */ if (canvas->videoconfig->hwscale && canvas->xv_image) { int i, j; int numattr = 0; Display *dpy = x11ui_get_display_ptr(); XvAttribute *attr = XvQueryPortAttributes(dpy, canvas->xv_port, &numattr); for (i = 0; i < (int)(sizeof(xv_settings)/sizeof(xv_settings[0])); i++) { xv_settings[i].atom = 0; for (j = 0; j < numattr; j++) { if (strcmp(xv_settings[i].name, attr[j].name) == 0) { xv_settings[i].atom = XInternAtom(dpy, xv_settings[i].name, False); xv_settings[i].min = attr[j].min_value; xv_settings[i].max = attr[j].max_value; break; } } } if (attr) { XFree(attr); } /* Apply color settings to XVideo. */ video_canvas_set_palette(canvas, canvas->palette); } }
void XVWindow::DumpCapabilities (int port) { XvImageFormatValues *xviformats = 0; XvAttribute *xvattributes = NULL; XvEncodingInfo *xveinfo = NULL; unsigned int numXveinfo = 0; unsigned int i = 0; int numXvattributes = 0; int j = 0; int numXviformats = 0; char info[512]; if (XvQueryEncodings (_display, port, &numXveinfo, &xveinfo) != Success) { PTRACE(4, "XVideo\tXvQueryEncodings failed\n"); return; } for (i = 0 ; i < numXveinfo ; i++) { PTRACE(4, "XVideo\tEncoding List for Port " << port << ": " << " id=" << xveinfo [i].encoding_id << " name=" << xveinfo [i].name << " size=" << xveinfo [i].width << "x" << xveinfo[i].height << " numerator=" << xveinfo [i].rate.numerator << " denominator=" << xveinfo [i].rate.denominator); } XvFreeEncodingInfo(xveinfo); PTRACE(4, "XVideo\tAttribute List for Port " << port << ":"); xvattributes = XvQueryPortAttributes (_display, port, &numXvattributes); for (j = 0 ; j < numXvattributes ; j++) { PTRACE(4, " �name: � � � " << xvattributes [j].name); PTRACE(4, " �flags: � � " << ((xvattributes [j].flags & XvGettable) ? " get" : "") << ((xvattributes [j].flags & XvSettable) ? " set" : "")); PTRACE(4, " �min_color: �" << xvattributes [j].min_value); PTRACE(4, " �max_color: �" << xvattributes [j].max_value); } if (xvattributes) XFree (xvattributes); PTRACE (4, "XVideo\tImage format list for Port " << port << ":"); xviformats = XvListImageFormats (_display, port, &numXviformats); for (j = 0 ; j < numXviformats ; j++) { sprintf (info, " 0x%x (%4.4s) %s, order: %s", xviformats [j].id, (char *) &xviformats [j].id, (xviformats [j].format == XvPacked) ? "packed" : "planar", xviformats [j].component_order); PTRACE(4, info); } if (xviformats) XFree (xviformats); }
static int xv_find_atom(struct vo *vo, uint32_t xv_port, const char *name, bool get, int *min, int *max) { Atom atom = None; int howmany = 0; XvAttribute *attributes = XvQueryPortAttributes(vo->x11->display, xv_port, &howmany); for (int i = 0; i < howmany && attributes; i++) { int flag = get ? XvGettable : XvSettable; if (attributes[i].flags & flag) { atom = XInternAtom(vo->x11->display, attributes[i].name, True); *min = attributes[i].min_value; *max = attributes[i].max_value; /* since we have SET_DEFAULTS first in our list, we can check if it's available then trigger it if it's ok so that the other values are at default upon query */ if (atom != None) { if (!strcmp(attributes[i].name, "XV_BRIGHTNESS") && (!strcasecmp(name, "brightness"))) break; else if (!strcmp(attributes[i].name, "XV_CONTRAST") && (!strcasecmp(name, "contrast"))) break; else if (!strcmp(attributes[i].name, "XV_SATURATION") && (!strcasecmp(name, "saturation"))) break; else if (!strcmp(attributes[i].name, "XV_HUE") && (!strcasecmp(name, "hue"))) break; if (!strcmp(attributes[i].name, "XV_RED_INTENSITY") && (!strcasecmp(name, "red_intensity"))) break; else if (!strcmp(attributes[i].name, "XV_GREEN_INTENSITY") && (!strcasecmp(name, "green_intensity"))) break; else if (!strcmp(attributes[i].name, "XV_BLUE_INTENSITY") && (!strcasecmp(name, "blue_intensity"))) break; else if ((!strcmp(attributes[i].name, "XV_ITURBT_709") //NVIDIA || !strcmp(attributes[i].name, "XV_COLORSPACE")) //ATI && (!strcasecmp(name, "bt_709"))) break; atom = None; continue; } } } XFree(attributes); return atom; }
static void init_xv_settings(video_canvas_t *canvas) { /* Find XVideo color setting limits. */ if (canvas->videoconfig->hwscale && canvas->xv_image) { int i, j; int numattr = 0; Display *dpy = x11ui_get_display_ptr(); XvAttribute *attr = XvQueryPortAttributes(dpy, canvas->xv_port, &numattr); xv_settings[0].value = &(canvas->videoconfig->video_resources.color_saturation); xv_settings[1].value = &(canvas->videoconfig->video_resources.color_contrast); xv_settings[2].value = &(canvas->videoconfig->video_resources.color_brightness); xv_settings[3].value = &(canvas->videoconfig->video_resources.color_gamma); for (i = 0; i < (int)util_arraysize(xv_settings); i++) { xv_settings[i].atom = 0; for (j = 0; j < numattr; j++) { if (!(attr[j].flags & XvSettable)) { continue; /* useless, can't be set */ } if (strcmp(xv_settings[i].name, attr[j].name) == 0) { xv_settings[i].atom = XInternAtom(dpy, xv_settings[i].name, False); xv_settings[i].min = attr[j].min_value; xv_settings[i].max = attr[j].max_value; if ((attr[j].flags & XvGettable) && !xv_settings[i].restore) { xv_settings[i].restore = (XvGetPortAttribute(dpy, canvas->xv_port, xv_settings[i].atom, &xv_settings[i].xv_default) == Success); if (!xv_settings[i].restore) { xv_settings[i].restore = 2; } } break; } } } if (attr) { XFree(attr); } /* Apply color settings to XVideo. */ video_canvas_set_palette(canvas, canvas->palette); } }
static Atom xv_intern_atom_if_exists(struct vo *vo, char const *atom_name) { struct xvctx *ctx = vo->priv; XvAttribute *attributes; int attrib_count, i; Atom xv_atom = None; attributes = XvQueryPortAttributes(vo->x11->display, ctx->xv_port, &attrib_count); if (attributes != NULL) { for (i = 0; i < attrib_count; ++i) { if (strcmp(attributes[i].name, atom_name) == 0) { xv_atom = XInternAtom(vo->x11->display, atom_name, False); break; } } XFree(attributes); } return xv_atom; }
uint8_t getAtom(char *string) { XvAttribute * attributes; int attrib_count,i; Atom xv_atom = None; attributes = XvQueryPortAttributes( xv_display, xv_port, &attrib_count ); if( attributes!=NULL ) { for ( i = 0; i < attrib_count; ++i ) { if ( strcmp(attributes[i].name, string ) == 0 ) { xv_atom = XInternAtom( xv_display, string, False ); break; // found what we want, break out } } XFree( attributes ); } return xv_atom; }
Atom XVWindow::GetXVAtom ( char const * name ) { XvAttribute * attributes; int numAttributes = 0; int i; Atom atom = None; attributes = XvQueryPortAttributes( _display, _XVPort, &numAttributes ); if( attributes != NULL ) { for ( i = 0; i < numAttributes; ++i ) { if ( strcmp(attributes[i].name, name ) == 0 ) { atom = XInternAtom( _display, name, False ); break; } } XFree( attributes ); } return atom; }
static int XVideoGetPort( Display *p_display, int32_t i_chroma, int i_requested_adaptor) // -1 for autoscan { XvAdaptorInfo *p_adaptor; unsigned int i; unsigned int i_adaptor, i_num_adaptors; int i_selected_port; switch( XvQueryExtension( p_display, &i, &i, &i, &i, &i ) ) { case Success: break; case XvBadExtension: ml_log_error("XvBadExtension\n" ); return -1; case XvBadAlloc: ml_log_error("XvBadAlloc\n" ); return -1; default: ml_log_error("XvQueryExtension failed\n" ); return -1; } switch( XvQueryAdaptors( p_display, DefaultRootWindow( p_display ), &i_num_adaptors, &p_adaptor ) ) { case Success: break; case XvBadExtension: ml_log_error("XvBadExtension for XvQueryAdaptors\n" ); return -1; case XvBadAlloc: ml_log_error("XvBadAlloc for XvQueryAdaptors\n" ); return -1; default: ml_log_error("XvQueryAdaptors failed\n" ); return -1; } i_selected_port = -1; for( i_adaptor = 0; i_adaptor < i_num_adaptors; ++i_adaptor ) { XvImageFormatValues *p_formats; int i_format, i_num_formats; int i_port; /* If we requested an adaptor and it's not this one, we aren't * interested */ if( i_requested_adaptor != -1 && i_adaptor != (unsigned int)i_requested_adaptor ) { continue; } /* If the adaptor doesn't have the required properties, skip it */ if( !( p_adaptor[ i_adaptor ].type & XvInputMask ) || !( p_adaptor[ i_adaptor ].type & XvImageMask ) ) { continue; } /* Check that adaptor supports our requested format... */ p_formats = XvListImageFormats( p_display, p_adaptor[i_adaptor].base_id, &i_num_formats ); for( i_format = 0; i_format < i_num_formats && ( i_selected_port == -1 ); i_format++ ) { XvAttribute *p_attr; int i_attr, i_num_attributes; /* Matching chroma? */ if( p_formats[ i_format ].id != i_chroma ) { continue; } /* Look for the first available port supporting this format */ for( i_port = p_adaptor[i_adaptor].base_id; ( i_port < (int)(p_adaptor[i_adaptor].base_id + p_adaptor[i_adaptor].num_ports) ) && ( i_selected_port == -1 ); i_port++ ) { if( XvGrabPort( p_display, i_port, CurrentTime ) == Success ) { i_selected_port = i_port; } } /* If no free port was found, forget it */ if( i_selected_port == -1 ) { continue; } /* If we found a port, print information about it */ ml_log_info("X11 display adaptor %i, port %i, format 0x%x (%4.4s) %s\n", i_adaptor, i_selected_port, p_formats[ i_format ].id, (char *)&p_formats[ i_format ].id, ( p_formats[ i_format ].format == XvPacked ) ? "packed" : "planar" ); /* Make sure XV_AUTOPAINT_COLORKEY is set */ p_attr = XvQueryPortAttributes( p_display, i_selected_port, &i_num_attributes ); for( i_attr = 0; i_attr < i_num_attributes; i_attr++ ) { if( !strcmp( p_attr[i_attr].name, "XV_AUTOPAINT_COLORKEY" ) ) { const Atom autopaint = XInternAtom( p_display, "XV_AUTOPAINT_COLORKEY", False ); XvSetPortAttribute( p_display, i_selected_port, autopaint, 1 ); break; } } if( p_attr != NULL ) { XFree( p_attr ); } } if( p_formats != NULL ) { XFree( p_formats ); } } if( i_num_adaptors > 0 ) { XvFreeAdaptorInfo( p_adaptor ); } if( i_selected_port == -1 ) { int i_chroma_tmp = X112VLC_FOURCC( i_chroma ); if( i_requested_adaptor == -1 ) { ml_log_error("no free XVideo port found for format: " "0x%.8x (%4.4s)\n", i_chroma_tmp, (char*)&i_chroma_tmp ); } else { ml_log_error("XVideo adaptor %i does not have a free: " "XVideo port for format 0x%.8x (%4.4s)\n", i_requested_adaptor, i_chroma_tmp, (char*)&i_chroma_tmp ); } } return i_selected_port; }
static int X11_GetXVideoPort(GF_VideoOutput *vout, u32 pixel_format, Bool check_color) { XWindow *xwin = (XWindow *)vout->opaque; Bool has_color_key = 0; XvAdaptorInfo *adaptors; unsigned int i; unsigned int nb_adaptors; int selected_port; if (XvQueryExtension(xwin->display, &i, &i, &i, &i, &i ) != Success) return -1; if (XvQueryAdaptors(xwin->display, DefaultRootWindow(xwin->display), &nb_adaptors, &adaptors) != Success) return -1; selected_port = -1; for (i=0; i < nb_adaptors; i++) { XvImageFormatValues *formats; int j, num_formats, port; if( !( adaptors[i].type & XvInputMask ) || !(adaptors[i].type & XvImageMask ) ) continue; /* Check for our format... */ formats = XvListImageFormats(xwin->display, adaptors[i].base_id, &num_formats); for (j=0; j<num_formats && (selected_port == -1 ); j++) { XvAttribute *attr; int k, nb_attributes; u32 pformat = X11_GetPixelFormat(formats[j].id); if( !is_same_yuv(pformat, pixel_format) ) continue; /* Grab first port supporting this format */ for (port=adaptors[i].base_id; (port < (int)(adaptors[i].base_id + adaptors[i].num_ports) ) && (selected_port == -1); port++) { if (port==xwin->xvport) continue; attr = XvQueryPortAttributes(xwin->display, port, &nb_attributes); for (k=0; k<nb_attributes; k++ ) { if (!strcmp(attr[k].name, "XV_COLORKEY")) { const Atom ckey = XInternAtom(xwin->display, "XV_COLORKEY", False); XvGetPortAttribute(xwin->display, port, ckey, &vout->overlay_color_key); has_color_key = 1; vout->overlay_color_key |= 0xFF000000; } /* else if (!strcmp(attr[k].name, "XV_AUTOPAINT_COLORKEY")) { const Atom paint = XInternAtom(xwin->display, "XV_AUTOPAINT_COLORKEY", False); XvSetPortAttribute(xwin->display, port, paint, 1); } */ } if (check_color && !has_color_key) continue; if (XvGrabPort(xwin->display, port, CurrentTime) == Success) { selected_port = port; xwin->xv_pf_format = formats[j].id; } } if (selected_port == -1 ) continue; } if (formats != NULL) XFree(formats); } if (nb_adaptors > 0) XvFreeAdaptorInfo(adaptors); return selected_port; }
int main (int argc, char* argv[]) { int yuv_width = 1024; int yuv_height = 768; int xv_port = -1; int adaptor, encodings, attributes, formats; int i, j, ret, p, _d, _w, _h; long secsb, secsa, frames; XvAdaptorInfo *ai; XvEncodingInfo *ei; XvAttribute *at; XvImageFormatValues *fo; XvImage *yuv_image; #define GUID_YUV12_PLANAR 0x32315659 unsigned int p_version, p_release, p_request_base, p_event_base, p_error_base; int p_num_adaptors; Display *dpy; Window window, _dw; XSizeHints hint; XSetWindowAttributes xswa; XVisualInfo vinfo; int screen; unsigned long mask; XEvent event; GC gc; /** for shm */ int shmem_flag = 0; XShmSegmentInfo yuv_shminfo; int CompletionType; printf("starting up video testapp...\n\n"); adaptor = -1; dpy = XOpenDisplay(NULL); if (dpy == NULL) { printf("Cannot open Display.\n"); exit (-1); } screen = DefaultScreen(dpy); /** find best display */ if (XMatchVisualInfo(dpy, screen, 24, TrueColor, &vinfo)) { printf(" found 24bit TrueColor\n"); } else if (XMatchVisualInfo(dpy, screen, 16, TrueColor, &vinfo)) { printf(" found 16bit TrueColor\n"); } else if (XMatchVisualInfo(dpy, screen, 15, TrueColor, &vinfo)) { printf(" found 15bit TrueColor\n"); } else if (XMatchVisualInfo(dpy, screen, 8, PseudoColor, &vinfo)) { printf(" found 8bit PseudoColor\n"); } else if (XMatchVisualInfo(dpy, screen, 8, GrayScale, &vinfo)) { printf(" found 8bit GrayScale\n"); } else if (XMatchVisualInfo(dpy, screen, 8, StaticGray, &vinfo)) { printf(" found 8bit StaticGray\n"); } else if (XMatchVisualInfo(dpy, screen, 1, StaticGray, &vinfo)) { printf(" found 1bit StaticGray\n"); } else { printf("requires 16 bit display\n"); exit (-1); } CompletionType = -1; hint.x = 1; hint.y = 1; hint.width = yuv_width; hint.height = yuv_height; hint.flags = PPosition | PSize; xswa.colormap = XCreateColormap(dpy, DefaultRootWindow(dpy), vinfo.visual, AllocNone); xswa.event_mask = StructureNotifyMask | ExposureMask; xswa.background_pixel = 0; xswa.border_pixel = 0; mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; window = XCreateWindow(dpy, DefaultRootWindow(dpy), 0, 0, yuv_width, yuv_height, 0, vinfo.depth, InputOutput, vinfo.visual, mask, &xswa); XStoreName(dpy, window, "XV"); XSetIconName(dpy, window, "XV"); XSelectInput(dpy, window, StructureNotifyMask); /** Map window */ XMapWindow(dpy, window); /** Wait for map. */ do { XNextEvent(dpy, &event); } while (event.type != MapNotify || event.xmap.event != window); if (XShmQueryExtension(dpy)) shmem_flag = 1; if (!shmem_flag) { printf("no shmem available.\n"); exit (-1); } if (shmem_flag==1) CompletionType = XShmGetEventBase(dpy) + ShmCompletion; /**--------------------------------- XV ------------------------------------*/ printf("beginning to parse the Xvideo extension...\n\n"); /** query and print Xvideo properties */ ret = XvQueryExtension(dpy, &p_version, &p_release, &p_request_base, &p_event_base, &p_error_base); if (ret != Success) { if (ret == XvBadExtension) printf("XvBadExtension returned at XvQueryExtension.\n"); else if (ret == XvBadAlloc) printf("XvBadAlloc returned at XvQueryExtension.\n"); else printf("other error happened at XvQueryExtension.\n"); } printf("========================================\n"); printf("XvQueryExtension returned the following:\n"); printf("p_version : %u\n", p_version); printf("p_release : %u\n", p_release); printf("p_request_base : %u\n", p_request_base); printf("p_event_base : %u\n", p_event_base); printf("p_error_base : %u\n", p_error_base); printf("========================================\n"); ret = XvQueryAdaptors(dpy, DefaultRootWindow(dpy), &p_num_adaptors, &ai); if (ret != Success) { if (ret == XvBadExtension) printf("XvBadExtension returned at XvQueryExtension.\n"); else if (ret == XvBadAlloc) printf("XvBadAlloc returned at XvQueryExtension.\n"); else printf("other error happaned at XvQueryAdaptors.\n"); } printf("=======================================\n"); printf("XvQueryAdaptors returned the following:\n"); printf("%d adaptors available.\n", p_num_adaptors); for (i = 0; i < p_num_adaptors; i++) { printf(" name: %s\n" " type: %s%s%s%s%s\n" " ports: %ld\n" " first port: %ld\n", ai[i].name, (ai[i].type & XvInputMask) ? "input | " : "", (ai[i].type & XvOutputMask) ? "output | " : "", (ai[i].type & XvVideoMask) ? "video | " : "", (ai[i].type & XvStillMask) ? "still | " : "", (ai[i].type & XvImageMask) ? "image | " : "", ai[i].num_ports, ai[i].base_id); xv_port = ai[i].base_id; printf("adaptor %d ; format list:\n", i); for (j = 0; j < ai[i].num_formats; j++) { printf(" depth=%d, visual=%ld\n", ai[i].formats[j].depth, ai[i].formats[j].visual_id); } for (p = ai[i].base_id; p < ai[i].base_id+ai[i].num_ports; p++) { printf(" encoding list for port %d\n", p); if (XvQueryEncodings(dpy, p, &encodings, &ei) != Success) { printf("XvQueryEncodings failed.\n"); continue; } for (j = 0; j < encodings; j++) { printf(" id=%ld, name=%s, size=%ldx%ld, numerator=%d, denominator=%d\n", ei[j].encoding_id, ei[j].name, ei[j].width, ei[j].height, ei[j].rate.numerator, ei[j].rate.denominator); } XvFreeEncodingInfo(ei); printf(" attribute list for port %d\n", p); at = XvQueryPortAttributes(dpy, p, &attributes); for (j = 0; j < attributes; j++) { printf(" name: %s\n" " flags: %s%s\n" " min_color: %i\n" " max_color: %i\n", at[j].name, (at[j].flags & XvGettable) ? " get" : "", (at[j].flags & XvSettable) ? " set" : "", at[j].min_value, at[j].max_value); } if (at) XFree(at); printf(" image format list for port %d\n", p); fo = XvListImageFormats(dpy, p, &formats); for (j = 0; j < formats; j++) { printf(" 0x%x (%4.4s) %s\n", fo[j].id, (char *)&fo[j].id, (fo[j].format == XvPacked) ? "packed" : "planar"); } if (fo) XFree(fo); } printf("\n"); } if (p_num_adaptors > 0) XvFreeAdaptorInfo(ai); if (xv_port == -1) exit (0); gc = XCreateGC(dpy, window, 0, 0); yuv_image = XvShmCreateImage(dpy, xv_port, GUID_YUV12_PLANAR, 0, yuv_width, yuv_height, &yuv_shminfo); yuv_shminfo.shmid = shmget(IPC_PRIVATE, yuv_image->data_size, IPC_CREAT | 0777); yuv_shminfo.shmaddr = yuv_image->data = shmat(yuv_shminfo.shmid, 0, 0); yuv_shminfo.readOnly = False; if (!XShmAttach(dpy, &yuv_shminfo)) { printf("XShmAttach failed !\n"); exit (-1); } for (i = 0; i < yuv_image->height; i++) { for (j = 0; j < yuv_image->width; j++) { yuv_image->data[yuv_image->width*i + j] = i*j; } } printf("%d\n", yuv_image->data_size); int joe = 0; while (1) { frames = secsa = secsb = 0; time(&secsa); while (frames < 200) { XGetGeometry(dpy, window, &_dw, &_d, &_d, &_w, &_h, &_d, &_d); for (i = 0; i < yuv_image->height * 1.5; i++) { for (j = 0; j < yuv_image->width; j++) { yuv_image->data[yuv_image->width*i + j] = (i + j + joe / 5); } } XvShmPutImage(dpy, xv_port, window, gc, yuv_image, 0, 0, yuv_image->width, yuv_image->height, 0, 0, _w, _h, True); /* XFlush(dpy); */ joe++; frames++; } time(&secsb); printf("%ld frames in %ld seconds; %.4f fps\n", frames, secsb-secsa, (double) frames/(secsb-secsa)); } return 0; }
int main(int argc, char *argv[]) { Display *dpy; unsigned int ver, rev, eventB, reqB, errorB; int i, j, k, n; unsigned int nencode, nadaptors; int nscreens, nattr, numImages; XvAdaptorInfo *ainfo; XvAttribute *attributes; XvEncodingInfo *encodings; XvFormat *format; XvImageFormatValues *formats; char *disname = NULL; char shortmode = 0; if ((argc > 4)) PrintUsage(); if (argc != 1) { for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-display")) { disname = argv[i + 1]; i++; } else if (!strcmp(argv[i], "-short")) shortmode = 1; else if (!strcmp(argv[i], "-version")) { printf("%s\n", PACKAGE_STRING); exit(0); } else { PrintUsage(); } } } if (!(dpy = XOpenDisplay(disname))) { fprintf(stderr, "xvinfo: Unable to open display %s\n", (disname != NULL) ? disname : XDisplayName(NULL)); exit(-1); } if ((Success != XvQueryExtension(dpy, &ver, &rev, &reqB, &eventB, &errorB))) { fprintf(stderr, "xvinfo: No X-Video Extension on %s\n", (disname != NULL) ? disname : XDisplayName(NULL)); exit(0); } else { fprintf(stdout, "X-Video Extension version %i.%i\n", ver, rev); } nscreens = ScreenCount(dpy); for (i = 0; i < nscreens; i++) { fprintf(stdout, "screen #%i\n", i); XvQueryAdaptors(dpy, RootWindow(dpy, i), &nadaptors, &ainfo); if (!nadaptors) { fprintf(stdout, " no adaptors present\n"); continue; } for (j = 0; j < nadaptors; j++) { fprintf(stdout, " Adaptor #%i: \"%s\"\n", j, ainfo[j].name); fprintf(stdout, " number of ports: %li\n", ainfo[j].num_ports); fprintf(stdout, " port base: %li\n", ainfo[j].base_id); fprintf(stdout, " operations supported: "); switch (ainfo[j].type & (XvInputMask | XvOutputMask)) { case XvInputMask: if (ainfo[j].type & XvVideoMask) fprintf(stdout, "PutVideo "); if (ainfo[j].type & XvStillMask) fprintf(stdout, "PutStill "); if (ainfo[j].type & XvImageMask) fprintf(stdout, "PutImage "); break; case XvOutputMask: if (ainfo[j].type & XvVideoMask) fprintf(stdout, "GetVideo "); if (ainfo[j].type & XvStillMask) fprintf(stdout, "GetStill "); break; default: fprintf(stdout, "none "); break; } fprintf(stdout, "\n"); format = ainfo[j].formats; if (!shortmode) { fprintf(stdout, " supported visuals:\n"); for (k = 0; k < ainfo[j].num_formats; k++, format++) { fprintf(stdout, " depth %i, visualID 0x%2lx\n", format->depth, format->visual_id); } } attributes = XvQueryPortAttributes(dpy, ainfo[j].base_id, &nattr); if (attributes && nattr) { fprintf(stdout, " number of attributes: %i\n", nattr); for (k = 0; k < nattr; k++) { fprintf(stdout, " \"%s\" (range %i to %i)\n", attributes[k].name, attributes[k].min_value, attributes[k].max_value); if (attributes[k].flags & XvSettable) { if (!shortmode) fprintf(stdout, " client settable attribute\n"); else fprintf(stdout, " settable"); } if (attributes[k].flags & XvGettable) { Atom the_atom; int value; if (!shortmode) fprintf(stdout, " client gettable attribute"); else fprintf(stdout, ", gettable"); the_atom = XInternAtom(dpy, attributes[k].name, True); if (the_atom != None) { if ((Success == XvGetPortAttribute(dpy, ainfo[j].base_id, the_atom, &value))) fprintf(stdout, " (current value is %i)", value); } fprintf(stdout, "\n"); } else if (shortmode) fprintf(stdout, "\n"); } XFree(attributes); } else { fprintf(stdout, " no port attributes defined\n"); } XvQueryEncodings(dpy, ainfo[j].base_id, &nencode, &encodings); if (encodings && nencode) { int ImageEncodings = 0; for (n = 0; n < nencode; n++) { if (!strcmp(encodings[n].name, "XV_IMAGE")) ImageEncodings++; } if (nencode - ImageEncodings) { fprintf(stdout, " number of encodings: %i\n", nencode - ImageEncodings); for (n = 0; n < nencode; n++) { if (strcmp(encodings[n].name, "XV_IMAGE")) { fprintf(stdout, " encoding ID #%li: \"%s\"\n", encodings[n].encoding_id, encodings[n].name); fprintf(stdout, " size: %li x %li\n", encodings[n].width, encodings[n].height); fprintf(stdout, " rate: %f\n", (float) encodings[n].rate.numerator / (float) encodings[n].rate.denominator); } } } if (ImageEncodings && (ainfo[j].type & XvImageMask)) { char imageName[5]; for (n = 0; n < nencode; n++) { if (!strcmp(encodings[n].name, "XV_IMAGE")) { fprintf(stdout, " maximum XvImage size: %li x %li\n", encodings[n].width, encodings[n].height); break; } } formats = XvListImageFormats(dpy, ainfo[j].base_id, &numImages); fprintf(stdout, " Number of image formats: %i\n", numImages); for (n = 0; n < numImages; n++) { sprintf(imageName, "%c%c%c%c", formats[n].id & 0xff, (formats[n].id >> 8) & 0xff, (formats[n].id >> 16) & 0xff, (formats[n].id >> 24) & 0xff); fprintf(stdout, " id: 0x%x", formats[n].id); if (isprint(imageName[0]) && isprint(imageName[1]) && isprint(imageName[2]) && isprint(imageName[3])) { fprintf(stdout, " (%s)\n", imageName); } else { fprintf(stdout, "\n"); } if (!shortmode) { fprintf(stdout, " guid: "); fprintf(stdout, "%02x", (unsigned char) formats[n].guid[0]); fprintf(stdout, "%02x", (unsigned char) formats[n].guid[1]); fprintf(stdout, "%02x", (unsigned char) formats[n].guid[2]); fprintf(stdout, "%02x-", (unsigned char) formats[n].guid[3]); fprintf(stdout, "%02x", (unsigned char) formats[n].guid[4]); fprintf(stdout, "%02x-", (unsigned char) formats[n].guid[5]); fprintf(stdout, "%02x", (unsigned char) formats[n].guid[6]); fprintf(stdout, "%02x-", (unsigned char) formats[n].guid[7]); fprintf(stdout, "%02x", (unsigned char) formats[n].guid[8]); fprintf(stdout, "%02x-", (unsigned char) formats[n].guid[9]); fprintf(stdout, "%02x", (unsigned char) formats[n].guid[10]); fprintf(stdout, "%02x", (unsigned char) formats[n].guid[11]); fprintf(stdout, "%02x", (unsigned char) formats[n].guid[12]); fprintf(stdout, "%02x", (unsigned char) formats[n].guid[13]); fprintf(stdout, "%02x", (unsigned char) formats[n].guid[14]); fprintf(stdout, "%02x\n", (unsigned char) formats[n].guid[15]); fprintf(stdout, " bits per pixel: %i\n", formats[n].bits_per_pixel); fprintf(stdout, " number of planes: %i\n", formats[n].num_planes); fprintf(stdout, " type: %s (%s)\n", (formats[n].type == XvRGB) ? "RGB" : "YUV", (formats[n].format == XvPacked) ? "packed" : "planar"); if (formats[n].type == XvRGB) { fprintf(stdout, " depth: %i\n", formats[n].depth); fprintf(stdout, " red, green, blue masks: " "0x%x, 0x%x, 0x%x\n", formats[n].red_mask, formats[n].green_mask, formats[n].blue_mask); } else { } } } if (formats) XFree(formats); } XvFreeEncodingInfo(encodings); } }
int xf_video_init(xfInfo * xfi) { unsigned int version; unsigned int release; unsigned int request_base; unsigned int event_base; unsigned int error_base; unsigned int num_adaptors; unsigned int i; int ret; XvAdaptorInfo * ai; XvAttribute * attr; XvImageFormatValues * fo; xfi->xv_colorkey_atom = None; xfi->xv_image_size = 0; if (!XShmQueryExtension(xfi->display)) { printf("xf_video_init: no shmem available.\n"); return 1; } ret = XvQueryExtension(xfi->display, &version, &release, &request_base, &event_base, &error_base); if (ret != Success) { printf("xf_video_init: XvQueryExtension failed %d.\n", ret); return 1; } printf("xf_video_init:"); printf(" version %u", version); printf(" release %u", release); printf("\n"); ret = XvQueryAdaptors(xfi->display, DefaultRootWindow(xfi->display), &num_adaptors, &ai); if (ret != Success) { printf("xf_video_init: XvQueryAdaptors failed %d.\n", ret); return 1; } for (i = 0; i < num_adaptors; i++) { printf("xf_video_init: adapter port %ld-%ld (%s)\n", ai[i].base_id, ai[i].base_id + ai[i].num_ports - 1, ai[i].name); if (xfi->xv_port == -1 && i == num_adaptors - 1) xfi->xv_port = ai[i].base_id; } if (num_adaptors > 0) XvFreeAdaptorInfo(ai); if (xfi->xv_port == -1) { printf("xf_video_init: no adapter selected, video frames will not be processed.\n"); return 1; } printf("xf_video_init: selected %ld\n", xfi->xv_port); attr = XvQueryPortAttributes(xfi->display, xfi->xv_port, &ret); for (i = 0; i < (unsigned int)ret; i++) { if (strcmp(attr[i].name, "XV_COLORKEY") == 0) { xfi->xv_colorkey_atom = XInternAtom(xfi->display, "XV_COLORKEY", False); XvSetPortAttribute(xfi->display, xfi->xv_port, xfi->xv_colorkey_atom, attr[i].min_value + 1); break; } } XFree(attr); printf("xf_video_init: pixel format "); fo = XvListImageFormats(xfi->display, xfi->xv_port, &ret); if (ret > 0) { xfi->xv_pixfmts = (uint32 *) malloc((ret + 1) * sizeof(uint32)); for (i = 0; i < ret; i++) { xfi->xv_pixfmts[i] = fo[i].id; printf("%c%c%c%c ", ((char*)(xfi->xv_pixfmts + i))[0], ((char*)(xfi->xv_pixfmts + i))[1], ((char*)(xfi->xv_pixfmts + i))[2], ((char*)(xfi->xv_pixfmts + i))[3]); } xfi->xv_pixfmts[i] = 0; } printf("\n"); return 0; }
int xv_init( xv_handle_t handle, Display *dpy, __u32 fourcc, int width, int height, int bpp ) { unsigned int version, release; unsigned int request_base, event_base, error_base; int i; if( XvQueryExtension( dpy, &version, &release, &request_base, &event_base, &error_base ) != Success ) { #ifdef DEBUG fprintf( stderr, "XvQueryExtension failed\n" ); #endif return -1; } if( XvQueryAdaptors( dpy, DefaultRootWindow( dpy ), &handle->num_adaptors, &handle->p_adaptor_info ) != Success ) { #ifdef DEBUG fprintf( stderr, "XvQueryAdaptors failed\n" ); #endif return -1; } /* printf( "%d adaptors found\n", handle->num_adaptors ); */ if( handle->num_adaptors == 0 ) { return -2; } for( i = 0; i < handle->num_adaptors; i++ ) { /* int format; */ unsigned int num_encodings; XvEncodingInfo *p_encoding_info; int encoding; XvAttribute *at; unsigned int num_attributes; int attribute; XvImageFormatValues *xvimage_formats; unsigned int num_xvimage_formats; int format; #ifdef DEBUG printf( "Adaptor: %d\n", i ); printf( "Name: %s\n", handle->p_adaptor_info[i].name ); printf( "Ports: %lu\n", handle->p_adaptor_info[i].num_ports ); printf( "Formats: %lu\n", handle->p_adaptor_info[i].num_formats ); for( format = 0; format < handle->p_adaptor_info[i].num_formats; format++ ) { printf( "+Format: %d\n", format ); printf( " +Depth: %d\n", handle->p_adaptor_info[i].formats[format].depth ); printf( " +VisualID: %lu\n", handle->p_adaptor_info[i].formats[format].visual_id ); } if( XvQueryEncodings( dpy, handle->p_adaptor_info[i].base_id, &num_encodings, &p_encoding_info ) != Success ) { fprintf( stderr, "XvQueryEncodings failed\n" ); } printf( " +num_encodings: %d\n", num_encodings ); for( encoding = 0; encoding < num_encodings; encoding++ ) { printf( " +Encoding: %d\n", encoding ); printf( " +Name: %s\n", p_encoding_info[encoding].name ); printf( " +Resolution: %lu x %lu\n", p_encoding_info[encoding].width, p_encoding_info[encoding].height ); } #endif //DEBUG at = XvQueryPortAttributes( dpy, handle->p_adaptor_info[i].base_id, &num_attributes ); #ifdef DEBUG printf( "num_attributes: %d\n", num_attributes ); #endif for( attribute = 0; attribute < num_attributes; attribute++ ) { int val; Atom atom; if( !strcmp( at[attribute].name, "XV_COLORKEY" ) ) { #ifdef DEBUG printf( "attribute: %d\n", attribute ); printf( "name: %s\n", at[attribute].name ); #endif atom = (Atom)XInternAtom( dpy, at[attribute].name, 0 ); #ifdef DEBUG printf( "atom: %p\n", atom ); #endif XvGetPortAttribute( dpy, handle->p_adaptor_info[i].base_id, atom, &val ); #ifdef DEBUG printf( "Attribute: %d\n", attribute ); printf( "Name: %s\n", at[attribute].name ); printf( "min: %x\n", at[attribute].min_value ); printf( "max: %x\n", at[attribute].max_value ); printf( "value: %x\n", val ); #endif handle->atom_colorkey = XInternAtom( dpy, at[attribute].name, 0 ); } if( !strcmp( at[attribute].name, "XV_BRIGHTNESS" ) ) { handle->atom_brightness = XInternAtom( dpy, at[attribute].name, 0 ); handle->brightness_min = at[attribute].min_value; handle->brightness_max = at[attribute].max_value; } if( !strcmp( at[attribute].name, "XV_HUE" ) ) { handle->atom_hue = XInternAtom( dpy, at[attribute].name, 0 ); handle->hue_min = at[attribute].min_value; handle->hue_max = at[attribute].max_value; } if( !strcmp( at[attribute].name, "XV_CONTRAST" ) ) { handle->atom_contrast = XInternAtom( dpy, at[attribute].name, 0 ); handle->contrast_min = at[attribute].min_value; handle->contrast_max = at[attribute].max_value; } if( !strcmp( at[attribute].name, "XV_DOUBLE_BUFFER" ) ) { Atom _atom; _atom = XInternAtom( dpy, at[attribute].name, 0 ); XvSetPortAttribute( dpy, handle->p_adaptor_info[i].base_id, _atom, 1 ); #ifdef DEBUG printf( "Xv: DOUBLE_BUFFER available\n" ); #endif } } xvimage_formats = XvListImageFormats( dpy, handle->p_adaptor_info[i].base_id, &num_xvimage_formats ); /* printf( "num_xvimage_formats: %d\n", num_xvimage_formats ); */ for( format = 0; format < num_xvimage_formats; format++ ) { char imageName[5] = {0, 0, 0, 0, 0}; memcpy(imageName, &(xvimage_formats[format].id), 4); #ifdef DEBUG fprintf(stdout, " id: 0x%x", xvimage_formats[format].id); #endif if( isprint( imageName[0]) && isprint(imageName[1]) && isprint( imageName[2]) && isprint(imageName[3])) { #ifdef DEBUG fprintf(stdout, " (%s)\n", imageName); #endif if( xvimage_formats[format].id == fourcc ) { handle->xv_mode_id = fourcc; break; } } else { #ifdef DEBUG fprintf(stdout, "\n"); #endif } } if( handle->xv_mode_id != fourcc ) { return -3; } if( XvGrabPort( dpy, handle->p_adaptor_info[i].base_id, CurrentTime ) != Success ) { /* fprintf( stderr, "Failed to grab port!\n" ); */ return -1; } } handle->use_shm = 1; if( handle->use_shm ) { memset( &handle->shminfo, 0, sizeof( XShmSegmentInfo ) ); handle->image = XvShmCreateImage( dpy, handle->p_adaptor_info[0].base_id, handle->xv_mode_id, (char*)NULL, width, height, &handle->shminfo ); if( handle->image ) { handle->shminfo.shmid = shmget( IPC_PRIVATE, handle->image->data_size, IPC_CREAT | 0777 ); if( handle->shminfo.shmid == -1 ) { /* fprintf( stderr, "shmget failed\n" ); */ return -1; } handle->shminfo.shmaddr = handle->image->data = shmat( handle->shminfo.shmid, 0, 0 ); shmctl(handle->shminfo.shmid, IPC_RMID, 0); /* destroy when we terminate, now if shmat failed */ if( handle->shminfo.shmaddr == ( void * ) -1 ) { /* fprintf( stderr, "shmat failed\n" ); */ return -1; } handle->shminfo.readOnly = False; if( !XShmAttach( dpy, &handle->shminfo ) ) { /* fprintf( stderr, "XShmAttach failed\n" ); */ shmdt( handle->shminfo.shmaddr ); XFree( handle->image ); return -1; } } else { /* fprintf( stderr, "XvShmCreateImage failed\n" ); */ return -1; } } else { char * data = (char*) malloc( width*height*(bpp/8)); handle->image = XvCreateImage( dpy, handle->p_adaptor_info[0].base_id, handle->xv_mode_id, data, width, height ); } handle->display = dpy; return 0; }
int S9xXVDisplayDriver::init (void) { int padding; int depth = 0, num_formats, num_attrs, highest_formats = 0; XvImageFormatValues *formats = NULL; XvAdaptorInfo *adaptors; XvAttribute *port_attr; VisualID visualid = None; unsigned int num_adaptors; GdkScreen *screen; GdkWindow *root; buffer[0] = malloc (image_padded_size); buffer[1] = malloc (scaled_padded_size); padding = (image_padded_size - image_size) / 2; padded_buffer[0] = (void *) (((uint8 *) buffer[0]) + padding); padding = (scaled_padded_size - scaled_size) / 2; padded_buffer[1] = (void *) (((uint8 *) buffer[1]) + padding); memset (buffer[0], 0, image_padded_size); memset (buffer[1], 0, scaled_padded_size); /* Setup XV */ gtk_widget_realize (drawing_area); display = gdk_x11_drawable_get_xdisplay (GDK_DRAWABLE (gtk_widget_get_window (drawing_area))); screen = gtk_widget_get_screen (drawing_area); root = gdk_screen_get_root_window (screen); xv_portid = -1; XvQueryAdaptors (display, GDK_WINDOW_XWINDOW (root), &num_adaptors, &adaptors); for (int i = 0; i < (int) num_adaptors; i++) { if (adaptors[i].type & XvInputMask && adaptors[i].type & XvImageMask) { formats = XvListImageFormats (display, adaptors[i].base_id, &num_formats); if (num_formats > highest_formats) { xv_portid = adaptors[i].base_id; highest_formats = num_formats; visualid = adaptors[i].formats->visual_id; } free (formats); } } XvFreeAdaptorInfo (adaptors); if (xv_portid < 0) { fprintf (stderr, "Could not open Xv output port.\n"); return -1; } /* Set XV_AUTOPAINT_COLORKEY _only_ if available */ port_attr = XvQueryPortAttributes (display, xv_portid, &num_attrs); for (int i = 0; i < num_attrs; i++) { if (!strcmp (port_attr[i].name, "XV_AUTOPAINT_COLORKEY")) { Atom colorkey = None; colorkey = XInternAtom (display, "XV_AUTOPAINT_COLORKEY", True); if (colorkey != None) XvSetPortAttribute (display, xv_portid, colorkey, 1); } } /* Try to find an RGB format */ format = FOURCC_YUY2; bpp = 100; formats = XvListImageFormats (display, xv_portid, &num_formats); for (int i = 0; i < num_formats; i++) { if (formats[i].id == 0x3 || formats[i].type == XvRGB) { if (formats[i].bits_per_pixel < bpp) { format = formats[i].id; bpp = formats[i].bits_per_pixel; bytes_per_pixel = (bpp == 15) ? 2 : bpp >> 3; depth = formats[i].depth; this->rshift = get_inv_shift (formats[i].red_mask, bpp); this->gshift = get_inv_shift (formats[i].green_mask, bpp); this->bshift = get_inv_shift (formats[i].blue_mask, bpp); /* Check for red-blue inversion on SiliconMotion drivers */ if (formats[i].red_mask == 0x001f && formats[i].blue_mask == 0x7c00) { int copy = this->rshift; this->rshift = this->bshift; this->bshift = copy; } /* on big-endian Xv still seems to like LSB order */ if (config->force_inverted_byte_order) S9xSetEndianess (ENDIAN_MSB); else S9xSetEndianess (ENDIAN_LSB); } } }
bool QX11VideoSurface::findPort() { unsigned int count = 0; XvAdaptorInfo *adaptors = 0; bool portFound = false; if (XvQueryAdaptors(QX11Info::display(), m_winId, &count, &adaptors) == Success) { #ifdef Q_WS_MAEMO_5 //the overlay xvideo adapter fails to switch winId, //prefer the "SGX Textured Video" adapter instead for (int i = count-1; i >= 0 && !portFound; --i) { #else for (unsigned int i = 0; i < count && !portFound; ++i) { #endif if (adaptors[i].type & XvImageMask) { m_portId = adaptors[i].base_id; for (unsigned int j = 0; j < adaptors[i].num_ports && !portFound; ++j, ++m_portId) portFound = XvGrabPort(QX11Info::display(), m_portId, 0) == Success; } } XvFreeAdaptorInfo(adaptors); } return portFound; } void QX11VideoSurface::querySupportedFormats() { int count = 0; if (XvImageFormatValues *imageFormats = XvListImageFormats( QX11Info::display(), m_portId, &count)) { const int rgbCount = sizeof(qt_xvRgbLookup) / sizeof(XvFormatRgb); const int yuvCount = sizeof(qt_xvYuvLookup) / sizeof(XvFormatYuv); for (int i = 0; i < count; ++i) { switch (imageFormats[i].type) { case XvRGB: for (int j = 0; j < rgbCount; ++j) { if (imageFormats[i] == qt_xvRgbLookup[j]) { m_supportedPixelFormats.append(qt_xvRgbLookup[j].pixelFormat); m_formatIds.append(imageFormats[i].id); break; } } break; case XvYUV: for (int j = 0; j < yuvCount; ++j) { if (imageFormats[i] == qt_xvYuvLookup[j]) { m_supportedPixelFormats.append(qt_xvYuvLookup[j].pixelFormat); m_formatIds.append(imageFormats[i].id); break; } } break; } } XFree(imageFormats); } m_brightnessRange = qMakePair(0, 0); m_contrastRange = qMakePair(0, 0); m_hueRange = qMakePair(0, 0); m_saturationRange = qMakePair(0, 0); if (XvAttribute *attributes = XvQueryPortAttributes(QX11Info::display(), m_portId, &count)) { for (int i = 0; i < count; ++i) { if (qstrcmp(attributes[i].name, "XV_BRIGHTNESS") == 0) m_brightnessRange = qMakePair(attributes[i].min_value, attributes[i].max_value); else if (qstrcmp(attributes[i].name, "XV_CONTRAST") == 0) m_contrastRange = qMakePair(attributes[i].min_value, attributes[i].max_value); else if (qstrcmp(attributes[i].name, "XV_HUE") == 0) m_hueRange = qMakePair(attributes[i].min_value, attributes[i].max_value); else if (qstrcmp(attributes[i].name, "XV_SATURATION") == 0) m_saturationRange = qMakePair(attributes[i].min_value, attributes[i].max_value); } XFree(attributes); } }
void xf_tsmf_init(xfInfo* xfi, long xv_port) { int ret; unsigned int i; unsigned int version; unsigned int release; unsigned int event_base; unsigned int error_base; unsigned int request_base; unsigned int num_adaptors; xfXvContext* xv; XvAdaptorInfo* ai; XvAttribute* attr; XvImageFormatValues* fo; xv = (xfXvContext*) malloc(sizeof(xfXvContext)); ZeroMemory(xv, sizeof(xfXvContext)); xfi->xv_context = xv; xv->xv_colorkey_atom = None; xv->xv_image_size = 0; xv->xv_port = xv_port; if (!XShmQueryExtension(xfi->display)) { DEBUG_XV("no shmem available."); return; } ret = XvQueryExtension(xfi->display, &version, &release, &request_base, &event_base, &error_base); if (ret != Success) { DEBUG_XV("XvQueryExtension failed %d.", ret); return; } DEBUG_XV("version %u release %u", version, release); ret = XvQueryAdaptors(xfi->display, DefaultRootWindow(xfi->display), &num_adaptors, &ai); if (ret != Success) { DEBUG_XV("XvQueryAdaptors failed %d.", ret); return; } for (i = 0; i < num_adaptors; i++) { DEBUG_XV("adapter port %ld-%ld (%s)", ai[i].base_id, ai[i].base_id + ai[i].num_ports - 1, ai[i].name); if (xv->xv_port == 0 && i == num_adaptors - 1) xv->xv_port = ai[i].base_id; } if (num_adaptors > 0) XvFreeAdaptorInfo(ai); if (xv->xv_port == 0) { DEBUG_XV("no adapter selected, video frames will not be processed."); return; } DEBUG_XV("selected %ld", xv->xv_port); attr = XvQueryPortAttributes(xfi->display, xv->xv_port, &ret); for (i = 0; i < (unsigned int)ret; i++) { if (strcmp(attr[i].name, "XV_COLORKEY") == 0) { xv->xv_colorkey_atom = XInternAtom(xfi->display, "XV_COLORKEY", FALSE); XvSetPortAttribute(xfi->display, xv->xv_port, xv->xv_colorkey_atom, attr[i].min_value + 1); break; } } XFree(attr); #ifdef WITH_DEBUG_XV fprintf(stderr, "xf_tsmf_init: pixel format "); #endif fo = XvListImageFormats(xfi->display, xv->xv_port, &ret); if (ret > 0) { xv->xv_pixfmts = (UINT32*) malloc((ret + 1) * sizeof(UINT32)); ZeroMemory(xv->xv_pixfmts, (ret + 1) * sizeof(UINT32)); for (i = 0; i < ret; i++) { xv->xv_pixfmts[i] = fo[i].id; #ifdef WITH_DEBUG_XV fprintf(stderr, "%c%c%c%c ", ((char*)(xv->xv_pixfmts + i))[0], ((char*)(xv->xv_pixfmts + i))[1], ((char*)(xv->xv_pixfmts + i))[2], ((char*)(xv->xv_pixfmts + i))[3]); #endif } xv->xv_pixfmts[i] = 0; } XFree(fo); #ifdef WITH_DEBUG_XV fprintf(stderr, "\n"); #endif }