static picture_pool_t *Pool(vout_display_t *vd, unsigned count) { vout_display_sys_t *sys = vd->sys; if (!sys->pool) { if (!sys->picture) { picture_resource_t rsc; memset(&rsc, 0, sizeof(rsc)); rsc.p[0].p_pixels = sys->video_ptr; rsc.p[0].i_lines = sys->var_info.yres; rsc.p[0].i_pitch = sys->line_length; sys->picture = picture_NewFromResource(&vd->fmt, &rsc); if (!sys->picture) return NULL; } if (sys->is_hw_accel) sys->pool = picture_pool_New(1, &sys->picture); else sys->pool = picture_pool_NewFromFormat(&vd->fmt, count); } return sys->pool; }
static picture_pool_t *PoolVideo(vout_display_t *vd, unsigned requested_count) { vout_display_sys_t *sys = vd->sys; if (!sys->pool) sys->pool = picture_pool_NewFromFormat(&vd->fmt, requested_count); return sys->pool; }
static picture_t *Get(vout_display_t *vd) { vout_display_sys_t *sys = vd->sys; if (!sys->pool) { if (!sys->picture) { picture_resource_t rsc; memset(&rsc, 0, sizeof(rsc)); rsc.p[0].p_pixels = sys->video_ptr; rsc.p[0].i_lines = sys->var_info.yres; if (sys->var_info.xres_virtual) rsc.p[0].i_pitch = sys->var_info.xres_virtual * sys->bytes_per_pixel; else rsc.p[0].i_pitch = sys->var_info.xres * sys->bytes_per_pixel; sys->picture = picture_NewFromResource(&vd->fmt, &rsc); if (!sys->picture) return NULL; } if (sys->is_hw_accel) sys->pool = picture_pool_New(1, &sys->picture); else sys->pool = picture_pool_NewFromFormat(&vd->fmt, 1); if (!sys->pool) return NULL; } return picture_pool_Get(sys->pool); }
static picture_pool_t *Pool(vout_display_t *vd, unsigned count) { vout_display_sys_t *sys = vd->sys; if (sys->pool == NULL) sys->pool = picture_pool_NewFromFormat(&vd->fmt, count); return sys->pool; }
static void NoDrInit(vout_thread_t *vout) { vout_thread_sys_t *sys = vout->p; if (sys->display.use_dr) sys->display_pool = vout_display_Pool(sys->display.vd, 3); else //sys->display_pool = picture_pool_Reserve(sys->decoder_pool, DISPLAY_PICTURE_COUNT); sys->display_pool = picture_pool_NewFromFormat(&sys->display.vd->source, DISPLAY_PICTURE_COUNT); }
static picture_t *Get(vout_display_t *vd) { vout_display_sys_t *sys = vd->sys; if (!sys->pool) { sys->pool = picture_pool_NewFromFormat(&vd->fmt, 1); if (!sys->pool) return NULL; } return picture_pool_Get(sys->pool); }
/** * Handles pool allocations for bitmaps */ static picture_pool_t *Pool(vout_display_t *vd, unsigned count) { vout_display_sys_t *sys = vd->sys; if (!sys->pool) { sys->pool = picture_pool_NewFromFormat(&vd->fmt, count); #ifndef NDEBUG msg_Dbg(vd, "New picture pool created"); #endif } return sys->pool; }
int vout_InitWrapper(vout_thread_t *vout) { vout_thread_sys_t *sys = vout->p; vout_display_t *vd = sys->display.vd; video_format_t source = vd->source; sys->display.use_dr = !vout_IsDisplayFiltered(vd); const bool allow_dr = !vd->info.has_pictures_invalid && !vd->info.is_slow && sys->display.use_dr; const unsigned private_picture = 4; /* XXX 3 for filter, 1 for SPU */ const unsigned decoder_picture = 1 + sys->dpb_size; const unsigned kept_picture = 1; /* last displayed picture */ const unsigned reserved_picture = DISPLAY_PICTURE_COUNT + private_picture + kept_picture; picture_pool_t *display_pool = vout_display_Pool(vd, allow_dr ? __MAX(VOUT_MAX_PICTURES, reserved_picture + decoder_picture) : 3); if (allow_dr && picture_pool_GetSize(display_pool) >= reserved_picture + decoder_picture) { sys->dpb_size = picture_pool_GetSize(display_pool) - reserved_picture; sys->decoder_pool = display_pool; sys->display_pool = display_pool; } else if (!sys->decoder_pool) { sys->decoder_pool = picture_pool_NewFromFormat(&source, __MAX(VOUT_MAX_PICTURES, reserved_picture + decoder_picture - DISPLAY_PICTURE_COUNT)); if (!sys->decoder_pool) return VLC_EGENERIC; if (allow_dr) { msg_Warn(vout, "Not enough direct buffers, using system memory"); sys->dpb_size = 0; } else { sys->dpb_size = picture_pool_GetSize(sys->decoder_pool) - reserved_picture; } NoDrInit(vout); } sys->private_pool = picture_pool_Reserve(sys->decoder_pool, private_picture); sys->display.filtered = NULL; return VLC_SUCCESS; }
/** * This function initializes libcaca vout method. */ static int Open(vlc_object_t *object) { vout_display_t *vd = (vout_display_t *)object; vout_display_sys_t *sys; #if defined(WIN32) && !defined(UNDER_CE) CONSOLE_SCREEN_BUFFER_INFO csbiInfo; SMALL_RECT rect; COORD coord; HANDLE hstdout; if (!AllocConsole()) { msg_Err(vd, "cannot create console"); return VLC_EGENERIC; } hstdout = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CONSOLE_TEXTMODE_BUFFER, NULL); if (!hstdout || hstdout == INVALID_HANDLE_VALUE) { msg_Err(vd, "cannot create screen buffer"); FreeConsole(); return VLC_EGENERIC; } if (!SetConsoleActiveScreenBuffer(hstdout)) { msg_Err(vd, "cannot set active screen buffer"); FreeConsole(); return VLC_EGENERIC; } coord = GetLargestConsoleWindowSize(hstdout); msg_Dbg(vd, "SetConsoleWindowInfo: %ix%i", coord.X, coord.Y); /* Force size for now */ coord.X = 100; coord.Y = 40; if (!SetConsoleScreenBufferSize(hstdout, coord)) msg_Warn(vd, "SetConsoleScreenBufferSize %i %i", coord.X, coord.Y); /* Get the current screen buffer size and window position. */ if (GetConsoleScreenBufferInfo(hstdout, &csbiInfo)) { rect.Top = 0; rect.Left = 0; rect.Right = csbiInfo.dwMaximumWindowSize.X - 1; rect.Bottom = csbiInfo.dwMaximumWindowSize.Y - 1; if (!SetConsoleWindowInfo(hstdout, TRUE, &rect)) msg_Dbg(vd, "SetConsoleWindowInfo failed: %ix%i", rect.Right, rect.Bottom); } #endif /* Allocate structure */ vd->sys = sys = calloc(1, sizeof(*sys)); if (!sys) goto error; sys->cv = cucul_create_canvas(0, 0); if (!sys->cv) { msg_Err(vd, "cannot initialize libcucul"); goto error; } sys->dp = caca_create_display(sys->cv); if (!sys->dp) { msg_Err(vd, "cannot initialize libcaca"); goto error; } if (vd->cfg->display.title) caca_set_display_title(sys->dp, vd->cfg->display.title); else caca_set_display_title(sys->dp, VOUT_TITLE "(Colour AsCii Art)"); /* Fix format */ video_format_t fmt = vd->fmt; if (fmt.i_chroma != VLC_CODEC_RGB32) { fmt.i_chroma = VLC_CODEC_RGB32; fmt.i_rmask = 0x00ff0000; fmt.i_gmask = 0x0000ff00; fmt.i_bmask = 0x000000ff; } /* */ sys->pool = picture_pool_NewFromFormat(&fmt, 1); if (!sys->pool) goto error; /* TODO */ vout_display_info_t info = vd->info; /* Setup vout_display now that everything is fine */ vd->fmt = fmt; vd->info = info; vd->get = Get; vd->prepare = Prepare; vd->display = Display; vd->control = Control; vd->manage = Manage; /* Fix initial state */ vout_display_SendEventFullscreen(vd, false); Refresh(vd); return VLC_SUCCESS; error: if (sys) { if (sys->pool) picture_pool_Delete(sys->pool); if (sys->dither) cucul_free_dither(sys->dither); if (sys->dp) caca_free_display(sys->dp); if (sys->cv) cucul_free_canvas(sys->cv); free(sys); } #if defined(WIN32) && !defined(UNDER_CE) FreeConsole(); #endif return VLC_EGENERIC; }