当前位置: 首页>>代码示例>>C++>>正文


C++ SDL_DisplayYUVOverlay函数代码示例

本文整理汇总了C++中SDL_DisplayYUVOverlay函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_DisplayYUVOverlay函数的具体用法?C++ SDL_DisplayYUVOverlay怎么用?C++ SDL_DisplayYUVOverlay使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SDL_DisplayYUVOverlay函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sdlview_filter_video

static int sdlview_filter_video(TCModuleInstance *self, vframe_list_t *frame)
{
    int ret = 0;
    uint8_t *src_planes[3] = { NULL, NULL, NULL };
    uint8_t *dst_planes[3] = { NULL, NULL, NULL };
    SDLPrivateData *pd = NULL;

    TC_MODULE_SELF_CHECK(self, "filter_video");
    TC_MODULE_SELF_CHECK(frame, "filter_video");

    pd = self->userdata;

    SDL_LockYUVOverlay(pd->overlay);

    YUV_INIT_PLANES(src_planes, frame->video_buf,
                    pd->src_fmt, pd->w, pd->h);
    dst_planes[0] = pd->overlay->pixels[0];
    dst_planes[1] = pd->overlay->pixels[1];
    dst_planes[2] = pd->overlay->pixels[2];

    ret = ac_imgconvert(src_planes, pd->src_fmt, dst_planes, IMG_YV12,
                        pd->w, pd->h);

    SDL_UnlockYUVOverlay(pd->overlay);

    pd->rectangle.x = 0;
    pd->rectangle.y = 0;
    pd->rectangle.w = pd->w;
    pd->rectangle.h = pd->h;

    SDL_DisplayYUVOverlay(pd->overlay, &(pd->rectangle)); 
    /* this one can fail? */

    return TC_OK;
}
开发者ID:BackupTheBerlios,项目名称:tcforge-svn,代码行数:35,代码来源:filter_sdlview.c

示例2: Draw

void
Draw()
{
    SDL_Rect rect;
    int i;
    int disp;

    if (!scale) {
        rect.w = overlay->w;
        rect.h = overlay->h;
        for (i = 0; i < h - rect.h && i < w - rect.w; i++) {
            rect.x = i;
            rect.y = i;
            SDL_DisplayYUVOverlay(overlay, &rect);
        }
    } else {
        rect.w = overlay->w / 2;
        rect.h = overlay->h / 2;
        rect.x = (w - rect.w) / 2;
        rect.y = (h - rect.h) / 2;
        disp = rect.y - 1;
        for (i = 0; i < disp; i++) {
            rect.w += 2;
            rect.h += 2;
            rect.x--;
            rect.y--;
            SDL_DisplayYUVOverlay(overlay, &rect);
        }
    }
    printf("Displayed %d times.\n", i);
}
开发者ID:Bergasms,项目名称:N64iOS,代码行数:31,代码来源:testoverlay.c

示例3: put_frame

    bool put_frame(AVFrame *frame)
    {
        if (frame)
        {
            SDL_LockYUVOverlay(overlay_);
            pict_.data[0] = overlay_->pixels[0];
            pict_.data[1] = overlay_->pixels[2];
            pict_.data[2] = overlay_->pixels[1];

            pict_.linesize[0] = overlay_->pitches[0];
            pict_.linesize[1] = overlay_->pitches[2];
            pict_.linesize[2] = overlay_->pitches[1];

            // Convert the image into YUV format that SDL uses
            if (sws_context_)
            {
                sws_scale(sws_context_, (uint8_t const * const *)frame->data,
                          frame->linesize, 0, height_,
                          pict_.data, pict_.linesize);;
            }
            SDL_UnlockYUVOverlay(overlay_);
            SDL_DisplayYUVOverlay(overlay_, &rect_);
            return true;
        }
        return false;
    }
开发者ID:tempbottle,项目名称:AVRemoteControl,代码行数:26,代码来源:sdloverlayport.hpp

示例4: open_video

static void open_video(void){
  /* taken from player_sample.c test file for theora alpha */

  if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
    printf("Unable to initialize SDL: %s\n", SDL_GetError());
    exit(1);
  }
  
  screen = SDL_SetVideoMode(ti.frame_width, ti.frame_height, 0, SDL_SWSURFACE);
  if ( screen == NULL ) {
    printf("Unable to set %dx%d video mode: %s\n", 
           ti.frame_width,ti.frame_height,SDL_GetError());
    exit(1);
  }
  
  yuv_overlay = SDL_CreateYUVOverlay(ti.frame_width, ti.frame_height,
				     SDL_YV12_OVERLAY,
				     screen);
  if ( yuv_overlay == NULL ) {
    printf("SDL: Couldn't create SDL_yuv_overlay: %s\n", 
	   SDL_GetError());
    exit(1);
  }
  rect.x = 0;
  rect.y = 0;
  rect.w = ti.frame_width;
  rect.h = ti.frame_height;

  SDL_DisplayYUVOverlay(yuv_overlay, &rect);
}
开发者ID:kazutomi,项目名称:xiphqt,代码行数:30,代码来源:splayer.c

示例5: video_display

void video_display(VideoState *is) {

    SDL_Rect rect;
    VideoPicture *vp;
    float aspect_ratio;
    int w, h, x, y;
    
    vp = &is->pictq[is->pictq_rindex];
    if(vp->bmp) {
        if(is->video_st->codec->sample_aspect_ratio.num == 0) {
            aspect_ratio = 0;
        } else {
            aspect_ratio = av_q2d(is->video_st->codec->sample_aspect_ratio) *
                is->video_st->codec->width / is->video_st->codec->height;
        }
        if(aspect_ratio <= 0.0) {
            aspect_ratio = (float)is->video_st->codec->width /
                (float)is->video_st->codec->height;
        }
        h = screen->h;
        w = ((int)rint(h * aspect_ratio)) & -3;
        if(w > screen->w) {
            w = screen->w;
            h = ((int)rint(w / aspect_ratio)) & -3;
        }
        x = (screen->w - w) / 2;
        y = (screen->h - h) / 2;

        rect.x = x;
        rect.y = y;
        rect.w = w;
        rect.h = h;
        SDL_DisplayYUVOverlay(vp->bmp, &rect);
    }
}
开发者ID:huamulan,项目名称:ffmpeg-tutor,代码行数:35,代码来源:tutorial05.c

示例6: Init_SDL

int Init_SDL(int edge, int frame_width, int frame_height){
	
#ifndef SDL_NO_DISPLAY	
	int screenwidth = 0, screenheight = 0;
	unsigned char *yuv[3];
	char *window_title = "SDL Display";


	/* First, initialize SDL's video subsystem. */
	if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) {
		/* Failed, exit. */
		printf("Video initialization failed: %s\n", SDL_GetError( ) );
	}

	// set window title 
	SDL_WM_SetCaption(window_title, NULL);

	// yuv params
	yuv[0] = malloc((frame_width + 2 * edge) * frame_height * sizeof(unsigned char));
	yuv[1] = malloc((frame_width + edge) * frame_height / 4 * sizeof(unsigned char));
	yuv[2] = malloc((frame_width + edge) * frame_height / 4 * sizeof(unsigned char));

	screenwidth = frame_width;
	screenheight = frame_height;

	
	screen = SDL_SetVideoMode(screenwidth, screenheight, 24, SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_HWACCEL);

	if ( screen == NULL ) {
		printf("SDL: Couldn't set %dx%d: %s", screenwidth, screenheight, SDL_GetError());
		exit(1);
	}
	else {
		printf("SDL: Set %dx%d @ %d bpp \n",screenwidth, screenheight, screen->format->BitsPerPixel);
	}

	// since IYUV ordering is not supported by Xv accel on maddog's system
	//  (Matrox G400 --- although, the alias I420 is, but this is not
	//  recognized by SDL), we use YV12 instead, which is identical,
	//  except for ordering of Cb and Cr planes...
	// we swap those when we copy the data to the display buffer...

	yuv_overlay = SDL_CreateYUVOverlay(frame_width + 2 * edge, frame_height, SDL_YV12_OVERLAY, screen);

	if ( yuv_overlay == NULL ) {
		printf("SDL: Couldn't create SDL_yuv_overlay: %s",SDL_GetError());
		exit(1);
	}


	rect.x = 0;
	rect.y = 0;
	rect.w = screenwidth + 2 * edge;
	rect.h = screenheight;
	SDL_UnlockYUVOverlay(yuv_overlay);

	SDL_DisplayYUVOverlay(yuv_overlay, &rect);
#endif
	return 0;
}
开发者ID:ArineYao,项目名称:openHEVC,代码行数:60,代码来源:sdl.c

示例7: vj_sdl_update_yuv_overlay

int vj_sdl_update_yuv_overlay(vj_sdl * vjsdl, uint8_t ** yuv420)
{
	if (!vj_sdl_lock(vjsdl))
		return 0;
#ifdef HAVE_SDL_TTF
	if( veejay_log_to_ringbuffer() ) {
		vj_sdl_draw_to_buffer( vjsdl->font, vjsdl->width, vjsdl->height );
		vj_sdl_font_logging( vjsdl->font, yuv420, vjsdl->width, vjsdl->height );
	}
#endif
	VJFrame *src_frame = (VJFrame*) vjsdl->src_frame;
	VJFrame *dst_frame = (VJFrame*) vjsdl->dst_frame;

	src_frame->data[0] = yuv420[0];
	src_frame->data[1] = yuv420[1];
	src_frame->data[2] = yuv420[2];
	dst_frame->data[0] = vjsdl->yuv_overlay->pixels[0];

	yuv_convert_and_scale_packed( vjsdl->scaler, vjsdl->src_frame,dst_frame );

	if (!vj_sdl_unlock(vjsdl))
		return 0;

	SDL_DisplayYUVOverlay(vjsdl->yuv_overlay, &(vjsdl->rectangle));

	return 1;
}
开发者ID:c0ntrol,项目名称:veejay,代码行数:27,代码来源:vj-sdl.c

示例8: open_video

static void open_video(void){
  if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
    fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
    exit(1);
  }

  screen = SDL_SetVideoMode(ti.frame_width, ti.frame_height, 0, SDL_SWSURFACE);
  if ( screen == NULL ) {
    fprintf(stderr, "Unable to set %dx%d video: %s\n",
            ti.frame_width,ti.frame_height,SDL_GetError());
    exit(1);
  }

  yuv_overlay = SDL_CreateYUVOverlay(ti.frame_width, ti.frame_height,
                                     SDL_YV12_OVERLAY,
                                     screen);
  if ( yuv_overlay == NULL ) {
    fprintf(stderr, "SDL: Couldn't create SDL_yuv_overlay: %s\n",
            SDL_GetError());
    exit(1);
  }
  rect.x = 0;
  rect.y = 0;
  rect.w = ti.frame_width;
  rect.h = ti.frame_height;

  SDL_DisplayYUVOverlay(yuv_overlay, &rect);
}
开发者ID:petterreinholdtsen,项目名称:cinelerra-hv,代码行数:28,代码来源:player_example.c

示例9: render_sdl

void render_sdl (uint8_t *mybuffer) {
	/* http://www.fourcc.org/indexyuv.htm */

	size_t Ylen= movie_width * movie_height;
	size_t UVlen= movie_width/2 * movie_height/2; 

	// decode ffmpeg - YUV 
	uint8_t *Yptr=mybuffer;
	uint8_t *Uptr=Yptr + Ylen;
	uint8_t *Vptr=Uptr + UVlen;

	if (sdl_pic_format == SDL_YV12_OVERLAY) { 
	// encode SDL YV12
		stride_memcpy(sdl_overlay->pixels[0],Yptr,movie_width,movie_height,sdl_overlay->pitches[0],movie_width);//Y
		stride_memcpy(sdl_overlay->pixels[1],Vptr,movie_width/2,movie_height/2,sdl_overlay->pitches[1],movie_width/2);//V
		stride_memcpy(sdl_overlay->pixels[2],Uptr,movie_width/2,movie_height/2,sdl_overlay->pitches[2],movie_width/2);//U
	} else {
	// encode SDL YUV
		stride_memcpy(sdl_overlay->pixels[0],Yptr,movie_width,movie_height,sdl_overlay->pitches[0],movie_width);//Y
		stride_memcpy(sdl_overlay->pixels[1],Uptr,movie_width/2,movie_height/2,sdl_overlay->pitches[1],movie_width/2);//U
		stride_memcpy(sdl_overlay->pixels[2],Vptr,movie_width/2,movie_height/2,sdl_overlay->pitches[2],movie_width/2);//V
	}

	SDL_UnlockYUVOverlay(sdl_overlay);
	SDL_DisplayYUVOverlay(sdl_overlay, &sdl_dest_rect);
	SDL_LockYUVOverlay(sdl_overlay);
}
开发者ID:krytarowski,项目名称:xjadeo,代码行数:27,代码来源:display_sdl.c

示例10: SDL_VideoDisplayThread

//==================Video======================
static void SDL_VideoDisplayThread(void *)
{
    SDL_Rect rect;
    while(runFlag)
    {
        Sleep(GUISLEEPTIME);

        AVFrame* frame;
        char *data;
        int size;
        if(tunnel.isServerConnected()&&tunnel.getVideoData(&data,&size))
        {
            if(vdecoder.decodeVideoFrame((char*)data,size,&frame))
            {
                SDL_LockYUVOverlay(screenOverlay);
                screenOverlay->pixels[0]=frame->data[0];
                screenOverlay->pixels[1]=frame->data[1];
                screenOverlay->pixels[2]=frame->data[2];
                screenOverlay->pitches[0]=frame->linesize[0];
                screenOverlay->pitches[1]=frame->linesize[1];
                screenOverlay->pitches[2]=frame->linesize[2];
                rect.w = RWIDTH;
                rect.h = RHEIGHT;
                rect.x=0;
                rect.y=0;
                SDL_DisplayYUVOverlay(screenOverlay, &rect);
                SDL_UnlockYUVOverlay(screenOverlay);
            }
            free(data);
        }

    }

}
开发者ID:polyu,项目名称:Cloud_Game,代码行数:35,代码来源:GameWindow.cpp

示例11: display_received_frame

int display_received_frame(codec_state *cs, AVFrame *r_video_frame)
{
    AVPicture pict;
    SDL_LockYUVOverlay(cs->video_picture.bmp);

    pict.data[0] = cs->video_picture.bmp->pixels[0];
    pict.data[1] = cs->video_picture.bmp->pixels[2];
    pict.data[2] = cs->video_picture.bmp->pixels[1];
    pict.linesize[0] = cs->video_picture.bmp->pitches[0];
    pict.linesize[1] = cs->video_picture.bmp->pitches[2];
    pict.linesize[2] = cs->video_picture.bmp->pitches[1];

    /* Convert the image into YUV format that SDL uses */
    sws_scale(cs->sws_SDL_r_ctx, (uint8_t const * const *)r_video_frame->data, r_video_frame->linesize, 0,
              cs->video_decoder_ctx->height, pict.data, pict.linesize );

    SDL_UnlockYUVOverlay(cs->video_picture.bmp);
    SDL_Rect rect;
    rect.x = 0;
    rect.y = 0;
    rect.w = cs->video_decoder_ctx->width;
    rect.h = cs->video_decoder_ctx->height;
    SDL_DisplayYUVOverlay(cs->video_picture.bmp, &rect);
    return 1;
}
开发者ID:okiyama,项目名称:ProjectTox-Core,代码行数:25,代码来源:AV_codec.c

示例12: sdlemu_draw_overlay

inline void sdlemu_draw_overlay(SDL_Surface *s, int size, int width, int height)
{
        static SDL_Rect		  src;
        static SDL_Rect		  dest;

        src.x  = 0;
        src.y  = 0;
        src.w  = width;
        src.h  = height;
        dest.x = 0;
        dest.y = 0;
        dest.w = width;
        dest.h = height;

		SDL_LockYUVOverlay(overlay);

        Convert32bit(s);

		overlay_rect.x = 0;
		overlay_rect.y = 0;
		overlay_rect.w = width  * size;
		overlay_rect.h = height * size;

		SDL_DisplayYUVOverlay( overlay, &overlay_rect);
		SDL_UnlockYUVOverlay(overlay);
}
开发者ID:alexthissen,项目名称:handy-fork,代码行数:26,代码来源:sdlemu_overlay.c

示例13: av_sync

void
av_sync(void)
{
	int num_rect = 0;
	SDL_Rect r;

#ifdef PROFILE_GRAPHICS
	float tot_area = 0;
	int i = 0;
	Uint32 ticks = SDL_GetTicks();
#endif

	SDL_Scale2x(screen_surf, screen_surf2x);
	/* copy palette and handle fading! */
	transform_palette();
	SDL_SetColors(screen_surf2x, pal_colors, 0, 256);
	SDL_BlitSurface(screen_surf2x, NULL, display, NULL);
	if (video_rect.h && video_rect.w)
	{
		av_need_update(&video_rect);
		r.h = 2 * video_rect.h;
		r.w = 2 * video_rect.w;
		r.x = 2 * video_rect.x;
		r.y = 2 * video_rect.y;
		SDL_DisplayYUVOverlay(video_overlay, &r);
	}
	if (news_rect.h && news_rect.w)
	{
		av_need_update(&news_rect);
		r.h = 2 * news_rect.h;
		r.w = 2 * news_rect.w;
		r.x = 2 * news_rect.x;
		r.y = 2 * news_rect.y;
		SDL_DisplayYUVOverlay(news_overlay, &r);
	}
	num_rect = get_dirty_rect_list();
	SDL_UpdateRects(display, num_rect, dirty_rect_list);
#ifdef PROFILE_GRAPHICS
	for (i = 0; i < num_rect; ++i)
		tot_area += dirty_rect_list[i].w * dirty_rect_list[i].h;
	tot_area = tot_area * 100 / (2 * MAX_X) / (2 * MAX_Y);
	TRACE4("%3d rects (%6.2f%%) updated in ~%3ums\n",
		num_rect, tot_area, SDL_GetTicks() - ticks);
#endif
	screen_dirty = 0;
}
开发者ID:getir-hackathon-2016,项目名称:raceintospace-cvs,代码行数:46,代码来源:sdl.c

示例14: SDL_LockYUVOverlay

/** Show image from given colorspace.
 * @param colorspace colorspace of the supplied buffer
 * @param buffer image buffer
 */
void
ImageDisplay::show(colorspace_t colorspace, unsigned char *buffer)
{
	SDL_LockYUVOverlay(_overlay);
	convert(colorspace, YUV422_PACKED, buffer, _overlay->pixels[0], _width, _height);
	SDL_UnlockYUVOverlay(_overlay);
	SDL_DisplayYUVOverlay(_overlay, _rect);
}
开发者ID:fawkesrobotics,项目名称:fawkes,代码行数:12,代码来源:image_display.cpp

示例15: Overlay_Display

static PyObject*
Overlay_Display (PyGameOverlay *self, PyObject *args)
{
    SDL_Rect cRect;
    // Parse data params for frame
    int ls_y, ls_u, ls_v, y;
    unsigned char *src_y=0, *src_u=0, *src_v=0;

    if (PyTuple_Size (args))
    {
        if (!PyArg_ParseTuple (args, "(s#s#s#)", &src_y, &ls_y, &src_u, &ls_u,
                               &src_v, &ls_v))
            return NULL;
    }

    if (src_y)
    {
        Uint8 *dst_y=0, *dst_u=0, *dst_v=0;
        SDL_LockYUVOverlay (self->cOverlay);

        // No clipping at this time( only support for YUV420 )

        dst_y = self->cOverlay->pixels[0];
        dst_v = self->cOverlay->pixels[1];
        dst_u = self->cOverlay->pixels[2];

        for (y = 0; y < self->cOverlay->h; y++)
        {
            memcpy (dst_y, src_y, self->cOverlay->w);

            src_y += ls_y / self->cOverlay->h;
            dst_y += self->cOverlay->pitches[0];

            if (!(y & 1))
            {
                src_u += (ls_u * 2)/self->cOverlay->h;
                src_v += (ls_v * 2)/self->cOverlay->h;
                dst_u += self->cOverlay->pitches[ 1 ];
                dst_v += self->cOverlay->pitches[ 2 ];
            }
            else
            {
                memcpy (dst_u, src_u, (ls_u * 2) / self->cOverlay->h);
                memcpy (dst_v, src_v, (ls_v * 2) / self->cOverlay->h);
            }
        }

        SDL_UnlockYUVOverlay (self->cOverlay);
    }

    cRect.x = self->cRect.x;
    cRect.y = self->cRect.y;
    cRect.w = self->cRect.w;
    cRect.h = self->cRect.h;
    SDL_DisplayYUVOverlay (self->cOverlay, &cRect);

    Py_RETURN_NONE;
}
开发者ID:Mrhjx2,项目名称:pygame,代码行数:58,代码来源:overlay.c


注:本文中的SDL_DisplayYUVOverlay函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。