mirror of
https://github.com/mpv-player/mpv
synced 2025-03-25 04:38:01 +00:00
direct rendering support
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4972 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
0954953681
commit
cba305ead5
@ -189,6 +189,7 @@ unsigned int t=GetTimer();
|
||||
unsigned int t2;
|
||||
double tt;
|
||||
|
||||
sh_video->video_out=video_out;
|
||||
mpi=mpvdec->decode(sh_video, start, in_size, drop_frame);
|
||||
|
||||
//------------------------ frame decoded. --------------------
|
||||
@ -215,7 +216,7 @@ if(benchmark)
|
||||
cur_video_time_usage=tt;
|
||||
}
|
||||
|
||||
if(!(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALBACK))){
|
||||
if(!(mpi->flags&(MP_IMGFLAG_DIRECT|MP_IMGFLAG_DRAW_CALLBACK))){
|
||||
// blit frame:
|
||||
if(mpi->flags&MP_IMGFLAG_PLANAR)
|
||||
video_out->draw_slice(mpi->planes,mpi->stride,sh_video->disp_w,sh_video->disp_h,0,0);
|
||||
|
@ -62,6 +62,8 @@ vd_functions_t* mpcodecs_vd_drivers[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
#include "libvo/video_out.h"
|
||||
|
||||
int mpcodecs_config_vo(sh_video_t *sh, int w, int h, unsigned int preferred_outfmt){
|
||||
|
||||
return 1;
|
||||
@ -109,8 +111,8 @@ mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, i
|
||||
}
|
||||
if(mpi){
|
||||
mpi->type=mp_imgtype;
|
||||
mpi->flags&=~(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE);
|
||||
mpi->flags|=mp_imgflag&(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE);
|
||||
mpi->flags&=~(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE|MP_IMGFLAG_DIRECT);
|
||||
mpi->flags|=mp_imgflag&(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE|MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ACCEPT_WIDTH|MP_IMGFLAG_ALIGNED_STRIDE|MP_IMGFLAG_DRAW_CALLBACK);
|
||||
if((mpi->width!=w2 || mpi->height!=h) && !(mpi->flags&MP_IMGFLAG_DIRECT)){
|
||||
mpi->width=w2;
|
||||
mpi->height=h;
|
||||
@ -120,16 +122,15 @@ mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, i
|
||||
mpi->flags&=~MP_IMGFLAG_ALLOCATED;
|
||||
}
|
||||
}
|
||||
if(!mpi->bpp){
|
||||
mp_image_setfmt(mpi,sh->codec->outfmt[sh->outfmtidx]);
|
||||
if(!(mpi->flags&(MP_IMGFLAG_ALLOCATED|MP_IMGFLAG_DIRECT))
|
||||
&& mpi->type>MP_IMGTYPE_EXPORT){
|
||||
if(!mpi->bpp) mp_image_setfmt(mpi,sh->codec->outfmt[sh->outfmtidx]);
|
||||
if(!(mpi->flags&MP_IMGFLAG_ALLOCATED) && mpi->type>MP_IMGTYPE_EXPORT){
|
||||
|
||||
// check libvo first!
|
||||
vo_functions_t* vo=sh->video_out;
|
||||
if(vo) vo->control(VOCTRL_GET_IMAGE,mpi);
|
||||
|
||||
if(!(mpi->flags&MP_IMGFLAG_DIRECT)){
|
||||
// non-direct and not yet allocaed image. allocate it!
|
||||
printf("*** Allocating mp_image_t, %dx%dx%dbpp %s %s, %d bytes\n",
|
||||
mpi->width,mpi->height,mpi->bpp,
|
||||
(mpi->flags&MP_IMGFLAG_YUV)?"YUV":"RGB",
|
||||
(mpi->flags&MP_IMGFLAG_PLANAR)?"planar":"packed",
|
||||
mpi->bpp*mpi->width*mpi->height/8);
|
||||
mpi->planes[0]=memalign(64, mpi->bpp*mpi->width*mpi->height/8);
|
||||
if(mpi->flags&MP_IMGFLAG_PLANAR){
|
||||
// YV12/I420. feel free to add other planar formats here...
|
||||
@ -141,7 +142,17 @@ mp_image_t* mpcodecs_get_image(sh_video_t *sh, int mp_imgtype, int mp_imgflag, i
|
||||
if(!mpi->stride[0]) mpi->stride[0]=mpi->width*mpi->bpp/8;
|
||||
}
|
||||
mpi->flags|=MP_IMGFLAG_ALLOCATED;
|
||||
}
|
||||
}
|
||||
if(!(mpi->flags&MP_IMGFLAG_TYPE_DISPLAYED)){
|
||||
mp_msg(MSGT_DECVIDEO,MSGL_INFO,"*** %s mp_image_t, %dx%dx%dbpp %s %s, %d bytes\n",
|
||||
(mpi->flags&MP_IMGFLAG_DIRECT)?"Direct Rendering":"Allocating",
|
||||
mpi->width,mpi->height,mpi->bpp,
|
||||
(mpi->flags&MP_IMGFLAG_YUV)?"YUV":"RGB",
|
||||
(mpi->flags&MP_IMGFLAG_PLANAR)?"planar":"packed",
|
||||
mpi->bpp*mpi->width*mpi->height/8);
|
||||
mpi->flags|=MP_IMGFLAG_TYPE_DISPLAYED;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return mpi;
|
||||
|
@ -1,6 +1,7 @@
|
||||
|
||||
#include "fastmemcpy.h"
|
||||
#include "../mmx_defs.h"
|
||||
#include "../mp_image.h"
|
||||
|
||||
// mga_vid drawing functions
|
||||
|
||||
@ -172,7 +173,6 @@ write_frame_yuy2(uint8_t *y)
|
||||
mem2agpcpy_pic(vid_data, y, len, mga_vid_config.src_height, 2*bespitch, len);
|
||||
}
|
||||
|
||||
|
||||
static uint32_t
|
||||
draw_frame(uint8_t *src[])
|
||||
{
|
||||
@ -184,6 +184,36 @@ draw_frame(uint8_t *src[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
get_image(mp_image_t *mpi){
|
||||
uint32_t bespitch = (mga_vid_config.src_width + 31) & ~31;
|
||||
uint32_t bespitch2 = bespitch/2;
|
||||
// printf("mga: get_image() called\n");
|
||||
if(mpi->type==MP_IMGTYPE_STATIC) return VO_FALSE; // it is not static
|
||||
if(mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; // slow video ram
|
||||
// printf("width=%d vs. bespitch=%d, flags=0x%X \n",mpi->width,bespitch,mpi->flags);
|
||||
if((mpi->width==bespitch) ||
|
||||
(mpi->flags&(MP_IMGFLAG_ACCEPT_STRIDE|MP_IMGFLAG_ACCEPT_WIDTH))){
|
||||
// we're lucky or codec accepts stride => ok, let's go!
|
||||
if(mpi->flags&MP_IMGFLAG_PLANAR){
|
||||
mpi->planes[0]=vid_data;
|
||||
mpi->planes[1]=vid_data + bespitch*mga_vid_config.src_height;
|
||||
mpi->planes[2]=vid_data + bespitch*mga_vid_config.src_height
|
||||
+ bespitch*mga_vid_config.src_height / 4;
|
||||
mpi->width=mpi->stride[0]=bespitch;
|
||||
mpi->stride[1]=mpi->stride[2]=bespitch2;
|
||||
} else {
|
||||
mpi->planes[0]=vid_data;
|
||||
mpi->width=bespitch;
|
||||
mpi->stride[0]=mpi->width*(mpi->bpp/8);
|
||||
}
|
||||
mpi->flags|=MP_IMGFLAG_DIRECT;
|
||||
// printf("mga: get_image() SUCCESS -> Direct Rendering ENABLED\n");
|
||||
return VO_TRUE;
|
||||
}
|
||||
return VO_FALSE;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
query_format(uint32_t format)
|
||||
{
|
||||
@ -205,6 +235,8 @@ static uint32_t control(uint32_t request, void *data, ...)
|
||||
switch (request) {
|
||||
case VOCTRL_QUERY_FORMAT:
|
||||
return query_format(*((uint32_t*)data));
|
||||
case VOCTRL_GET_IMAGE:
|
||||
return get_image(data);
|
||||
}
|
||||
return VO_NOTIMPL;
|
||||
}
|
||||
|
@ -36,6 +36,8 @@
|
||||
#define VOCTRL_PAUSE 7
|
||||
/* start/resume playback */
|
||||
#define VOCTRL_RESUME 8
|
||||
/* libmpcodecs direct rendering: */
|
||||
#define VOCTRL_GET_IMAGE 9
|
||||
|
||||
#define VO_TRUE 1
|
||||
#define VO_FALSE 0
|
||||
|
Loading…
Reference in New Issue
Block a user