From 41d658fb35cd6addebd096d612fe894d2b82d658 Mon Sep 17 00:00:00 2001 From: michael Date: Sat, 1 Dec 2001 01:29:25 +0000 Subject: yv12 scaling (-x & -y) git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@3237 b3059339-0415-0410-9bf9-f77b7e298cf2 --- mencoder.c | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) (limited to 'mencoder.c') diff --git a/mencoder.c b/mencoder.c index c1c38a5cf6..936452f385 100644 --- a/mencoder.c +++ b/mencoder.c @@ -40,6 +40,9 @@ static char* banner_text= #include +#include +#include "../postproc/swscale.h" + //-------------------------- // cache2: @@ -112,6 +115,9 @@ int lame_param_padding=-1; // unset int lame_param_br=-1; // unset int lame_param_ratio=-1; // unset +static int scale_srcW=0; +static int scale_srcH=0; +static int vo_w=0, vo_h=0; //-------------------------- config stuff: #include "cfgparser.h" @@ -155,12 +161,20 @@ int vo_expose = 0; static unsigned char* vo_image=NULL; static unsigned char* vo_image_ptr=NULL; -static int vo_w,vo_h; static uint32_t draw_slice(uint8_t *src[], int stride[], int w,int h, int x0,int y0){ int y; -// printf("draw_slice %dx%d %d;%d\n",w,h,x,y); - +// printf("draw_slice %dx%d %d;%d\n",w,h,x0,y0); + if(scale_srcW) + { + uint8_t* dstPtr[3]= { + vo_image, + vo_image + vo_w*vo_h*5/4, + vo_image + vo_w*vo_h}; + SwScale_YV12slice(src, stride, y0, h, dstPtr, vo_w, 12, scale_srcW, scale_srcH, vo_w, vo_h); + } + else + { // copy Y: for(y=0;y>1)*(y0+y)+x0; memcpy(d,s,w); } - + } // !swscaler } static uint32_t draw_frame(uint8_t *src[]){ @@ -365,9 +379,18 @@ if(i>=CODECS_MAX_OUTFMT){ } sh_video->outfmtidx=i; +if(out_fmt==IMGFMT_YV12 && vo_w!=0 && vo_h!=0) +{ + scale_srcW= sh_video->disp_w; + scale_srcH= sh_video->disp_h; +} +else +{ + vo_w=sh_video->disp_w; + vo_h=sh_video->disp_h; +} + if(out_fmt==IMGFMT_YV12 || out_fmt==IMGFMT_I420 || out_fmt==IMGFMT_IYUV){ - vo_w=sh_video->disp_w; - vo_h=sh_video->disp_h; vo_image=malloc(vo_w*vo_h*3/2); vo_image_ptr=vo_image; } @@ -418,6 +441,7 @@ if(sh_audio){ // set up video encoder: +SwScale_Init(); video_out.draw_slice=draw_slice; video_out.draw_frame=draw_frame; @@ -452,8 +476,8 @@ case 0: case VCODEC_DIVX4: mux_v->bih=malloc(sizeof(BITMAPINFOHEADER)); mux_v->bih->biSize=sizeof(BITMAPINFOHEADER); - mux_v->bih->biWidth=sh_video->disp_w; - mux_v->bih->biHeight=sh_video->disp_h; + mux_v->bih->biWidth=vo_w; + mux_v->bih->biHeight=vo_h; mux_v->bih->biPlanes=1; mux_v->bih->biBitCount=24; mux_v->bih->biCompression=mmioFOURCC('d','i','v','x'); @@ -525,8 +549,8 @@ case 0: break; case VCODEC_DIVX4: // init divx4linux: - divx4_param.x_dim=sh_video->disp_w; - divx4_param.y_dim=sh_video->disp_h; + divx4_param.x_dim=vo_w; + divx4_param.y_dim=vo_h; divx4_param.framerate=(float)mux_v->h.dwRate/mux_v->h.dwScale; if(!divx4_param.bitrate) divx4_param.bitrate=800000; else if(divx4_param.bitrate<=16000) divx4_param.bitrate*=1000; -- cgit v1.2.3