SDL_Overlay *DirectFB_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display) { SDL_Overlay *overlay; struct private_yuvhwdata *hwdata; /* Create the overlay structure */ overlay = SDL_calloc (1, sizeof(SDL_Overlay)); if (!overlay) { SDL_OutOfMemory(); return NULL; } /* Fill in the basic members */ overlay->format = format; overlay->w = width; overlay->h = height; /* Set up the YUV surface function structure */ overlay->hwfuncs = &directfb_yuvfuncs; /* Create the pixel data and lookup tables */ hwdata = SDL_calloc(1, sizeof(struct private_yuvhwdata)); overlay->hwdata = hwdata; if (!hwdata) { SDL_OutOfMemory(); SDL_FreeYUVOverlay (overlay); return NULL; } if (CreateYUVSurface (this, hwdata, width, height, format)) { SDL_FreeYUVOverlay (overlay); return NULL; } overlay->hw_overlay = 1; /* Set up the plane pointers */ overlay->pitches = hwdata->pitches; overlay->pixels = hwdata->planes; switch (format) { case SDL_YV12_OVERLAY: case SDL_IYUV_OVERLAY: overlay->planes = 3; break; default: overlay->planes = 1; break; } /* We're all done.. */ return overlay; }
void alloc_picture(void *userdata) { VideoState *is = (VideoState *)userdata; VideoPicture *vp; vp = &is->pictq[is->pictq_windex]; if(vp->bmp) { // we already have one make another, bigger/smaller SDL_FreeYUVOverlay(vp->bmp); } // Allocate a place to put our YUV image on that screen vp->bmp = SDL_CreateYUVOverlay(is->video_st->codec->width, is->video_st->codec->height, SDL_YV12_OVERLAY, screen); vp->width = is->video_st->codec->width; vp->height = is->video_st->codec->height; SDL_LockMutex(is->pictq_mutex); vp->allocated = 1; SDL_CondSignal(is->pictq_cond); SDL_UnlockMutex(is->pictq_mutex); }
static void ffmovie_cleanup(FFMovie *movie) { if(!movie) return; if(movie->audio_st) { packet_queue_abort(&movie->audioq); SDL_CloseAudio(); packet_queue_end(&movie->audioq); avcodec_close(&movie->audio_st->codec); movie->audio_st = NULL; } if(movie->video_st) { avcodec_close(&movie->video_st->codec); movie->video_st = NULL; } if (movie->context) { av_close_input_file(movie->context); movie->context = NULL; } if(movie->dest_mutex) { SDL_DestroyMutex(movie->dest_mutex); movie->dest_mutex = NULL; } if (movie->dest_overlay) { SDL_FreeYUVOverlay(movie->dest_overlay); movie->dest_overlay = NULL; } Global_num_active--; }
EC_VOID SDL_VideoRender::Uninit() { SDL_FreeSurface(m_pScreen); SDL_FreeYUVOverlay(m_pOverlay); SDL_QuitSubSystem(SDL_INIT_VIDEO); SDL_Quit(); }
int do_video_options(int sel) { int old_stretch = display_cfg.stretch; #ifdef RAINE_WIN32 UINT32 old_driver = display_cfg.video_driver; #endif // int oldx = display_cfg.screen_x,oldy = display_cfg.screen_y; video_options = new TVideo(_("Video options"), video_items); video_options->execute(); #ifdef RAINE_WIN32 if (old_driver != display_cfg.video_driver) { if (sdl_overlay) { SDL_FreeYUVOverlay(sdl_overlay); sdl_overlay = NULL; } sdl_screen = NULL; SDL_QuitSubSystem(SDL_INIT_VIDEO); setup_video_driver(); SDL_InitSubSystem(SDL_INIT_VIDEO); ScreenChange(); } #endif SetupScreenBitmap(); if ((sdl_overlay != NULL || display_cfg.video_mode == 1) && display_cfg.video_mode != 2) { // explicitely clear scanlines when overlays are enabled display_cfg.scanlines = 0; } if (old_stretch != display_cfg.stretch && display_cfg.stretch == 3 && sdl_game_bitmap) { DestroyScreenBitmap(); // init hq2x/3x, switch gamebitmap to 16bpp // + recall InitLUTs by recreating game_bitmap when enabling hq2x/3x } return 0; // (oldx != display_cfg.screen_x || oldy != display_cfg.screen_y); }
uint8_t sdlAccelRender::end( void) { if(sdl_overlay) { SDL_FreeYUVOverlay(sdl_overlay); } if(sdl_display) { SDL_UnlockSurface(sdl_display); SDL_FreeSurface(sdl_display); } if(sdl_running) { SDL_QuitSubSystem(SDL_INIT_VIDEO); #ifdef __APPLE__ destroyCocoaView(); #endif } if(decoded) { delete [] decoded; decoded=NULL; } sdl_running=0; sdl_overlay=NULL; sdl_display=NULL; printf("[SDL] Video subsystem closed and destroyed\n"); }
~SdlOverlayPort() { if (overlay_) SDL_FreeYUVOverlay(overlay_); if (sws_context_) sws_freeContext(sws_context_); }
SdlAbstract::~SdlAbstract () { if (mpBmp) { SDL_FreeYUVOverlay(mpBmp); mpBmp = NULL; } SDL_Quit (); }
static void overlay_dealloc (PyGameOverlay *self) { if (SDL_WasInit (SDL_INIT_VIDEO) && self->cOverlay) SDL_FreeYUVOverlay (self->cOverlay); PyObject_Free ((PyObject*)self); }
static OMX_ERRORTYPE sdlivr_proc_stop_and_return (void *ap_obj) { sdlivr_prc_t *p_prc = ap_obj; assert (NULL != p_prc); SDL_FreeYUVOverlay (p_prc->p_overlay); return OMX_ErrorNone; }
ShowObject::~ShowObject(){ SDL_FreeYUVOverlay(bmp); SDL_FreeSurface(screen); SDL_Quit(); av_free(pFrame); // avcodec_close(pCodecCtx); // av_close_input_file(pFormatCtx); }
SdlBlitter::~SdlBlitter() { if (overlay) { SDL_UnlockYUVOverlay(overlay); SDL_FreeYUVOverlay(overlay); } if (surface != screen) SDL_FreeSurface(surface); }
/** Destructor. */ ImageDisplay::~ImageDisplay() { delete _rect; SDL_FreeYUVOverlay(_overlay); SDL_FreeSurface(_surface); SDLKeeper::quit(); }
static void sdl_destroy_window(SdlOut *obj){ if (obj->overlay!=NULL){ SDL_FreeYUVOverlay(obj->overlay); obj->overlay=NULL; } if (obj->screen!=NULL){ SDL_FreeSurface(obj->screen); obj->screen=NULL; } }
int main(int argc, char** argv) { int ret = EXIT_SUCCESS; /* Initialize param struct to zero */ memset(&P, 0, sizeof(P)); if (!parse_input(argc, argv)) { return EXIT_FAILURE; } /* Initialize parameters corresponding to YUV-format */ setup_param(); if (!sdl_init()) { return EXIT_FAILURE; } if (!open_input()) { return EXIT_FAILURE; } if (!allocate_memory()) { ret = EXIT_FAILURE; goto cleanup; } /* Lets do some basic consistency check on input */ check_input(); /* send event to display first frame */ event.type = SDL_KEYDOWN; event.key.keysym.sym = SDLK_RIGHT; SDL_PushEvent(&event); /* while true */ event_loop(); cleanup: destroy_message_queue(); SDL_FreeYUVOverlay(my_overlay); free(P.raw); free(P.y_data); free(P.cb_data); free(P.cr_data); if (fd) { fclose(fd); } if (P.fd2) { fclose(P.fd2); } return ret; }
static void SDLVid_DestroyObjects(SDLVidCtx *ctx) { if (ctx->back_buffer) SDL_FreeSurface(ctx->back_buffer); ctx->back_buffer = NULL; if (ctx->pool_rgb) SDL_FreeSurface(ctx->pool_rgb); ctx->pool_rgb = NULL; if (ctx->pool_rgba) SDL_FreeSurface(ctx->pool_rgba); ctx->pool_rgba = NULL; SDL_FreeYUVOverlay(ctx->yuv_overlay); ctx->yuv_overlay=NULL; }
void vid_close() { if (overlay) { SDL_UnlockYUVOverlay(overlay); SDL_FreeYUVOverlay(overlay); } else SDL_UnlockSurface(screen); SDL_Quit(); fb.enabled = 0; }
void newsrc_sdl (void) { if(sdl_overlay) SDL_FreeYUVOverlay(sdl_overlay); // FIXME: on linux the SDL_*_OVERLAY are defined as FOURCC numbers rather than beeing abstract // so we could try other ffmpeg/lqt compatible 420P formats as I420 (0x30323449) sdl_overlay = SDL_CreateYUVOverlay(movie_width, movie_height, 0x30323449, sdl_screen); sdl_pic_format=0x30323449; if(!sdl_overlay || (!sdl_overlay->hw_overlay)) { sdl_overlay = SDL_CreateYUVOverlay(movie_width, movie_height, SDL_YV12_OVERLAY, sdl_screen); sdl_pic_format=SDL_YV12_OVERLAY; } }
static int sdl_video_open(int width, int height) { int flags = SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL; int w,h; if (is_full_screen) flags |= SDL_FULLSCREEN; else flags |= SDL_RESIZABLE; if (is_full_screen && fs_screen_width) { w = fs_screen_width; h = fs_screen_height; } else if (width > fs_screen_width || height > fs_screen_height) { w = fs_screen_width; h = fs_screen_height; } else { w = width; h = height; } /* 32 because framebuffer is usually initalized to 8 and you have to use fbset with -depth to make it working */ screen = SDL_SetVideoMode(w, h, 32, flags); if (!screen) { MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO,"%s: Unable to set video mode: %s", SDL_GetError()); return -1; } MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: SDL dimension %d x %d fullscreen %d BytesPerPixel %d", screen->w, screen->h, is_full_screen, screen->format->BytesPerPixel); SDL_WM_SetCaption("motion", "motion"); SDL_ShowCursor(SDL_DISABLE); if (cur_width != width || cur_height != height) { cur_width = width; cur_height = height; if (overlay) SDL_FreeYUVOverlay(overlay); overlay = SDL_CreateYUVOverlay(cur_width, cur_height, SDL_YV12_OVERLAY, screen); if (!overlay) { MOTION_LOG(ERR, TYPE_ALL, SHOW_ERRNO, "%s: Could not create overlay: %s", SDL_GetError()); sdl_stop(); } else MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: SDL created %dx%dx%d %s overlay", overlay->w,overlay->h,overlay->planes, overlay->hw_overlay?"hardware":"software"); } return overlay == NULL; }
static void sdl_close (vo_instance_t * _instance) { sdl_instance_t * instance; int i; instance = (sdl_instance_t *) _instance; for (i = 0; i < 3; i++) SDL_FreeYUVOverlay (instance->frame[i].overlay); SDL_FreeSurface (instance->surface); SDL_QuitSubSystem (SDL_INIT_VIDEO); }
static void sdl_reset(void) { if (sdl.bmp) { SDL_FreeYUVOverlay(sdl.bmp); sdl.bmp = NULL; } if (sdl.screen) { SDL_FreeSurface(sdl.screen); sdl.screen = NULL; } }
void sdl_stop(void) { if (screen) { MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO, "%s: SDL quit"); SDL_ShowCursor(SDL_ENABLE); if (overlay) { SDL_FreeYUVOverlay(overlay); overlay = NULL; } SDL_Quit(); screen = NULL; } }
static void overlay_init() { if (!use_yuv) return; if (use_yuv < 0) if (vmode[0] < 320 || vmode[1] < 288) return; overlay = SDL_CreateYUVOverlay(320, 144, SDL_YUY2_OVERLAY, screen); if (!overlay) return; if (!overlay->hw_overlay || overlay->planes > 1) { SDL_FreeYUVOverlay(overlay); overlay = 0; return; } SDL_LockYUVOverlay(overlay); fb.w = 160; fb.h = 144; fb.pelsize = 4; fb.pitch = overlay->pitches[0]; fb.ptr = overlay->pixels[0]; fb.yuv = 1; fb.cc[0].r = fb.cc[1].r = fb.cc[2].r = fb.cc[3].r = 0; fb.dirty = 1; fb.enabled = 1; overlay_rect.x = 0; overlay_rect.y = 0; overlay_rect.w = vmode[0]; overlay_rect.h = vmode[1]; /* Color channels are 0=Y, 1=U, 2=V, 3=Y1 */ switch (overlay->format) { /* FIXME - support more formats */ case SDL_YUY2_OVERLAY: default: fb.cc[0].l = 0; fb.cc[1].l = 24; fb.cc[2].l = 8; fb.cc[3].l = 16; break; } SDL_UnlockYUVOverlay(overlay); }
AVIWrapper::~AVIWrapper() { if (v_stream) v_stream->StopStreaming(); if (a_stream) a_stream->StopStreaming(); if (i_avi) delete i_avi; if (screen_overlay) SDL_FreeYUVOverlay(screen_overlay); if (remaining_buffer) delete[] remaining_buffer; }
/* Must be called with the sdl lock held */ static void gst_sdlvideosink_destroy (GstSDLVideoSink * sdlvideosink) { if (sdlvideosink->overlay) { SDL_FreeYUVOverlay (sdlvideosink->overlay); sdlvideosink->overlay = NULL; } if (sdlvideosink->screen) { SDL_FreeSurface (sdlvideosink->screen); sdlvideosink->screen = NULL; } sdlvideosink->xwindow_id = 0; }
C_RESULT vp_stages_output_sdl_stage_close(vp_stages_output_sdl_config_t *cfg) { vp_os_mutex_lock(&xlib_mutex); SDL_ShowCursor(SDL_ENABLE); SDL_FreeYUVOverlay(cfg->overlay); SDL_FreeSurface(cfg->surface); SDL_Quit(); vp_os_mutex_unlock(&xlib_mutex); return (VP_SUCCESS); }
static OMX_ERRORTYPE sdlivr_prc_deallocate_resources (void * ap_obj) { sdlivr_prc_t * p_prc = ap_obj; assert (p_prc); if (p_prc->p_overlay) { SDL_FreeYUVOverlay (p_prc->p_overlay); p_prc->p_overlay = NULL; } /* This frees p_prc->p_surface */ SDL_Quit (); p_prc->p_surface = NULL; return OMX_ErrorNone; }
/* * Clean up - free everything */ CSDLVideo::~CSDLVideo (void) { CHECK_AND_FREE(m_name); if (m_image) { SDL_FreeYUVOverlay(m_image); m_image = NULL; } if (m_screen) { SDL_FreeSurface(m_screen); m_screen = NULL; } if (m_mutex) { SDL_DestroyMutex(m_mutex); m_mutex = NULL; } }
void plat_sdl_finish(void) { if (plat_sdl_overlay != NULL) { SDL_FreeYUVOverlay(plat_sdl_overlay); plat_sdl_overlay = NULL; } if (plat_sdl_gl_active) { gl_finish(); plat_sdl_gl_active = 0; } // restore back to initial resolution // resolves black screen issue on R-Pi if (strcmp(vid_drv_name, "x11") != 0) SDL_SetVideoMode(fs_w, fs_h, 16, SDL_SWSURFACE); SDL_Quit(); }
void SDLQuit(chain_t *display_service) { displaythread_info_t *info; info=(displaythread_info_t*)display_service->data; #ifdef HAVE_SDLLIB // if width==-1, SDL was never initialized so we do nothing if (display_service->current_buffer->frame.size[0]!=-1) { SDLEventStopThread(display_service); SDL_FreeYUVOverlay(info->sdloverlay); SDL_FreeSurface(info->sdlvideo); SDL_QuitSubSystem(SDL_INIT_VIDEO); } #endif }