1
mirror of https://github.com/mpv-player/mpv synced 2024-12-24 07:33:46 +01:00

enabled new OSD code in -vop expand, subtitles rendering support to mencoder

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@5670 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
arpi 2002-04-17 21:51:18 +00:00
parent c4d86b833e
commit 51e8f97ef7
6 changed files with 152 additions and 42 deletions

View File

@ -25,9 +25,9 @@ MANDIR = ${prefix}/man
# a BSD compatible 'install' program
INSTALL = install
SRCS_COMMON = xacodec.c cpudetect.c mp_msg.c codec-cfg.c cfgparser.c my_profile.c spudec.c playtree.c playtreeparser.c asxparser.c vobsub.c
SRCS_MENCODER = mencoder.c $(SRCS_COMMON) libao2/afmt.c divx4_vbr.c libvo/aclib.c libvo/osd.c me-opt-reg.c
SRCS_MPLAYER = mplayer.c $(SRCS_COMMON) find_sub.c subreader.c lirc_mp.c mixer.c mp-opt-reg.c
SRCS_COMMON = xacodec.c cpudetect.c mp_msg.c codec-cfg.c cfgparser.c my_profile.c spudec.c playtree.c playtreeparser.c asxparser.c vobsub.c subreader.c find_sub.c
SRCS_MENCODER = mencoder.c $(SRCS_COMMON) libao2/afmt.c divx4_vbr.c libvo/aclib.c libvo/osd.c libvo/sub.c libvo/font_load.c me-opt-reg.c
SRCS_MPLAYER = mplayer.c $(SRCS_COMMON) lirc_mp.c mixer.c mp-opt-reg.c
OBJS_MENCODER = $(SRCS_MENCODER:.c=.o)
OBJS_MPLAYER = $(SRCS_MPLAYER:.c=.o)
@ -268,18 +268,19 @@ config.h: configure
# do not rebuild after cvs commits if .developer file is present!
# rebuild at every config.h/config.mak change:
version.h: config.h config.mak Makefile
version.h:
./version.sh `$(CC) --version`
ifeq ($(wildcard .developer),)
$(MAKE) distclean
endif
$(MAKE) depend
# rebuild at every CVS update:
# rebuild at every CVS update or config/makefile change:
ifeq ($(wildcard .developer),)
ifneq ($(wildcard CVS/Entries),)
version.h: CVS/Entries
endif
version.h: config.h config.mak Makefile
endif
#

View File

@ -99,7 +99,28 @@
{"tv", "MPlayer was compiled without TV Interface support\n", CONF_TYPE_PRINT, 0, 0, 0, NULL},
#endif
{"vivo", vivoopts_conf, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
{"vop", &vo_plugin_args, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL},
{"vop", &vo_plugin_args, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL},
// ------------------------- subtitles options --------------------
#ifdef USE_SUB
{"sub", &sub_name, CONF_TYPE_STRING, 0, 0, 0, NULL},
#ifdef USE_ICONV
{"subcp", &sub_cp, CONF_TYPE_STRING, 0, 0, 0, NULL},
#endif
{"subdelay", &sub_delay, CONF_TYPE_FLOAT, 0, 0.0, 10.0, NULL},
{"subfps", &sub_fps, CONF_TYPE_FLOAT, 0, 0.0, 10.0, NULL},
{"noautosub", &sub_auto, CONF_TYPE_FLAG, 0, 1, 0, NULL},
{"unicode", &sub_unicode, CONF_TYPE_FLAG, 0, 0, 1, NULL},
{"nounicode", &sub_unicode, CONF_TYPE_FLAG, 0, 1, 0, NULL},
{"utf8", &sub_utf8, CONF_TYPE_FLAG, 0, 0, 1, NULL},
{"noutf8", &sub_utf8, CONF_TYPE_FLAG, 0, 1, 0, NULL},
{"subpos",&sub_pos, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL},
#endif
#ifdef USE_OSD
{"font", &font_name, CONF_TYPE_STRING, 0, 0, 0, NULL},
{"ffactor", &font_factor, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 10.0, NULL},
#endif
#else

View File

@ -58,15 +58,6 @@ extern int vo_gamma_blue_intensity;
extern int vo_directrendering;
extern int vd_use_slices;
#ifdef USE_SUB
extern int sub_unicode;
extern int sub_utf8;
#ifdef USE_ICONV
extern char *sub_cp;
#endif
extern int sub_pos;
#endif
#ifdef USE_OSD
extern int osd_level;
#endif
@ -191,24 +182,7 @@ static config_t mplayer_opts[]={
// {"encode", &encode_name, CONF_TYPE_STRING, 0, 0, 0, NULL},
{"vobsub", &vobsub_name, CONF_TYPE_STRING, 0, 0, 0, NULL},
{"vobsubid", &vobsub_id, CONF_TYPE_INT, CONF_RANGE, 0, 31, NULL},
#ifdef USE_SUB
{"sub", &sub_name, CONF_TYPE_STRING, 0, 0, 0, NULL},
#ifdef USE_ICONV
{"subcp", &sub_cp, CONF_TYPE_STRING, 0, 0, 0, NULL},
#endif
{"subdelay", &sub_delay, CONF_TYPE_FLOAT, 0, 0.0, 10.0, NULL},
{"subfps", &sub_fps, CONF_TYPE_FLOAT, 0, 0.0, 10.0, NULL},
{"noautosub", &sub_auto, CONF_TYPE_FLAG, 0, 1, 0, NULL},
{"unicode", &sub_unicode, CONF_TYPE_FLAG, 0, 0, 1, NULL},
{"nounicode", &sub_unicode, CONF_TYPE_FLAG, 0, 1, 0, NULL},
{"utf8", &sub_utf8, CONF_TYPE_FLAG, 0, 0, 1, NULL},
{"noutf8", &sub_utf8, CONF_TYPE_FLAG, 0, 1, 0, NULL},
{"subpos",&sub_pos, CONF_TYPE_INT, CONF_RANGE, 0, 100, NULL},
#endif
#ifdef USE_OSD
{"font", &font_name, CONF_TYPE_STRING, 0, 0, 0, NULL},
{"ffactor", &font_factor, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 10.0, NULL},
#endif
// {"bg", &play_in_bg, CONF_TYPE_FLAG, 0, 0, 1, NULL},
// {"nobg", &play_in_bg, CONF_TYPE_FLAG, 0, 1, 0, NULL},
{"sstep", &step_sec, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL},

View File

@ -1,4 +1,4 @@
//#define OSD_SUPPORT
#define OSD_SUPPORT
#include <stdio.h>
#include <stdlib.h>
@ -23,6 +23,7 @@ struct vf_priv_s {
int exp_x,exp_y;
mp_image_t *dmpi;
int osd;
unsigned char* fb_ptr;
};
//===========================================================================//
@ -33,7 +34,8 @@ static int orig_w,orig_h;
static void remove_func_2(int x0,int y0, int w,int h){
// TODO: let's cleanup the place
printf("OSD clear: %d;%d %dx%d \n",x0,y0,w,h);
//printf("OSD clear: %d;%d %dx%d \n",x0,y0,w,h);
vf_mpi_clear(vf->priv->dmpi,x0,y0,w,h);
}
static void remove_func(int x0,int y0, int w,int h){
@ -60,10 +62,30 @@ static void remove_func(int x0,int y0, int w,int h){
}
static void draw_func(int x0,int y0, int w,int h,unsigned char* src, unsigned char *srca, int stride){
unsigned char* dst=vf->priv->dmpi->planes[0]+
unsigned char* dst;
if(!vo_osd_changed_flag && vf->priv->dmpi->planes[0]==vf->priv->fb_ptr){
// ok, enough to update the area inside the video, leave the black bands
// untouched!
if(x0<vf->priv->exp_x){
int tmp=vf->priv->exp_x-x0;
w-=tmp; src+=tmp; srca+=tmp; x0+=tmp;
}
if(y0<vf->priv->exp_y){
int tmp=vf->priv->exp_y-y0;
h-=tmp; src+=tmp*stride; srca+=tmp*stride; y0+=tmp;
}
if(x0+w>vf->priv->exp_x+orig_w){
w=vf->priv->exp_x+orig_w-x0;
}
if(y0+h>vf->priv->exp_y+orig_h){
h=vf->priv->exp_y+orig_h-y0;
}
}
if(w<=0 || h<=0) return; // nothing to do...
// printf("OSD redraw: %d;%d %dx%d \n",x0,y0,w,h);
dst=vf->priv->dmpi->planes[0]+
vf->priv->dmpi->stride[0]*y0+
(vf->priv->dmpi->bpp>>3)*x0;
if(!vo_osd_changed_flag) return;
switch(vf->priv->dmpi->imgfmt){
case IMGFMT_BGR15:
case IMGFMT_RGB15:
@ -97,12 +119,22 @@ static void draw_func(int x0,int y0, int w,int h,unsigned char* src, unsigned ch
static void draw_osd(struct vf_instance_s* vf_,int w,int h){
vf=vf_;orig_w=w;orig_h=h;
// printf("======================================\n");
if(vf->priv->exp_w!=w || vf->priv->exp_h!=h ||
vf->priv->exp_x || vf->priv->exp_y){
// yep, we're expanding image, not just copy.
vo_remove_text(vf->priv->exp_w,vf->priv->exp_h,remove_func);
vf->priv->exp_x || vf->priv->exp_y){
// yep, we're expanding image, not just copy.
if(vf->priv->dmpi->planes[0]!=vf->priv->fb_ptr){
// double buffering, so we need full clear :(
remove_func(0,0,vf->priv->exp_w,vf->priv->exp_h);
} else {
// partial clear:
vo_remove_text(vf->priv->exp_w,vf->priv->exp_h,remove_func);
}
}
vo_draw_text(vf->priv->exp_w,vf->priv->exp_h,draw_func);
// save buffer pointer for double buffering detection - yes, i know it's
// ugly method, but note that codecs with DR support does the same...
vf->priv->fb_ptr=vf->priv->dmpi->planes[0];
}
#endif
@ -120,6 +152,7 @@ static int config(struct vf_instance_s* vf,
// check:
// if(vf->priv->exp_w+vf->priv->exp_x>width) return 0; // bad width
// if(vf->priv->exp_h+vf->priv->exp_y>height) return 0; // bad height
vf->priv->fb_ptr=NULL;
ret=vf_next_config(vf,vf->priv->exp_w,vf->priv->exp_h,d_width,d_height,flags,outfmt);
return ret;
}

View File

@ -85,6 +85,14 @@ extern void* vo_vobsub;
extern char * __sub_osd_names[];
extern char * __sub_osd_names_short[];
extern int sub_unicode;
extern int sub_utf8;
#ifdef USE_ICONV
extern char *sub_cp;
#endif
extern int sub_pos;
//extern void vo_draw_text_osd(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
//extern void vo_draw_text_progbar(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));
//extern void vo_draw_text_sub(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride));

View File

@ -148,6 +148,24 @@ int pass_working=0;
static int play_n_frames=-1;
#include "libvo/font_load.h"
#include "libvo/sub.h"
// sub:
char *font_name=NULL;
float font_factor=0.75;
char *sub_name=NULL;
float sub_delay=0;
float sub_fps=0;
int sub_auto = 0;
#ifdef USE_SUB
static subtitle* subtitles=NULL;
float sub_last_pts = -303;
#endif
//char *out_audio_codec=NULL; // override audio codec
//char *out_video_codec=NULL; // override video codec
@ -218,8 +236,6 @@ void parse_cfgfiles( m_config_t* conf )
//---------------------------------------------------------------------------
void *vo_spudec=NULL;
int dec_audio(sh_audio_t *sh_audio,unsigned char* buffer,int total){
int size=0;
int eof=0;
@ -334,6 +350,21 @@ if(!parse_codec_cfg(get_path("codecs.conf"))){
gCpuCaps.hasSSE, gCpuCaps.hasSSE2);
#endif
// check font
#ifdef USE_OSD
if(font_name){
vo_font=read_font_desc(font_name,font_factor,verbose>1);
if(!vo_font) mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadFont,font_name);
} else {
// try default:
vo_font=read_font_desc(get_path("font/font.desc"),font_factor,verbose>1);
if(!vo_font)
vo_font=read_font_desc(DATADIR"/font/font.desc",font_factor,verbose>1);
}
#endif
vo_init_osd();
// FIXME: get rid of -dvd and other tricky options and config/playtree
stream2=open_stream(frameno_filename,0,&i);
if(stream2){
@ -481,6 +512,22 @@ vo_spudec=spudec_new_scaled(stream->type==STREAMTYPE_DVD?((dvd_priv_t *)(stream-
}
#endif
#ifdef USE_SUB
// after reading video params we should load subtitles because
// we know fps so now we can adjust subtitles time to ~6 seconds AST
// check .sub
// current_module="read_subtitles_file";
if(sub_name){
subtitles=sub_read_file(sub_name, sh_video->fps);
if(!subtitles) mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantLoadSub,sub_name);
} else
if(sub_auto) { // auto load sub file ...
subtitles=sub_read_file( filename ? sub_filename( get_path("sub/"), filename )
: "default.sub", sh_video->fps );
}
#endif
// set up output file:
muxer_f=fopen(out_filename,"wb");
if(!muxer_f) {
@ -557,6 +604,8 @@ default:
mp_msg(MSGT_MENCODER,MSGL_FATAL,"Failed to open the encoder\n");
mencoder_exit(1,NULL);
}
// append 'expand' filter, it fixes stride problems and renders osd:
sh_video->vfilter=vf_open_filter(sh_video->vfilter,"expand","-1:-1:-1:-1:1");
sh_video->vfilter=append_filters(sh_video->vfilter);
mp_msg(MSGT_CPLAYER,MSGL_INFO,"==========================================================================\n");
@ -1027,6 +1076,30 @@ if(sh_audio && !demuxer2){
}
fflush(stdout);
#ifdef USE_SUB
// find sub
if(subtitles && d_video->pts>0){
float pts=d_video->pts;
if(sub_fps==0) sub_fps=sh_video->fps;
if (pts > sub_last_pts || pts < sub_last_pts-1.0 ) {
find_sub(subtitles,sub_uses_time?(100*(pts+sub_delay)):((pts+sub_delay)*sub_fps)); // FIXME! frame counter...
sub_last_pts = pts;
}
}
#endif
#ifdef USE_DVDREAD
// DVD sub:
if(vo_spudec){
unsigned char* packet=NULL;
int len;
while((len=ds_get_packet_sub(d_dvdsub,&packet))>0){
mp_msg(MSGT_MENCODER,MSGL_V,"\rDVD sub: len=%d v_pts=%5.3f s_pts=%5.3f \n",len,d_video->pts,d_dvdsub->pts);
spudec_assemble(vo_spudec,packet,len,90000*d_dvdsub->pts);
}
spudec_heartbeat(vo_spudec,90000*d_video->pts);
}
#endif
} // while(!eof)