static void win32_display_frame( vo_driver_t * vo_driver, vo_frame_t * vo_frame ) { win32_driver_t * win32_driver = ( win32_driver_t * ) vo_driver; win32_frame_t * win32_frame = ( win32_frame_t * ) vo_frame; int offset; int size; // if the required width, height or format has changed // then recreate the secondary buffer if( ( win32_driver->req_format != win32_frame->format ) || ( win32_driver->width != win32_frame->width ) || ( win32_driver->height != win32_frame->height ) ) { CreateSecondary( win32_driver, win32_frame->width, win32_frame->height, win32_frame->format ); } // determine desired ratio win32_driver->ratio = win32_frame->ratio; // lock our surface to update its contents win32_driver->contents = Lock( win32_driver->secondary ); // surface unavailable, skip frame render if( !win32_driver->contents ) { vo_frame->free( vo_frame ); return; } // if our actual frame format is the native screen // pixel format, we need to convert it if( win32_driver->act_format == IMGFMT_NATIVE ) { // use the software color conversion functions // to rebuild the frame in our native screen // pixel format ... this is slow if( win32_driver->req_format == XINE_IMGFMT_YV12 ) { // convert from yv12 to native // screen pixel format #if NEW_YUV win32_driver->yuv2rgb->configure( win32_driver->yuv2rgb, win32_driver->width, win32_driver->height, win32_driver->width, win32_driver->width/2, win32_driver->width, win32_driver->height, win32_driver->width * win32_driver->bytespp ); #else yuv2rgb_setup( win32_driver->yuv2rgb, win32_driver->width, win32_driver->height, win32_driver->width, win32_driver->width/2, win32_driver->width, win32_driver->height, win32_driver->width * win32_driver->bytespp ); #endif win32_driver->yuv2rgb->yuv2rgb_fun( win32_driver->yuv2rgb, win32_driver->contents, win32_frame->vo_frame.base[0], win32_frame->vo_frame.base[1], win32_frame->vo_frame.base[2] ); } if( win32_driver->req_format == XINE_IMGFMT_YUY2 ) { // convert from yuy2 to native // screen pixel format #if NEW_YUV win32_driver->yuv2rgb->configure( win32_driver->yuv2rgb, win32_driver->width, win32_driver->height, win32_driver->width, win32_driver->width/2, win32_driver->width, win32_driver->height, win32_driver->width * win32_driver->bytespp ); #else yuv2rgb_setup( win32_driver->yuv2rgb, win32_driver->width, win32_driver->height, win32_driver->width, win32_driver->width/2, win32_driver->width, win32_driver->height, win32_driver->width * win32_driver->bytespp ); #endif win32_driver->yuv2rgb->yuy22rgb_fun( win32_driver->yuv2rgb, win32_driver->contents, win32_frame->vo_frame.base[0] ); } #if RGB_SUPPORT if( win32_driver->req_format == IMGFMT_RGB ) { // convert from 24 bit rgb to native // screen pixel format // TODO : rgb2rgb conversion } #endif } else { // the actual format is identical to our // stream format. we just need to copy it switch(win32_frame->format) { case XINE_IMGFMT_YV12: { vo_frame_t *frame; uint8_t *img; frame = vo_frame; img = (uint8_t *)win32_driver->contents; offset = 0; size = frame->pitches[0] * frame->height; memcpy( img+offset, frame->base[0], size); offset += size; size = frame->pitches[2]* frame->height / 2; memcpy( img+offset, frame->base[2], size); offset += size; size = frame->pitches[1] * frame->height / 2; memcpy( img+offset, frame->base[1], size); } break; case XINE_IMGFMT_YUY2: memcpy( win32_driver->contents, win32_frame->vo_frame.base[0], win32_frame->vo_frame.pitches[0] * win32_frame->vo_frame.height * 2); break; default: memcpy( win32_driver->contents, win32_frame->vo_frame.base[0], win32_frame->vo_frame.pitches[0] * win32_frame->vo_frame.height * 2); break; } } // unlock the surface Unlock( win32_driver->secondary ); // scale, clip and display our frame DisplayFrame( win32_driver ); // tag our frame as displayed if((win32_driver->current != NULL) && (win32_driver->current != vo_frame)) { vo_frame->free(&win32_driver->current->vo_frame); } win32_driver->current = vo_frame; }
static void win32_display_frame( vo_driver_t * vo_driver, vo_frame_t * vo_frame ) { win32_driver_t *win32_driver = ( win32_driver_t * ) vo_driver; win32_frame_t *win32_frame = ( win32_frame_t * ) vo_frame; /* if the required width, height or format has changed * then recreate the secondary buffer */ if( ( win32_driver->req_format != win32_frame->format ) || ( win32_driver->width != win32_frame->width ) || ( win32_driver->height != win32_frame->height ) ) { CreateSecondary( win32_driver, win32_frame->width, win32_frame->height, win32_frame->format ); } /* determine desired ratio */ win32_driver->ratio = win32_frame->ratio; /* lock our surface to update its contents */ win32_driver->contents = Lock( win32_driver, win32_driver->secondary ); /* surface unavailable, skip frame render */ if( !win32_driver->contents ) { vo_frame->free( vo_frame ); return; } /* if our actual frame format is the native screen * pixel format, we need to convert it */ if( win32_driver->act_format == IMGFMT_NATIVE ) { /* use the software color conversion functions * to rebuild the frame in our native screen * pixel format ... this is slow */ if( win32_driver->req_format == XINE_IMGFMT_YV12 ) { /* convert from yv12 to native * screen pixel format */ #if NEW_YUV win32_driver->yuv2rgb->configure( win32_driver->yuv2rgb, win32_driver->width, win32_driver->height, win32_frame->vo_frame.pitches[0], win32_frame->vo_frame.pitches[1], win32_driver->width, win32_driver->height, win32_driver->width * win32_driver->bytespp); #else yuv2rgb_setup( win32_driver->yuv2rgb, win32_driver->width, win32_driver->height, win32_frame->vo_frame.pitches[0], win32_frame->vo_frame.pitches[1], win32_driver->width, win32_driver->height, win32_driver->width * win32_driver->bytespp ); #endif win32_driver->yuv2rgb->yuv2rgb_fun( win32_driver->yuv2rgb, win32_driver->contents, win32_frame->vo_frame.base[0], win32_frame->vo_frame.base[1], win32_frame->vo_frame.base[2] ); } if( win32_driver->req_format == XINE_IMGFMT_YUY2 ) { /* convert from yuy2 to native * screen pixel format */ #if NEW_YUV win32_driver->yuv2rgb->configure( win32_driver->yuv2rgb, win32_driver->width, win32_driver->height, win32_frame->vo_frame.pitches[0], win32_frame->vo_frame.pitches[0] / 2, win32_driver->width, win32_driver->height, win32_driver->width * win32_driver->bytespp ); #else yuv2rgb_setup( win32_driver->yuv2rgb, win32_driver->width, win32_driver->height, win32_frame->vo_frame.pitches[0], win32_frame->vo_frame.pitches[0] / 2, win32_driver->width, win32_driver->height, win32_driver->width * win32_driver->bytespp ); #endif win32_driver->yuv2rgb->yuy22rgb_fun( win32_driver->yuv2rgb, win32_driver->contents, win32_frame->vo_frame.base[0] ); } #if RGB_SUPPORT if( win32_driver->req_format == IMGFMT_RGB ) { /* convert from 24 bit rgb to native * screen pixel format */ /* TODO : rgb2rgb conversion */ } #endif } else { /* the actual format is identical to our * stream format. we just need to copy it */ int line; uint8_t * src; vo_frame_t * frame = vo_frame; uint8_t * dst = (uint8_t *)win32_driver->contents; switch(win32_frame->format) { case XINE_IMGFMT_YV12: src = frame->base[0]; for (line = 0; line < frame->height ; line++){ xine_fast_memcpy( dst, src, frame->width); src += vo_frame->pitches[0]; dst += win32_driver->ddsd.lPitch; } src = frame->base[2]; for (line = 0; line < frame->height/2 ; line++){ xine_fast_memcpy( dst, src, frame->width/2); src += vo_frame->pitches[2]; dst += win32_driver->ddsd.lPitch/2; } src = frame->base[1]; for (line = 0; line < frame->height/2 ; line++){ xine_fast_memcpy( dst, src, frame->width/2); src += vo_frame->pitches[1]; dst += win32_driver->ddsd.lPitch/2; } break; case XINE_IMGFMT_YUY2: default: src = frame->base[0]; for (line = 0; line < frame->height ; line++){ xine_fast_memcpy( dst, src, frame->width*2); src += vo_frame->pitches[0]; dst += win32_driver->ddsd.lPitch; } break; } } /* unlock the surface */ Unlock( win32_driver->secondary ); /* scale, clip and display our frame */ DisplayFrame( win32_driver ); /* tag our frame as displayed */ if((win32_driver->current != NULL) && ((vo_frame_t *)win32_driver->current != vo_frame)) { vo_frame->free(&win32_driver->current->vo_frame); } win32_driver->current = (win32_frame_t *)vo_frame; }