[Mplayerxp-cvslog] SF.net SVN: mplayerxp:[638] mplayerxp
Brought to you by:
olov
|
From: <nic...@us...> - 2013-05-14 12:02:23
|
Revision: 638
http://sourceforge.net/p/mplayerxp/code/638
Author: nickols_k
Date: 2013-05-14 12:02:20 +0000 (Tue, 14 May 2013)
Log Message:
-----------
more streams
Modified Paths:
--------------
mplayerxp/libmpstream2/s_file.cpp
mplayerxp/libvo2/vo_fbdev.cpp
Modified: mplayerxp/libmpstream2/s_file.cpp
===================================================================
--- mplayerxp/libmpstream2/s_file.cpp 2013-05-08 13:49:59 UTC (rev 637)
+++ mplayerxp/libmpstream2/s_file.cpp 2013-05-14 12:02:20 UTC (rev 638)
@@ -4,6 +4,9 @@
/*
s_file - stream interface for file i/o.
*/
+#include <iostream>
+#include <fstream>
+
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
@@ -36,29 +39,29 @@
virtual off_t sector_size() const;
virtual std::string mime_type() const;
private:
- int fd;
- int was_open;
+ std::ifstream fs;
off_t spos;
off_t end_pos;
};
File_Stream_Interface::File_Stream_Interface(libinput_t&l)
:Stream_Interface(l),
- fd(0),was_open(0),spos(0) {}
+ spos(0) {}
File_Stream_Interface::~File_Stream_Interface() {}
MPXP_Rc File_Stream_Interface::open(const std::string& filename,unsigned flags)
{
UNUSED(flags);
- if(filename=="-") fd=0;
- else fd=::open(filename.c_str(),O_RDONLY);
- if(fd<0) {
+// if(filename=="-") fd=0;
+// else fd=::open(filename.c_str(),O_RDONLY);
+ fs.open(filename.c_str(),std::ios_base::binary | std::ios_base::in);
+ if(!fs.is_open()) {
mpxp_err<<"[s_file] Cannot open file: "<<filename<<std::endl;
return MPXP_False;
}
- was_open = (fd==0)?0:1;
- end_pos = ::lseek(fd,0,SEEK_END);
- ::lseek(fd,0,SEEK_SET);
+ fs.seekg(0,std::ios_base::end);
+ end_pos = fs.tellg();
+ fs.seekg(0,std::ios_base::beg);
/* decreasing number of packet from 256 to 10 speedups cache2 from 3.27% to 1.26%
with full speed 1.04% for -nocache */
/* Note: Please locate sector_size changinf after all read/write operations of open() function */
@@ -76,14 +79,18 @@
Should we repeate read() again on these errno: `EAGAIN', `EIO' ???
*/
sp->type=0;
- sp->len = ::read(fd,sp->buf,sp->len);
- if(sp->len>0) spos += sp->len;
- return sp->len;
+ fs.read(sp->buf,sp->len);
+ spos = fs.tellg();
+ return fs.good()?sp->len:-1;
}
off_t File_Stream_Interface::seek(off_t pos)
{
- spos=::lseek(fd,pos,SEEK_SET);
+ fs.clear(fs.failbit);
+ fs.clear(fs.badbit);
+ fs.clear(fs.eofbit);
+ fs.seekg(pos,std::ios_base::beg);
+ spos=fs.tellg();
return spos;
}
@@ -94,7 +101,7 @@
void File_Stream_Interface::close()
{
- if(was_open) ::close(fd);
+ if(fs.is_open()) fs.close();
}
MPXP_Rc File_Stream_Interface::ctrl(unsigned cmd,any_t*args) {
Modified: mplayerxp/libvo2/vo_fbdev.cpp
===================================================================
--- mplayerxp/libvo2/vo_fbdev.cpp 2013-05-08 13:49:59 UTC (rev 637)
+++ mplayerxp/libvo2/vo_fbdev.cpp 2013-05-14 12:02:20 UTC (rev 638)
@@ -8,6 +8,8 @@
*
* Some idea and code borrowed from Chris Lawrence's ppmtofb-0.27
*/
+#include <iostream>
+#include <fstream>
static const char* FBDEV= "fbdev: ";
@@ -128,12 +130,11 @@
MPXP_Rc fb_preinit();
std::string parse_sub_device(const std::string& sd);
int parse_fbmode_cfg(const std::string& cfgfile);
- int get_token(int num);
+ int get_token(std::ifstream&,int num);
void vt_set_textarea(int u, int l);
void lots_of_printf() const;
LocalPtr<Aspect>aspect;
- FILE * fp;
int line_num;
char * line;
char * token[MAX_NR_TOKEN];
@@ -145,8 +146,7 @@
range_t * monitor_dotclock;
fb_mode_t * mode;
/* vt related variables */
- int vt_fd;
- FILE * vt_fp;
+ std::ofstream vt_fp;
int vt_doit;
/* vo_fbdev related variables */
int dev_fd;
@@ -175,7 +175,6 @@
unsigned out_width;
unsigned out_height;
int last_row;
- int fs;
MPXP_Rc pre_init_err;
#ifdef CONFIG_VIDIX
/* Name of VIDIX driver */
@@ -314,7 +313,7 @@
if(fb_preinit()!=MPXP_Ok) exit_player("FBDev preinit");
}
-int FBDev_VO_Interface::get_token(int num)
+int FBDev_VO_Interface::get_token(std::ifstream& fp,int num)
{
static int read_nextline = 1;
static int line_pos;
@@ -327,7 +326,8 @@
}
if (read_nextline) {
- if (!fgets(line, MAX_LINE_LEN, fp)) goto out_eof;
+ fp.getline(line, MAX_LINE_LEN);
+ if (!fp.good()) goto out_eof;
line_pos = 0;
++line_num;
read_nextline = 0;
@@ -374,10 +374,12 @@
char *endptr; // strtoul()...
int in_mode_def = 0;
int tmp, i;
+ std::ifstream fp;
mpxp_dbg2<<"Reading "<<cfgfile.c_str()<<":";
- if ((fp = fopen(cfgfile.c_str(), "r")) == NULL) {
+ fp.open(cfgfile.c_str(),std::ios_base::in);
+ if (!fp.is_open()) {
mpxp_err<<"can't open '"<<cfgfile<<"': "<<strerror(errno)<<std::endl;
return -1;
}
@@ -390,12 +392,12 @@
/*
* check if the cfgfile starts with 'mode'
*/
- while ((tmp = get_token(1)) == RET_EOL) /* NOTHING */;
+ while ((tmp = get_token(fp,1)) == RET_EOL) /* NOTHING */;
if (tmp == RET_EOF) goto out;
if (!strcmp(token[0], "mode")) goto loop_enter;
goto err_out_parse_error;
- while ((tmp = get_token(1)) != RET_EOF) {
+ while ((tmp = get_token(fp,1)) != RET_EOF) {
if (tmp == RET_EOL) continue;
if (!strcmp(token[0], "mode")) {
if (in_mode_def) {
@@ -413,7 +415,7 @@
++nr_modes;
memset(_mode,0,sizeof(fb_mode_t));
- if (get_token(1) < 0) goto err_out_parse_error;
+ if (get_token(fp,1) < 0) goto err_out_parse_error;
for (i = 0; i < nr_modes - 1; i++) {
if (!strcmp(token[0], fb_modes[i].name)) {
mpxp_err<<"mode name '"<<token[0]<<"' isn't unique"<<std::endl;
@@ -427,7 +429,7 @@
in_mode_def = 1;
} else if (!strcmp(token[0], "geometry")) {
check_in_mode_def(in_mode_def); goto err_out_print_linenum;
- if (get_token(5) < 0) goto err_out_parse_error;
+ if (get_token(fp,5) < 0) goto err_out_parse_error;
_mode->xres = strtoul(token[0], &endptr, 0);
if (*endptr) goto err_out_parse_error;
_mode->yres = strtoul(token[1], &endptr, 0);
@@ -440,7 +442,7 @@
if (*endptr) goto err_out_parse_error;
} else if (!strcmp(token[0], "timings")) {
check_in_mode_def(in_mode_def); goto err_out_print_linenum;
- if (get_token(7) < 0) goto err_out_parse_error;
+ if (get_token(fp,7) < 0) goto err_out_parse_error;
_mode->pixclock = strtoul(token[0], &endptr, 0);
if (*endptr) goto err_out_parse_error;
_mode->left = strtoul(token[1], &endptr, 0);
@@ -460,44 +462,44 @@
in_mode_def = 0;
} else if (!strcmp(token[0], "accel")) {
check_in_mode_def(in_mode_def); goto err_out_print_linenum;
- if (get_token(1) < 0) goto err_out_parse_error;
+ if (get_token(fp,1) < 0) goto err_out_parse_error;
/*
* it's only used for text acceleration
* so we just ignore it.
*/
} else if (!strcmp(token[0], "hsync")) {
check_in_mode_def(in_mode_def); goto err_out_print_linenum;
- if (get_token(1) < 0) goto err_out_parse_error;
+ if (get_token(fp,1) < 0) goto err_out_parse_error;
if (!strcmp(token[0], "low")) _mode->sync &= ~FB_SYNC_HOR_HIGH_ACT;
else if(!strcmp(token[0], "high")) _mode->sync |= FB_SYNC_HOR_HIGH_ACT;
else goto err_out_parse_error;
} else if (!strcmp(token[0], "vsync")) {
check_in_mode_def(in_mode_def); goto err_out_print_linenum;
- if (get_token(1) < 0) goto err_out_parse_error;
+ if (get_token(fp,1) < 0) goto err_out_parse_error;
if (!strcmp(token[0], "low")) _mode->sync &= ~FB_SYNC_VERT_HIGH_ACT;
else if(!strcmp(token[0], "high")) _mode->sync |= FB_SYNC_VERT_HIGH_ACT;
else goto err_out_parse_error;
} else if (!strcmp(token[0], "csync")) {
check_in_mode_def(in_mode_def); goto err_out_print_linenum;
- if (get_token(1) < 0) goto err_out_parse_error;
+ if (get_token(fp,1) < 0) goto err_out_parse_error;
if (!strcmp(token[0], "low")) _mode->sync &= ~FB_SYNC_COMP_HIGH_ACT;
else if(!strcmp(token[0], "high")) _mode->sync |= FB_SYNC_COMP_HIGH_ACT;
else goto err_out_parse_error;
} else if (!strcmp(token[0], "extsync")) {
check_in_mode_def(in_mode_def); goto err_out_print_linenum;
- if (get_token(1) < 0) goto err_out_parse_error;
+ if (get_token(fp,1) < 0) goto err_out_parse_error;
if (!strcmp(token[0], "false")) _mode->sync &= ~FB_SYNC_EXT;
else if(!strcmp(token[0], "true")) _mode->sync |= FB_SYNC_EXT;
else goto err_out_parse_error;
} else if (!strcmp(token[0], "laced")) {
check_in_mode_def(in_mode_def); goto err_out_print_linenum;
- if (get_token(1) < 0) goto err_out_parse_error;
+ if (get_token(fp,1) < 0) goto err_out_parse_error;
if (!strcmp(token[0], "false")) _mode->vmode = FB_VMODE_NONINTERLACED;
else if (!strcmp(token[0], "true")) _mode->vmode = FB_VMODE_INTERLACED;
else goto err_out_parse_error;
} else if (!strcmp(token[0], "double")) {
check_in_mode_def(in_mode_def); goto err_out_print_linenum;
- if (get_token(1) < 0) goto err_out_parse_error;
+ if (get_token(fp,1) < 0) goto err_out_parse_error;
if (!strcmp(token[0], "false")) ;
else if (!strcmp(token[0], "true")) _mode->vmode = FB_VMODE_DOUBLE;
else goto err_out_parse_error;
@@ -507,7 +509,7 @@
out:
mpxp_dbg2<<nr_modes<<"modes"<<std::endl;
delete line;
- fclose(fp);
+ fp.close();
return nr_modes;
err_out_parse_error:
mpxp_err<<"parse error";
@@ -520,7 +522,6 @@
}
nr_modes = 0;
delete line;
- delete fp;
return -2;
err_out_not_valid:
mpxp_err<<"previous mode is not correct"<<std::endl;
@@ -873,8 +874,8 @@
if (mp_conf.verbose > 1)
mpxp_dbg2<<FBDEV<< "vt_set_textarea("<<u<<","<<l<<"): "<<urow<<","<<lrow<<std::endl;
- ::fprintf(vt_fp, "\33[%d;%dr\33[%d;%dH", urow, lrow, lrow, 0);
- ::fflush(vt_fp);
+ vt_fp<<"\33["<<urow<<";"<<lrow<<"r\33["<<lrow<<";0H";
+ vt_fp.flush();
}
MPXP_Rc FBDev_VO_Interface::configure(uint32_t width, uint32_t height, uint32_t d_width,
@@ -1079,11 +1080,8 @@
return MPXP_False;
}
}
- if (vt_doit && (vt_fd = open("/dev/tty", O_WRONLY)) == -1) {
- mpxp_err<<FBDEV<< "can't open /dev/tty: "<<strerror(errno)<<std::endl;
- vt_doit = 0;
- }
- if (vt_doit && !(vt_fp = fdopen(vt_fd, "w"))) {
+ vt_fp.open("/dev/tty", std::ios_base::out);
+ if (vt_doit && !vt_fp.is_open()) {
mpxp_err<<FBDEV<< "can't fdopen /dev/tty: "<<strerror(errno)<<std::endl;
vt_doit = 0;
}
@@ -1096,18 +1094,19 @@
MPXP_Rc FBDev_VO_Interface::query_format(vo_query_fourcc_t * format) const
{
+ MPXP_Rc rc=MPXP_False;
#ifdef CONFIG_VIDIX
if(vidix) return vidix->query_fourcc(format);
#endif
format->flags=VOCAP_NA;
switch(format->fourcc) {
- case IMGFMT_BGR15: if(bpp == 15) format->flags=VOCAP_SUPPORTED; break;
- case IMGFMT_BGR16: if(bpp == 16) format->flags=VOCAP_SUPPORTED; break;
- case IMGFMT_BGR24: if(bpp == 24) format->flags=VOCAP_SUPPORTED; break;
- case IMGFMT_BGR32: if(bpp == 32) format->flags=VOCAP_SUPPORTED; break;
+ case IMGFMT_BGR15: if(bpp == 15) format->flags=VOCAP_SUPPORTED; rc=MPXP_Ok; break;
+ case IMGFMT_BGR16: if(bpp == 16) format->flags=VOCAP_SUPPORTED; rc=MPXP_Ok; break;
+ case IMGFMT_BGR24: if(bpp == 24) format->flags=VOCAP_SUPPORTED; rc=MPXP_Ok; break;
+ case IMGFMT_BGR32: if(bpp == 32) format->flags=VOCAP_SUPPORTED; rc=MPXP_Ok; break;
default: break;
}
- return MPXP_Ok;
+ return rc;
}
MPXP_Rc FBDev_VO_Interface::select_frame(unsigned idx)
@@ -1115,14 +1114,11 @@
#ifdef CONFIG_VIDIX
if(vidix) return vidix->select_frame(idx);
#endif
- unsigned i, out_offset = 0, in_offset = 0;
- for (i = 0; i < out_height; i++) {
- memcpy( L123123875 + out_offset, next_frame[idx] + in_offset,
- out_width * pixel_size);
- out_offset += line_len;
- in_offset += out_width * pixel_size;
- }
+ size_t src_stride=out_width*pixel_size;
+ size_t dst_stride=line_len;
+ stream_copy_pic(L123123875,next_frame[idx],src_stride,out_height,dst_stride,src_stride);
+
return MPXP_Ok;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|