本文整理汇总了C++中SDL_CreateYUVOverlay函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_CreateYUVOverlay函数的具体用法?C++ SDL_CreateYUVOverlay怎么用?C++ SDL_CreateYUVOverlay使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SDL_CreateYUVOverlay函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sprintf_s
EC_U32 SDL_VideoRender::Init(MediaCtxInfo* pMediaInfo,
EC_U32 nScreenWidth,
EC_U32 nScreenHight,
EC_VOIDP pDrawable)
{
if (EC_NULL == pMediaInfo)
return EC_Err_BadParam;
AVCodecContext *pCodecCtx = (AVCodecContext*)(pMediaInfo->m_pVideoCodecInfo);
if ((0 == nScreenWidth) || (0 == nScreenHight))
{
nScreenWidth = pCodecCtx->width;
nScreenHight = pCodecCtx->height;
}
m_pDrawable = pDrawable;
char pEnvStr[256] = { 0 };
sprintf_s(pEnvStr, 255, "SDL_WINDOWID=0x%lx", pDrawable);
SDL_putenv(pEnvStr);
if (SDL_Init(SDL_INIT_VIDEO) < 0)
return Video_Render_Err_InitFail;
m_nWindowWidth = nScreenWidth;
m_nWindowHeight = nScreenHight;
m_nVideoWidth = pCodecCtx->width;
m_nVideoHeight = pCodecCtx->height;
m_nScreenWidth = GetSystemMetrics(SM_CXSCREEN);
m_nScreenHeight = GetSystemMetrics(SM_CYSCREEN);
EC_U32 nFlag = 0;
if (m_pDrawable == EC_NULL)
nFlag = SDL_FULLSCREEN;
m_pScreen = SDL_SetVideoMode(m_nScreenWidth, m_nScreenHeight, 0, nFlag);
if (EC_NULL == m_pScreen)
return Video_Render_Err_CreatWindowFail;
m_pOverlay = SDL_CreateYUVOverlay(m_nWindowWidth, m_nWindowHeight, SDL_YV12_OVERLAY, m_pScreen);
if (EC_NULL == m_pOverlay)
return Video_Render_Err_CreatRenderFail;
SetVideoRect(&m_sSDLRect);
return Video_Render_Err_None;
}
示例2: SDL_FreeSurface
EC_VOID SDL_VideoRender::UpdateVideoScreen(MediaEngVideoScreen *pVideoScreen)
{
m_nWindowWidth = pVideoScreen->nWidth;
m_nWindowHeight = pVideoScreen->nHeight;
EC_VOIDP pDrawable = pVideoScreen->pScreen;
if (pDrawable != m_pDrawable)
{
EC_U32 nFlag = 0;
SDL_FreeSurface(m_pScreen);
if (m_pDrawable == EC_NULL) nFlag = SDL_FULLSCREEN;
m_pScreen = SDL_SetVideoMode(m_nScreenWidth, m_nScreenHeight, 0, nFlag);
}
SDL_FreeYUVOverlay(m_pOverlay);
m_pOverlay = SDL_CreateYUVOverlay(m_nWindowWidth, m_nWindowHeight, SDL_YV12_OVERLAY, m_pScreen);
SetVideoRect(&m_sSDLRect);
EraseVideoRim();
}
示例3: alloc_picture
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[is->videoIndex]);
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);
}
示例4: sdlview_configure
/**
* sdlview_configure: Configure this instance of the module. See
* tcmodule-data.h for function details.
*/
static int sdlview_configure(TCModuleInstance *self,
const char *options, vob_t *vob)
{
SDLPrivateData *pd = NULL;
int ret;
TC_MODULE_SELF_CHECK(self, "configure");
pd = self->userdata;
ret = configure_colorspace(pd, vob->im_v_codec, verbose);
if (ret != TC_OK) {
/* failure reason already tc_log()'d out */
return ret;
}
pd->w = vob->ex_v_width;
pd->h = vob->ex_v_height;
SDL_WM_SetCaption("transcode SDL preview", NULL);
pd->surface = SDL_SetVideoMode(pd->w, pd->h, 0, SDL_HWSURFACE);
if (!pd->surface) {
tc_log_error(MOD_NAME, "cannot setup SDL Video Mode: %s",
SDL_GetError());
return TC_ERROR;
}
pd->overlay = SDL_CreateYUVOverlay(pd->w, pd->h,
SDL_YV12_OVERLAY, pd->surface);
if (!pd->overlay) {
tc_log_error(MOD_NAME, "cannot setup SDL YUV overlay: %s",
SDL_GetError());
return TC_ERROR;
}
if (verbose) {
tc_log_info(MOD_NAME, "preview window: %ix%i YV12 overlay",
pd->w, pd->h);
}
return TC_OK;
}
示例5: SDL_Init
bool VideoFrame::init() {
log::info << "Starting the SDL subsystem..." << log::endl;
int result = SDL_Init(SDL_INIT_VIDEO);
if (result < 0) {
log::error << "Could not start SDL (error: " << result << ")" << log::endl;
return false;
}
char driverName[128];
SDL_VideoDriverName(driverName, sizeof (driverName));
log::info << "Using Video Driver : " << driverName << log::endl;
screen = SDL_SetVideoMode(width, height, 0, video_format);
overlay = SDL_CreateYUVOverlay(width, height, SDL_YV12_OVERLAY, screen);
SDL_WM_SetCaption(window_name.c_str(), NULL);
return true;
}
示例6: SDL_Display
void SDL_Display(int edge, int frame_width, int frame_height, unsigned char *Y, unsigned char *U, unsigned char *V){
#ifndef SDL_NO_DISPLAY
// Lock SDL_yuv_overlay
if ( SDL_MUSTLOCK(screen) ) {
if ( SDL_LockSurface(screen) < 0 ) return;
}
if (SDL_LockYUVOverlay(yuv_overlay) < 0) return;
if (frame_width != screen -> w || frame_height != screen -> h){
screen -> clip_rect . w = screen -> w = frame_width;
screen -> clip_rect . h = screen -> h = frame_height;
screen = SDL_SetVideoMode(frame_width, frame_height, 24, SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_HWACCEL);
yuv_overlay -> w = rect . w = frame_width + 2 * edge;
yuv_overlay -> h = rect . h = frame_height;
yuv_overlay = SDL_CreateYUVOverlay(frame_width + 2 * edge, frame_height, SDL_YV12_OVERLAY, screen);
}
if ( screen == NULL ) {
printf("SDL: Couldn't set %dx%d: %s", frame_width, frame_height, SDL_GetError());
exit(1);
}
// let's draw the data (*yuv[3]) on a SDL screen (*screen)
memcpy(yuv_overlay->pixels[0], Y, (frame_width + 2 * edge) * frame_height);
memcpy(yuv_overlay->pixels[1], V, (frame_width + 2 * edge) * frame_height / 4);
memcpy(yuv_overlay->pixels[2], U, (frame_width + 2 * edge) * frame_height / 4);
// Unlock SDL_yuv_overlay
if ( SDL_MUSTLOCK(screen) ) {
SDL_UnlockSurface(screen);
}
SDL_UnlockYUVOverlay(yuv_overlay);
// Show, baby, show!
SDL_DisplayYUVOverlay(yuv_overlay, &rect);
#endif
}
示例7: init_sdl_window
SDL_Overlay * init_sdl_window(AVCodecContext * pCodecCtx, SDL_Overlay * bmp)
{
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER))
{
fprintf(stderr, "Nao foi possivel inicializar o SDL - %s\n", SDL_GetError());
return NULL;
}
SDL_Surface * screen;
screen = SDL_SetVideoMode(1280, 720, 0, 0);
if (!screen)
{
fprintf(stderr, "SDL: Nao foi possivel configurar o modo do video\n");
return NULL;
}
bmp = SDL_CreateYUVOverlay(pCodecCtx->width, pCodecCtx->height, SDL_YV12_OVERLAY, screen);
return bmp;
}
示例8: SdlVideoOutput_CreateWindow
/*----------------------------------------------------------------------
| SdlVideoOutput_CreateWindow
+---------------------------------------------------------------------*/
static BLT_Result
SdlVideoOutput_CreateWindow(SdlVideoOutput* self)
{
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
ATX_LOG_WARNING("SdlVideoOutput_CreateWindow - cannot init SDL");
return BLT_FAILURE;
}
self->screen = SDL_SetVideoMode(1000, 600, 24, SDL_HWSURFACE | SDL_RESIZABLE);
if (self->screen == NULL) {
ATX_LOG_WARNING("SdlVideoOutput_CreateWindow - SDL_SetVideoMode() failed");
return BLT_FAILURE;
}
self->yuv_overlay = SDL_CreateYUVOverlay(1000, 600, SDL_YV12_OVERLAY, self->screen);
if (self->yuv_overlay == NULL) {
ATX_LOG_WARNING("SdlVideoOutput_CreateWindow - SDL_CreateYUVOverlay() failed");
return BLT_FAILURE;
}
return BLT_SUCCESS;
}
示例9: sdl_port_set_format
/** Set format on a port */
static MMAL_STATUS_T sdl_port_set_format(MMAL_PORT_T *port)
{
MMAL_COMPONENT_T *component = port->component;
MMAL_COMPONENT_MODULE_T *module = component->priv->module;
MMAL_STATUS_T status;
if ((status=mmal_sdl_create_surface(module)) != MMAL_SUCCESS)
return status;
/* We only support I420 */
if (port->format->encoding != MMAL_ENCODING_I420)
return MMAL_ENOSYS;
/* Check if we need to re-create an overlay */
if (module->sdl_overlay &&
module->width == port->format->es->video.width &&
module->height == port->format->es->video.height)
return MMAL_SUCCESS; /* Nothing to do */
if (module->sdl_overlay)
SDL_FreeYUVOverlay(module->sdl_overlay);
/* Create overlay */
module->sdl_overlay =
SDL_CreateYUVOverlay(port->format->es->video.width,
port->format->es->video.height,
SDL_YV12_OVERLAY, module->sdl_surface);
if (!module->sdl_overlay)
{
LOG_ERROR("cannot create SDL overlay");
return MMAL_ENOSPC;
}
module->width = port->format->es->video.width;
module->height = port->format->es->video.height;
port->buffer_size_min = module->width * module->height * 3 / 2;
return MMAL_SUCCESS;
}
示例10: sdl_init
Uint32 sdl_init(void)
{
/* SDL init */
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
fprintf(stderr, "Unable to set video mode: %s\n", SDL_GetError());
atexit(SDL_Quit);
return 0;
}
info = SDL_GetVideoInfo();
if (!info) {
fprintf(stderr, "SDL ERROR Video query failed: %s\n", SDL_GetError());
SDL_Quit();
return 0;
}
P.bpp = info->vfmt->BitsPerPixel;
if (info->hw_available){
P.vflags = SDL_HWSURFACE;
} else {
P.vflags = SDL_SWSURFACE;
}
if ((screen = SDL_SetVideoMode(P.width, P.height, P.bpp, P.vflags)) == 0) {
fprintf(stderr, "SDL ERROR Video mode set failed: %s\n", SDL_GetError());
SDL_Quit();
return 0;
}
my_overlay = SDL_CreateYUVOverlay(P.width, P.height, P.overlay_format, screen);
if (!my_overlay) {
fprintf(stderr, "Couldn't create overlay\n");
return 0;
}
return 1;
}
示例11: Overlay_New
PyObject*
Overlay_New (PyTypeObject *type, PyObject *args, PyObject *kwds)
{
int pixelformat;
PyGameOverlay *self;
int w, h;
SDL_Surface *screen;
if (!PyArg_ParseTuple (args, "i(ii)", &pixelformat, &w, &h))
return NULL;
if (!SDL_WasInit (SDL_INIT_VIDEO))
return RAISE
(PyExc_SDLError,
"cannot create overlay without pygame.display initialized");
screen = SDL_GetVideoSurface ();
if (!screen)
return RAISE (PyExc_SDLError, "Display mode not set");
// Create new Overlay object
self= (PyGameOverlay *)type->tp_alloc (type, 0);
if (!self)
return NULL;
// Create layer with desired format
self->cOverlay = SDL_CreateYUVOverlay (w, h, pixelformat, screen);
if (!self->cOverlay)
return RAISE (PyExc_SDLError, "Cannot create overlay");
self->cRect.x= 0;
self->cRect.y= 0;
self->cRect.w= w;
self->cRect.h= h;
return (PyObject*)self;
}
示例12: alloc_picture
/* allocate a picture (needs to do that in main thread to avoid
potential locking problems */
void alloc_picture(void *userdata) {
VideoState *is = (VideoState *)userdata;
Frame *vp;
vp = &is->pictq.queue[is->pictq.windex];
if (vp->bmp) {
// we already have one make another, bigger/smaller
SDL_FreeYUVOverlay(vp->bmp);
vp->bmp = NULL;
}
// Allocate a place to put our YUV image on that screen
SDL_LockMutex(screen_mutex);
vp->bmp = SDL_CreateYUVOverlay(is->video_ctx->width,
is->video_ctx->height,
SDL_YV12_OVERLAY,
screen);
SDL_UnlockMutex(screen_mutex);
vp->width = is->video_ctx->width;
vp->height = is->video_ctx->height;
SDL_LockMutex(is->pictq.mutex);
vp->allocated = 1;
SDL_CondSignal(is->pictq.cond);
SDL_UnlockMutex(is->pictq.mutex);
}
示例13: main
//.........这里部分代码省略.........
if(pCodec==NULL) {
fprintf(stderr, "Unsupported codec!\n");
return -1; // Codec not found
}
// Open codec
if(avcodec_open(pCodecCtx, pCodec)<0) {
fprintf(stderr, "Cannot open video codec!\n");
return -1; // Could not open codec
}
// construct the scale context, conversing to PIX_FMT_YUV420P
img_convert_ctx = sws_getContext(pCodecCtx->width, pCodecCtx->height,pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height, PIX_FMT_YUV420P, SWS_BICUBIC, NULL, NULL, NULL);// other codes
if (img_convert_ctx == NULL) {
fprintf(stderr, "Cannot initialize the conversion context!\n");
return -1;
}
// Allocate video frame
pFrame=avcodec_alloc_frame();
// Make a screen to put our video
#ifndef __DARWIN__
screen = SDL_SetVideoMode(pCodecCtx->width, pCodecCtx->height, 0, 0);
#else
screen = SDL_SetVideoMode(pCodecCtx->width, pCodecCtx->height, 24, 0);
#endif
if(!screen) {
fprintf(stderr, "SDL: could not set video mode - exiting\n");
exit(1);
}
// Allocate a place to put our YUV image on that screen
bmp = SDL_CreateYUVOverlay(pCodecCtx->width,
pCodecCtx->height,
SDL_YV12_OVERLAY,
screen);
// Read frames and save first five frames to disk
i=0;
while(av_read_frame(pFormatCtx, &packet)>=0) {
// Is this a packet from the video stream?
if(packet.stream_index==videoStream) {
// Decode video frame
avcodec_decode_video(pCodecCtx, pFrame, &frameFinished,
packet.data, packet.size);
// Did we get a video frame?
if(frameFinished) {
SDL_LockYUVOverlay(bmp);
AVPicture pict;
pict.data[0] = bmp->pixels[0];
pict.data[1] = bmp->pixels[2];
pict.data[2] = bmp->pixels[1];
pict.linesize[0] = bmp->pitches[0];
pict.linesize[1] = bmp->pitches[2];
pict.linesize[2] = bmp->pitches[1];
// Convert the image into YUV format that SDL uses
/*
img_convert(&pict, PIX_FMT_YUV420P,
(AVPicture *)pFrame, pCodecCtx->pix_fmt,
pCodecCtx->width, pCodecCtx->height);
示例14: ffmovie_setdisplay
void ffmovie_setdisplay(FFMovie *movie, SDL_Surface *dest, SDL_Rect *rect)
{
/*MAIN THREAD*/
if(!movie->video_st || movie->abort_request || movie->context==NULL) {
/*This movie has no video stream, or finished*/
return;
}
SDL_LockMutex(movie->dest_mutex);
if(movie->dest_overlay) {
/*clean any existing overlay*/
SDL_FreeYUVOverlay(movie->dest_overlay);
movie->dest_overlay = NULL;
}
if(!dest) {
/*no destination*/
movie->dest_overlay = NULL;
} else {
if(rect) {
movie->dest_rect.x = rect->x;
movie->dest_rect.y = rect->y;
movie->dest_rect.w = rect->w;
movie->dest_rect.h = rect->h;
} else {
movie->dest_rect.x = 0;
movie->dest_rect.y = 0;
movie->dest_rect.w = 0;
movie->dest_rect.h = 0;
}
if(movie->dest_rect.w == 0) {
movie->dest_rect.w = MIN(movie->video_st->codec.width, dest->w);
}
if(movie->dest_rect.h == 0) {
movie->dest_rect.h = MIN(movie->video_st->codec.height, dest->h);
}
#if 0
/* XXX: use generic function */
/* XXX: disable overlay if no hardware acceleration or if RGB format */
switch(movie->video_st->codec.pix_fmt) {
case PIX_FMT_YUV420P:
case PIX_FMT_YUV422P:
case PIX_FMT_YUV444P:
case PIX_FMT_YUV422:
case PIX_FMT_YUV410P:
case PIX_FMT_YUV411P:
is_yuv = 1;
break;
default:
is_yuv = 0;
break;
}
#endif
movie->dest_surface = dest;
movie->dest_overlay = SDL_CreateYUVOverlay(
movie->video_st->codec.width,
movie->video_st->codec.height,
SDL_YV12_OVERLAY, dest);
}
SDL_UnlockMutex(movie->dest_mutex);
/*set display time to now, force redraw*/
movie->dest_showtime = get_master_clock(movie);
}
示例15: plat_sdl_change_video_mode
/* w, h is layer resolution */
int plat_sdl_change_video_mode(int w, int h, int force)
{
static int prev_w, prev_h;
if (w == 0)
w = prev_w;
else
prev_w = w;
if (h == 0)
h = prev_h;
else
prev_h = h;
plat_target.vout_method=vout_mode_overlay;
// invalid method might come from config..
if (plat_target.vout_method != 0
&& plat_target.vout_method != vout_mode_overlay
&& plat_target.vout_method != vout_mode_gl)
{
fprintf(stderr, "invalid vout_method: %d\n", plat_target.vout_method);
plat_target.vout_method = 0;
}
// skip GL recreation if window doesn't change - avoids flicker
if (plat_target.vout_method == vout_mode_gl && plat_sdl_gl_active
&& plat_target.vout_fullscreen == old_fullscreen && !force)
{
return 0;
}
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;
}
if (plat_target.vout_method != 0) {
Uint32 flags = SDL_RESIZABLE | SDL_SWSURFACE;
int win_w = window_w;
int win_h = window_h;
if (plat_target.vout_fullscreen) {
flags |= SDL_FULLSCREEN;
win_w = fs_w;
win_h = fs_h;
}
// XXX: workaround some occasional mysterious deadlock in SDL_SetVideoMode
// (seen on r-pi)
SDL_PumpEvents();
unsigned int user_width = 0;
sscanf(getenv("PCSX_WIDTH"), "%d", &user_width);
if(user_width == 0)
user_width=win_h;
plat_sdl_screen = SDL_SetVideoMode(/*win_w*/ /*win_h*4/3*/ /*640*/ user_width*4/3, /*win_h*/ /*512*/ user_width, 0, flags);
if (plat_sdl_screen == NULL) {
fprintf(stderr, "SDL_SetVideoMode failed: %s\n", SDL_GetError());
plat_target.vout_method = 0;
}
}
if (plat_target.vout_method == vout_mode_overlay) {
plat_sdl_overlay = SDL_CreateYUVOverlay(w, h, SDL_UYVY_OVERLAY, plat_sdl_screen);
if (plat_sdl_overlay != NULL) {
if ((long)plat_sdl_overlay->pixels[0] & 3)
fprintf(stderr, "warning: overlay pointer is unaligned\n");
plat_sdl_overlay_clear();
}
else {
fprintf(stderr, "warning: could not create overlay.\n");
plat_target.vout_method = 0;
}
}
else if (plat_target.vout_method == vout_mode_gl) {
plat_sdl_gl_active = (gl_init(display, window, &gl_quirks) == 0);
if (!plat_sdl_gl_active) {
fprintf(stderr, "warning: could not init GL.\n");
plat_target.vout_method = 0;
}
}
if (plat_target.vout_method == 0) {
SDL_PumpEvents();
plat_sdl_screen = SDL_SetVideoMode(w, h, 16, SDL_SWSURFACE);
if (plat_sdl_screen == NULL) {
fprintf(stderr, "SDL_SetVideoMode failed: %s\n", SDL_GetError());
return -1;
}
}
old_fullscreen = plat_target.vout_fullscreen;
if (plat_sdl_resize_cb != NULL)
plat_sdl_resize_cb(plat_sdl_screen->w, plat_sdl_screen->h);
//.........这里部分代码省略.........