[Mplayerxp-cvslog] SF.net SVN: mplayerxp:[639] mplayerxp
Brought to you by:
olov
From: <nic...@us...> - 2013-05-14 14:45:23
|
Revision: 639 http://sourceforge.net/p/mplayerxp/code/639 Author: nickols_k Date: 2013-05-14 14:45:21 +0000 (Tue, 14 May 2013) Log Message: ----------- more streams Modified Paths: -------------- mplayerxp/dump.cpp mplayerxp/libao3/ao_null.cpp mplayerxp/libao3/ao_wav.cpp mplayerxp/libmpcodecs/vd_qtvideo.cpp mplayerxp/libmpconf/cfgparser.cpp mplayerxp/libmpdemux/demux_avi.cpp mplayerxp/libmpdemux/demux_ogg.cpp mplayerxp/libmpdemux/mux_mpxp64.cpp mplayerxp/libmpdemux/mux_raw.cpp mplayerxp/libmpdemux/muxer.cpp mplayerxp/libmpdemux/muxer.h mplayerxp/libmpdemux/stheader.cpp mplayerxp/libmpstream2/network_asf.cpp mplayerxp/libmpstream2/s_ftp.cpp mplayerxp/libmpsub/subreader.cpp mplayerxp/libmpsub/subreader.h mplayerxp/libmpsub/vobsub.cpp mplayerxp/libvo2/font_load.cpp mplayerxp/libvo2/font_load.h mplayerxp/libvo2/screenshot.cpp mplayerxp/postproc/af_hrtf.cpp mplayerxp/postproc/af_raw.cpp mplayerxp/postproc/libmenu/menu_filesel.cpp mplayerxp/postproc/libmenu/menu_txt.cpp mplayerxp/postproc/vf_raw.cpp mplayerxp/postproc/vf_scale.cpp mplayerxp/win32loader/dshow/DS_Filter.c Modified: mplayerxp/dump.cpp =================================================================== --- mplayerxp/dump.cpp 2013-05-14 12:02:20 UTC (rev 638) +++ mplayerxp/dump.cpp 2013-05-14 14:45:21 UTC (rev 639) @@ -4,6 +4,8 @@ /* dump.c - stream dumper */ +#include <iostream> +#include <fstream> #include <stdio.h> #include <stdlib.h> @@ -28,8 +30,7 @@ int dump_parse(const char *param) { int type=0; - const char *tile; - tile=mrl_parse_line(param,NULL,NULL,&media,&port); + mrl_parse_line(param,NULL,NULL,&media,&port); if(!media) return 0; if(strcmp(media,"stream")==0) type=1; else type=2; @@ -40,7 +41,7 @@ { char buf[4096]; int len; - FILE *f; + std::ofstream f; const char *ext,*name; MP_UNIT("dumpstream"); stream->reset(); @@ -56,17 +57,17 @@ strcpy(buf,port); } name=buf; - f=fopen(name,"wb"); - if(!f){ + f.open(name,std::ios_base::out|std::ios_base::binary); + if(!f.is_open()){ MSG_FATAL(MSGTR_CantOpenDumpfile); exit_player(MSGTR_Fatal_error); } MSG_INFO("Dumping stream to %s\n",name); while(!stream->eof()){ len=stream->read(buf,4096); - if(len>0) fwrite(buf,len,1,f); + if(len>0) f.write(buf,len); } - fclose(f); + f.close(); mpxp_info<<MSGTR_StreamDumped<<std::endl; exit_player(MSGTR_Exit_eof); } @@ -82,7 +83,7 @@ virtual ~dump_priv_t() {} int my_use_pts; - FILE* mux_file; + std::ofstream mux_file; muxer_t* muxer; muxer_stream_t *m_audio,*m_video,*m_subs; unsigned decoded_frameno; @@ -141,9 +142,9 @@ MSG_FATAL("Unsupported muxer format %s found\n",media); exit_player(MSGTR_Fatal_error); } - priv->mux_file=fopen(stream_dump_name,"wb"); + priv->mux_file.open(stream_dump_name,std::ios_base::out|std::ios_base::binary); MSG_DBG2("Preparing stream dumping: %s\n",stream_dump_name); - if(!priv->mux_file){ + if(!priv->mux_file.is_open()){ MSG_FATAL(MSGTR_CantOpenDumpfile); exit_player(MSGTR_Fatal_error); } @@ -270,10 +271,10 @@ if(demuxer->sub->sh) { if(priv->m_subs) MSG_V("Finishing sstream as\n"); } - fseeko(priv->mux_file,0,SEEK_SET); + priv->mux_file.seekp(0,std::ios_base::beg); muxer_write_header(priv->muxer,demuxer); - fclose(priv->mux_file); - delete demuxer->priv; + priv->mux_file.close(); + delete priv; demuxer->priv=NULL; } mpxp_info<<MSGTR_StreamDumped<<std::endl; Modified: mplayerxp/libao3/ao_null.cpp =================================================================== --- mplayerxp/libao3/ao_null.cpp 2013-05-14 12:02:20 UTC (rev 638) +++ mplayerxp/libao3/ao_null.cpp 2013-05-14 14:45:21 UTC (rev 639) @@ -1,6 +1,9 @@ #include "mpxp_config.h" #include "osdep/mplib.h" using namespace usr; +#include <iostream> +#include <fstream> + #include <stdint.h> #include <stdio.h> #include <stdlib.h> @@ -88,7 +91,7 @@ struct timeval last_tv; int buffer; - FILE* fd; + std::ofstream fd; int fast_mode; int wav_mode; }; @@ -96,13 +99,14 @@ Null_AO_Interface::Null_AO_Interface(const std::string& _subdevice) :AO_Interface(_subdevice) {} Null_AO_Interface::~Null_AO_Interface() { - if(fd && wav_mode && fseeko(fd, 0, SEEK_SET) == 0){ /* Write wave header */ + if(fd.is_open() && wav_mode){ /* Write wave header */ + fd.seekp(0, std::ios_base::beg); wavhdr.file_length = wavhdr.data_length + sizeof(wavhdr) - 8; wavhdr.file_length = le2me_32(wavhdr.file_length); wavhdr.data_length = le2me_32(wavhdr.data_length); - ::fwrite(&wavhdr,sizeof(wavhdr),1,fd); + fd.write((char*)&wavhdr,sizeof(wavhdr)); } - if(fd) ::fclose(fd); + if(fd.is_open()) fd.close(); } void Null_AO_Interface::drain() { @@ -139,8 +143,7 @@ UNUSED(flags); if (!subdevice.empty()) { mrl_parse_line(subdevice,NULL,NULL,&null_dev,&mode); - fd=NULL; - if(null_dev) fd = ::fopen(null_dev, "wb"); + if(null_dev) fd.open(null_dev, std::ios_base::out|std::ios_base::binary); if(::strcmp(mode,"wav")==0) wav_mode=1; } //end parsing subdevice return MPXP_Ok; @@ -179,7 +182,7 @@ } buffer=0; gettimeofday(&last_tv, 0); - if(fd && wav_mode) { + if(fd.is_open() && wav_mode) { wavhdr.channels = le2me_16(_channels); wavhdr.sample_rate = le2me_32(_samplerate); wavhdr.bytes_per_second = le2me_32(afmt2bps(_format)); @@ -188,7 +191,7 @@ wavhdr.data_length=le2me_32(0x7ffff000); wavhdr.file_length = wavhdr.data_length + sizeof(wavhdr) - 8; - ::fwrite(&wavhdr,sizeof(wavhdr),1,fd); + fd.write((char*)&wavhdr,sizeof(wavhdr)); wavhdr.file_length=wavhdr.data_length=0; } return MPXP_Ok; @@ -225,7 +228,7 @@ UNUSED(flags); if(fd && len) { mpxp_dbg2<<"writing "<<len<<" bytes into file"<<std::endl; - ::fwrite(data,len,1,fd); + fd.write((const char*)data,len); wavhdr.data_length += len; } return fast_mode?bursts*_outburst:len; Modified: mplayerxp/libao3/ao_wav.cpp =================================================================== --- mplayerxp/libao3/ao_wav.cpp 2013-05-14 12:02:20 UTC (rev 638) +++ mplayerxp/libao3/ao_wav.cpp 2013-05-14 14:45:21 UTC (rev 639) @@ -20,6 +20,9 @@ * with MPlayer; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include <iostream> +#include <fstream> + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -92,7 +95,7 @@ int fast; uint64_t data_length; - FILE* fp; + std::ofstream fp; WaveHeader wavhdr; unsigned _channels,_samplerate,_format; unsigned _buffersize,_outburst; @@ -102,13 +105,8 @@ :AO_Interface(_subdevice) {} Wave_AO_Interface::~Wave_AO_Interface() { if(pcm_waveheader){ /* Rewrite wave header */ - int broken_seek = 0; -#ifdef __MINGW32__ - // Windows, in its usual idiocy "emulates" seeks on pipes so it always looks - // like they work. So we have to detect them brute-force. - broken_seek = GetFileType((HANDLE)_get_osfhandle(_fileno(fp))) != FILE_TYPE_DISK; -#endif - if (broken_seek || fseek(fp, 0, SEEK_SET) != 0) + fp.seekp(0,std::ios_base::beg); + if (!fp.good()) mpxp_err<<"Could not seek to start, WAV size headers not updated!"<<std::endl; else if (data_length > 0x7ffff000) mpxp_err<<"File larger than allowed for WAV files, may play truncated!"<<std::endl; @@ -116,10 +114,10 @@ wavhdr.file_length = data_length + sizeof(wavhdr) - 8; wavhdr.file_length = le2me_32(wavhdr.file_length); wavhdr.data_length = le2me_32(data_length); - ::fwrite(&wavhdr,sizeof(wavhdr),1,fp); + fp.write((char*)&wavhdr,sizeof(wavhdr)); } } - ::fclose(fp); + fp.close(); } // to set/get/query special features/parameters @@ -189,10 +187,10 @@ wavhdr.file_length = wavhdr.data_length + sizeof(wavhdr) - 8; mpxp_info<<"ao_wav: "<<out_filename<<" "<<_samplerate<<"-"<<((_channels > 1) ? "Stereo" : "Mono")<<" "<<afmt2str(_format)<<std::endl; - fp = ::fopen(out_filename.c_str(), "wb"); - if(fp) { + fp.open(out_filename.c_str(),std::ios_base::out|std::ios_base::binary); + if(fp.is_open()) { if(pcm_waveheader){ /* Reserve space for wave header */ - ::fwrite(&wavhdr,sizeof(wavhdr),1,fp); + fp.write((char*)&wavhdr,sizeof(wavhdr)); } return MPXP_Ok; } @@ -222,7 +220,7 @@ // return: number of bytes played unsigned Wave_AO_Interface::play(const any_t* data,unsigned len,unsigned flags){ UNUSED(flags); - ::fwrite(data,len,1,fp); + fp.write((const char*)data,len); if(pcm_waveheader) data_length += len; return len; } Modified: mplayerxp/libmpcodecs/vd_qtvideo.cpp =================================================================== --- mplayerxp/libmpcodecs/vd_qtvideo.cpp 2013-05-14 12:02:20 UTC (rev 638) +++ mplayerxp/libmpcodecs/vd_qtvideo.cpp 2013-05-14 14:45:21 UTC (rev 639) @@ -260,21 +260,12 @@ //Fill the imagedescription for our SVQ3 frame //we can probably get this from Demuxer -#if 0 - framedescHandle=(ImageDescriptionHandle)NewHandleClear(sizeof(ImageDescription)+200); - MSG_V("framedescHandle=%p *p=%p\n",framedescHandle,*framedescHandle); -{ FILE* f=fopen("/root/.wine/fake_windows/IDesc","r"); - if(!f) MSG_ERR("filenot found: IDesc\n"); - fread(*framedescHandle,sizeof(ImageDescription)+200,1,f); - fclose(f); -} -#else if(!sh->ImageDesc) sh->ImageDesc=reinterpret_cast<ImageDescription*>(sh->bih+1); // hack for SVQ3-in-AVI MSG_V("ImageDescription size: %d\n",((ImageDescription*)(sh->ImageDesc))->idSize); framedescHandle=(ImageDescriptionHandle)NewHandleClear(((ImageDescription*)(sh->ImageDesc))->idSize); memcpy(*framedescHandle,sh->ImageDesc,((ImageDescription*)(sh->ImageDesc))->idSize); dump_ImageDescription(*framedescHandle); -#endif + //Find codecscomponent for video decompression // result = FindCodec ('SVQ1',anyCodec,&compressor,&decompressor ); // MSG_V("FindCodec SVQ1 returned:%i compressor: 0x%X decompressor: 0x%X\n",result,compressor,decompressor); Modified: mplayerxp/libmpconf/cfgparser.cpp =================================================================== --- mplayerxp/libmpconf/cfgparser.cpp 2013-05-14 12:02:20 UTC (rev 638) +++ mplayerxp/libmpconf/cfgparser.cpp 2013-05-14 14:45:21 UTC (rev 639) @@ -10,6 +10,8 @@ */ #include <algorithm> #include <limits> +#include <iostream> +#include <fstream> #include <stdlib.h> #include <stdio.h> @@ -342,7 +344,7 @@ static const int MAX_PARAM_LEN=100; MPXP_Rc M_Config::parse_config_file(const std::string& conffile) { - FILE *fp; + std::ifstream fs; char *line; char opt[MAX_OPT_LEN + 1]; char param[MAX_PARAM_LEN + 1]; @@ -374,7 +376,8 @@ goto out; } - if ((fp = ::fopen(conffile.c_str(), "r")) == NULL) { + fs.open(conffile.c_str(),std::ios_base::in); + if (!fs.is_open()) { if (recursion_depth > 1) mpxp_err<<": "<<::strerror(errno)<<std::endl; delete line; ret = MPXP_Ok; @@ -382,7 +385,8 @@ } if (recursion_depth > 1) mpxp_fatal<<std::endl; - while (fgets(line, MAX_LINE_LEN, fp)) { + while (!fs.eof()) { + fs.getline(line, MAX_LINE_LEN); if (errors >= 16) { mpxp_fatal<<"too many errors"<<std::endl; goto out; @@ -504,7 +508,7 @@ } delete line; - fclose(fp); + fs.close(); out: --recursion_depth; return ret; Modified: mplayerxp/libmpdemux/demux_avi.cpp =================================================================== --- mplayerxp/libmpdemux/demux_avi.cpp 2013-05-14 12:02:20 UTC (rev 638) +++ mplayerxp/libmpdemux/demux_avi.cpp 2013-05-14 14:45:21 UTC (rev 639) @@ -622,45 +622,6 @@ delete priv->suidx; } -/* Read a saved index file */ -#if 0 -if (index_file_load) { - FILE *fp; - char magic[7]; - unsigned int i; - - if ((fp = fopen(index_file_load, "r")) == NULL) { - MSG_ERR(MSGTR_MPDEMUX_AVIHDR_CantReadIdxFile, index_file_load, strerror(errno)); - goto gen_index; - } - fread(&magic, 6, 1, fp); - if (strncmp(magic, "MPIDX1", 6)) { - MSG_ERR(MSGTR_MPDEMUX_AVIHDR_NotValidMPidxFile, index_file_load); - goto gen_index; - } - fread(&priv->idx_size, sizeof(priv->idx_size), 1, fp); - priv->idx=mp_malloc(priv->idx_size*sizeof(AVIINDEXENTRY)); - if (!priv->idx) { - MSG_ERR(MSGTR_MPDEMUX_AVIHDR_FailedMallocForIdxFile, index_file_load); - priv->idx_size = 0; - goto gen_index; - } - - for (i=0; i<priv->idx_size;i++) { - AVIINDEXENTRY *idx; - idx=&((AVIINDEXENTRY *)priv->idx)[i]; - fread(idx, sizeof(AVIINDEXENTRY), 1, fp); - if (feof(fp)) { - MSG_ERR(MSGTR_MPDEMUX_AVIHDR_PrematureEOF, index_file_load); - delete priv->idx; - priv->idx_size = 0; - goto gen_index; - } - } - fclose(fp); - mp_msg(MSGT_HEADER,MSGL_INFO, MSGTR_MPDEMUX_AVIHDR_IdxFileLoaded, index_file_load); -} -#endif /* Generate indexes */ if(index_mode>=2 || (priv->idx_size==0 && index_mode==1)){ // build index for file: @@ -735,27 +696,6 @@ priv->idx_size=priv->idx_pos; MSG_INFO("Indexed are generated for %ul chunks\n",priv->idx_size); if(mp_conf.verbose>=2) print_index(priv->idx,priv->idx_size); - -#if 0 - /* Write generated index to a file */ - if (index_file_save) { - FILE *fp; - unsigned int i; - - if ((fp=fopen(index_file_save, "w")) == NULL) { - MSG_ERR(MSGTR_MPDEMUX_AVIHDR_Failed2WriteIdxFile, index_file_save, strerror(errno)); - return; - } - fwrite("MPIDX1", 6, 1, fp); - fwrite(&priv->idx_size, sizeof(priv->idx_size), 1, fp); - for (i=0; i<priv->idx_size; i++) { - AVIINDEXENTRY *idx = &((AVIINDEXENTRY *)priv->idx)[i]; - fwrite(idx, sizeof(AVIINDEXENTRY), 1, fp); - } - fclose(fp); - MSG_INFO(MSGTR_MPDEMUX_AVIHDR_IdxFileSaved, index_file_save); - } -#endif } } #undef MIN Modified: mplayerxp/libmpdemux/demux_ogg.cpp =================================================================== --- mplayerxp/libmpdemux/demux_ogg.cpp 2013-05-14 12:02:20 UTC (rev 638) +++ mplayerxp/libmpdemux/demux_ogg.cpp 2013-05-14 14:45:21 UTC (rev 639) @@ -182,7 +182,6 @@ static subtitle ogg_sub; static float clear_sub; -//FILE* subout; static MPXP_Rc ogg_probe(Demuxer *demuxer) { Modified: mplayerxp/libmpdemux/mux_mpxp64.cpp =================================================================== --- mplayerxp/libmpdemux/mux_mpxp64.cpp 2013-05-14 12:02:20 UTC (rev 638) +++ mplayerxp/libmpdemux/mux_mpxp64.cpp 2013-05-14 14:45:21 UTC (rev 639) @@ -62,105 +62,105 @@ float prev_seek; }priv_mpxpav64_t; -static void mpxpav64_put64(FILE *f,uint64_t value) +static void mpxpav64_put64(std::ofstream& f,uint64_t value) { uint64_t val; val = me2le_64(value); - fwrite(&val,8,1,f); + f.write((char*)&val,8); } -static void mpxpav64_put32(FILE *f,uint32_t value) +static void mpxpav64_put32(std::ofstream& f,uint32_t value) { uint32_t val; val = me2le_32(value); - fwrite(&val,4,1,f); + f.write((char*)&val,4); } -static void mpxpav64_put16(FILE *f,uint16_t value) +static void mpxpav64_put16(std::ofstream& f,uint16_t value) { uint16_t val; val = me2le_16(value); - fwrite(&val,2,1,f); + f.write((char*)&val,2); } -static void mpxpav64_put8(FILE *f,uint8_t value) +static void mpxpav64_put8(std::ofstream& f,uint8_t value) { - fwrite(&value,1,1,f); + f.write((char*)&value,1); } -static void mpxpav64_put_pts64(FILE *f,double value) +static void mpxpav64_put_pts64(std::ofstream& f,double value) { uint64_t val; val = llrint(value*1000); /* 1 ms */ mpxpav64_put64(f,val); } -static void mpxpav64_put_pts32(FILE *f,float value) +static void mpxpav64_put_pts32(std::ofstream& f,float value) { uint32_t val; val = PTS2INT(value); /* 1 ms */ mpxpav64_put32(f,val); } -static void mpxpav64_put_pts16(FILE *f,float value) +static void mpxpav64_put_pts16(std::ofstream& f,float value) { uint16_t val; val = PTS2INT(value); /* 1 ms */ mpxpav64_put16(f,val); } -static void mpxpav64_put_pts8(FILE *f,float value) +static void mpxpav64_put_pts8(std::ofstream& f,float value) { uint8_t val; val = PTS2INT(value); /* 1 ms */ mpxpav64_put8(f,val); } -static void mpxpav64_put_unicode(FILE *f, const char *tag) +static void mpxpav64_put_unicode(std::ofstream& f, const char *tag) { size_t len; char *str=nls_recode_from_screen_cp("UTF-16LE",tag,&len); mpxpav64_put16(f,len); - fwrite(str,len,1,f); + f.write(str,len); delete str; } -static void mpxpav64_put_frcc_unicode(FILE *f, const char *frcc,const char *tag) +static void mpxpav64_put_frcc_unicode(std::ofstream& f, const char *frcc,const char *tag) { - fwrite(frcc,4,1,f); + f.write(frcc,4); mpxpav64_put_unicode(f,tag); } -static uint64_t mpxpav64_open_header64(FILE *f,const char *id) +static uint64_t mpxpav64_open_header64(std::ofstream& f,const char *id) { - fwrite(id,8,1,f); + f.write(id,8); mpxpav64_put64(f,-1); - return ftello(f); + return f.tellp(); } -static void mpxpav64_close_header64(FILE *f,uint64_t header_start) +static void mpxpav64_close_header64(std::ofstream& f,uint64_t header_start) { uint64_t header_end; - header_end = ftello(f); - fseeko(f,header_start-8,SEEK_SET); + header_end = f.tellp(); + f.seekp(header_start-8,std::ios_base::beg); mpxpav64_put64(f,header_end-header_start); - fseeko(f,header_end,SEEK_SET); + f.seekp(header_end,std::ios_base::beg); } -static uint64_t mpxpav64_open_header32(FILE *f,const char *id) +static uint64_t mpxpav64_open_header32(std::ofstream& f,const char *id) { - fwrite(id,4,1,f); + f.write(id,4); mpxpav64_put32(f,-1); - return ftello(f); + return f.tellp(); } -static void mpxpav64_close_header32(FILE *f,uint64_t header_start) +static void mpxpav64_close_header32(std::ofstream& f,uint64_t header_start) { uint64_t header_end; - header_end = ftello(f); - fseeko(f,header_start-4,SEEK_SET); + header_end = f.tellp(); + f.seekp(header_start-4,std::ios_base::beg); mpxpav64_put32(f,header_end-header_start); - fseeko(f,header_end,SEEK_SET); + f.seekp(header_end,std::ios_base::beg); } static muxer_stream_t* mpxpav64_new_stream(muxer_t *muxer,int type) @@ -206,7 +206,7 @@ static void mpxpav64_put_fcnt(muxer_t *muxer,Demuxer*dinfo) { uint64_t fpos; - FILE *f = muxer->file; + std::ofstream& f = muxer->file; const char *sname; fpos=mpxpav64_open_header32(f,"FCNT"); #ifdef USE_ICONV @@ -297,19 +297,19 @@ priv_mpxpav64_stream_t *privs=(priv_mpxpav64_stream_t *)s->priv; uint64_t fpos,spos,flags=0; uint8_t* frcc; - FILE *f = muxer->file; + std::ofstream& f = muxer->file; VideoPropHeader vprp; fpos=mpxpav64_open_header32(f,"ST64"); switch(s->type) { case MUXER_TYPE_VIDEO: - fwrite("vids",4,1,f); + f.write("vids",4); break; case MUXER_TYPE_AUDIO: - fwrite("auds",4,1,f); + f.write("auds",4); break; default: - fwrite("gens",4,1,f); + f.write("gens",4); break; } mpxpav64_put64(f,privs->data_off); @@ -336,10 +336,10 @@ case MUXER_TYPE_VIDEO: flags=13; mpxpav64_put8(f,flags); - fwrite("video/x-video",flags,1,f); + f.write("video/x-video",flags); spos=mpxpav64_open_header32(f,"BIH "); le2me_BITMAPINFOHEADER(s->bih); - fwrite(s->bih,s->bih->biSize,1,f); + f.write((char*)s->bih,s->bih->biSize); le2me_BITMAPINFOHEADER(s->bih); mpxpav64_close_header32(f,spos); if(s->aspect) @@ -363,7 +363,7 @@ le2me_VIDEO_FIELD_DESC(&vprp.FieldInfo[0]); le2me_VIDEO_FIELD_DESC(&vprp.FieldInfo[1]); spos=mpxpav64_open_header32(f,"vprp"); - fwrite(&vprp,sizeof(VideoPropHeader),1,f); + f.write((char*)&vprp,sizeof(VideoPropHeader)); le2me_VideoPropHeader(&vprp); le2me_VIDEO_FIELD_DESC(&vprp.FieldInfo[0]); le2me_VIDEO_FIELD_DESC(&vprp.FieldInfo[1]); @@ -374,7 +374,7 @@ ImageDescription id; spos=mpxpav64_open_header32(f,"IMGD"); le2me_ImageDesc(&id); - fwrite(&id,sizeof(ImageDescription),1,f); + f.write((char*)&id,sizeof(ImageDescription)); le2me_ImageDesc(&id); mpxpav64_close_header32(f,spos); } @@ -382,10 +382,10 @@ case MUXER_TYPE_AUDIO: flags=13; mpxpav64_put8(f,flags); - fwrite("audio/x-audio",flags,1,f); + f.write("audio/x-audio",flags); spos=mpxpav64_open_header32(f,"WAVE"); le2me_WAVEFORMATEX(s->wf); - fwrite(s->wf,WFSIZE(s->wf),1,f); + f.write((char*)s->wf,WFSIZE(s->wf)); le2me_WAVEFORMATEX(s->wf); mpxpav64_close_header32(f,spos); frcc=(uint8_t *)(&((sh_audio_t *)(s->source))->wtag); @@ -399,7 +399,7 @@ default: flags=17; mpxpav64_put8(f,flags); - fwrite("unknown/x-unknown",flags,1,f); + f.write("unknown/x-unknown",flags); break; } @@ -414,9 +414,9 @@ uint32_t max_bitrate=0; float pts; size_t i; - FILE *f = muxer->file; + std::ofstream& f = muxer->file; if(!pass) pmpxpav64->mainh=mpxpav64_open_header64(f,"MPXPAV64"); - else fseeko(f,16,SEEK_CUR); + else f.seekp(16,std::ios_base::cur); hpos=mpxpav64_open_header64(f,"HEADER64"); fpos=mpxpav64_open_header32(f,"FPRP"); tmp=0; @@ -447,7 +447,7 @@ for(i=0;i<muxer->avih.dwStreams;i++) mpxpav64_put_st64(muxer,muxer->streams[i]); mpxpav64_close_header64(f,hpos); if(!pass) pmpxpav64->datah=mpxpav64_open_header64(f,"AVDATA64"); - else fseeko(f,16,SEEK_CUR); + else f.seekp(16,std::ios_base::cur); pass++; } @@ -456,14 +456,14 @@ { priv_mpxpav64_t *pmpxpav64=(priv_mpxpav64_t *)s->muxer->priv; priv_mpxpav64_stream_t *privs=(priv_mpxpav64_stream_t *)s->priv; - FILE *f = s->muxer->file; + std::ofstream& f = s->muxer->file; uint64_t off; float xpts; uint8_t xflg; int want_pts32,is_seek; uint8_t seek[3]= {'S','E','E'}, Dx[2]; /* make indexes */ - off=ftello(f); + off=f.tellp(); xflg=0; is_seek=0; if(!privs->data_off) privs->data_off=off; @@ -503,7 +503,7 @@ else privs->idx=mp_realloc(privs->idx,(privs->idx_size+1)*sizeof(uint64_t)); ((uint64_t *)(privs->idx))[privs->idx_size]=off; privs->idx_size++; - fwrite(seek,3,1,f); + f.write((char*)seek,3); } want_pts32=0; if(privs->prev_pts==HUGE) want_pts32=1; @@ -537,7 +537,7 @@ Dx[0]=is_seek?'K':flags&AVIIF_KEYFRAME?'D':'d'; Dx[1]=xflg; - fwrite(Dx,2,1,f); + f.write((char*)Dx,2); if((xflg&0x80)==0x80) { if(s->id < 0x100U) mpxpav64_put8(f,s->id); @@ -557,7 +557,7 @@ else if(PTS2INT(xpts)<0x100000000ULL) mpxpav64_put_pts32(f,xpts); else mpxpav64_put_pts64(f,xpts); } - fwrite(s->buffer,len,1,f); + f.write((char*)s->buffer,len); MSG_V("MUX_MPXPAV64: write %lu bytes of #%u %08X flags %f pts %f\n",len,s->id,flags,pts,xpts); /* update statistic */ privs->npackets++; @@ -582,8 +582,8 @@ priv_mpxpav64_stream_t *privs=(priv_mpxpav64_stream_t *)s->priv; uint64_t ioff; uint32_t i; - FILE *f = s->muxer->file; - if(!privs->idx_off) privs->idx_off=ftello(f); + std::ofstream& f = s->muxer->file; + if(!privs->idx_off) privs->idx_off=f.tellp(); ioff=mpxpav64_open_header64(f,"INDEX_64"); mpxpav64_put32(f,s->id); for(i=0;i<privs->idx_size;i++) mpxpav64_put64(f,((uint64_t *)privs->idx)[i]); @@ -595,8 +595,8 @@ priv_mpxpav64_stream_t *privs=(priv_mpxpav64_stream_t *)s->priv; uint64_t ioff; uint32_t i; - FILE *f = s->muxer->file; - if(!privs->idx_off) privs->idx_off=ftello(f); + std::ofstream& f = s->muxer->file; + if(!privs->idx_off) privs->idx_off=f.tellp(); ioff=mpxpav64_open_header32(f,"IX32"); mpxpav64_put32(f,s->id); for(i=0;i<privs->idx_size;i++) mpxpav64_put32(f,((uint64_t *)privs->idx)[i]); @@ -608,8 +608,8 @@ off_t avdata64_size; priv_mpxpav64_t *pmpxpav64=(priv_mpxpav64_t *)muxer->priv; unsigned i; - FILE *f = muxer->file; - avdata64_size=ftello(f); + std::ofstream& f = muxer->file; + avdata64_size=f.tellp(); mpxpav64_close_header64(f,pmpxpav64->datah); for(i=0;i<muxer->avih.dwStreams;i++) { Modified: mplayerxp/libmpdemux/mux_raw.cpp =================================================================== --- mplayerxp/libmpdemux/mux_raw.cpp 2013-05-14 12:02:20 UTC (rev 638) +++ mplayerxp/libmpdemux/mux_raw.cpp 2013-05-14 14:45:21 UTC (rev 639) @@ -62,7 +62,7 @@ static void rawfile_write_chunk(muxer_stream_t *s,size_t len,unsigned int flags,float pts){ muxer_t *muxer=s->muxer; - fwrite(s->buffer,len,1,muxer->file); + muxer->file.write((char*)s->buffer,len); } static void rawfile_write_header(muxer_t *muxer,Demuxer*dinfo){ Modified: mplayerxp/libmpdemux/muxer.cpp =================================================================== --- mplayerxp/libmpdemux/muxer.cpp 2013-05-14 12:02:20 UTC (rev 638) +++ mplayerxp/libmpdemux/muxer.cpp 2013-05-14 14:45:21 UTC (rev 639) @@ -34,14 +34,13 @@ delete packet; } -muxer_t *muxer_new_muxer(const char *type,const char *subtype,FILE *f){ - muxer_t* muxer=new(zeromem) muxer_t; - muxer->file = f; -// if(!strcmp(type,"lavf")) { if(!muxer_init_muxer_lavf(muxer,subtype)) { delete muxer; muxer=NULL; }} +muxer_t *muxer_new_muxer(const std::string& type,const std::string& subtype,std::ofstream& f){ + muxer_t* muxer=new(zeromem) muxer_t(f); +// if(type=="lavf") { if(!muxer_init_muxer_lavf(muxer,subtype)) { delete muxer; muxer=NULL; }} // else - if(!strcmp(type,"mpxp")) muxer_init_muxer_mpxp64(muxer); + if(type=="mpxp") muxer_init_muxer_mpxp64(muxer); else - if(!strcmp(type,"raw")) muxer_init_muxer_raw(muxer); + if(type=="raw") muxer_init_muxer_raw(muxer); else { delete muxer; muxer=NULL; } return muxer; } Modified: mplayerxp/libmpdemux/muxer.h =================================================================== --- mplayerxp/libmpdemux/muxer.h 2013-05-14 12:02:20 UTC (rev 638) +++ mplayerxp/libmpdemux/muxer.h 2013-05-14 14:45:21 UTC (rev 639) @@ -1,5 +1,8 @@ #ifndef MUXER_H_INCLUDED #define MUXER_H_INCLUDED 1 +#include <string> +#include <iostream> +#include <fstream> enum { MUXER_MAX_STREAMS =16, @@ -62,6 +65,7 @@ }; struct muxer_t { + muxer_t(std::ofstream& f):file(f) {} // encoding: MainAVIHeader avih; muxer_stream_t* def_v; // default video stream (for general headers) @@ -71,18 +75,18 @@ void (*cont_write_header)(struct muxer_t *,Demuxer* dinfo); void (*cont_write_index)(struct muxer_t *); muxer_stream_t* (*cont_new_stream)(struct muxer_t *,int); - FILE* file; + std::ofstream& file; any_t*priv; }; -muxer_t *muxer_new_muxer(const char *type,const char *subtype,FILE *f); +muxer_t *muxer_new_muxer(const std::string& type,const std::string& subtype,std::ofstream& f); inline muxer_stream_t* muxer_new_stream(muxer_t* muxer,int a) { return muxer->cont_new_stream(muxer,a); } inline void muxer_write_chunk(muxer_stream_t* a,size_t b,unsigned c,float d) { a->muxer->cont_write_chunk(a,b,c,d); } inline void muxer_write_header(muxer_t* muxer,Demuxer* info) { if(muxer->cont_write_header) muxer->cont_write_header(muxer,info); } inline void muxer_write_index(muxer_t* muxer) { if(muxer->cont_write_index) muxer->cont_write_index(muxer); } inline void muxer_fix_parameters(muxer_t* muxer) { if(muxer->fix_parameters) muxer->fix_parameters(muxer); } -extern void muxer_init_muxer_raw(muxer_t *); -extern void muxer_init_muxer_mpxp64(muxer_t *); -extern int muxer_init_muxer_lavf(muxer_t *,const char *); +extern void muxer_init_muxer_raw(muxer_t*); +extern void muxer_init_muxer_mpxp64(muxer_t*); +extern int muxer_init_muxer_lavf(muxer_t*,const std::string&); #endif Modified: mplayerxp/libmpdemux/stheader.cpp =================================================================== --- mplayerxp/libmpdemux/stheader.cpp 2013-05-14 12:02:20 UTC (rev 638) +++ mplayerxp/libmpdemux/stheader.cpp 2013-05-14 14:45:21 UTC (rev 639) @@ -126,7 +126,7 @@ (fourcc == mmioFOURCC('m','p','e','g')) || (fourcc == mmioFOURCC('M','P','E','G'))) { - int saved_pos; +// int saved_pos; Demuxer::demuxer_type_e saved_type; /* demuxer pos saving is required for libavcodec mpeg decoder as it's Modified: mplayerxp/libmpstream2/network_asf.cpp =================================================================== --- mplayerxp/libmpstream2/network_asf.cpp 2013-05-14 12:02:20 UTC (rev 638) +++ mplayerxp/libmpstream2/network_asf.cpp 2013-05-14 14:45:21 UTC (rev 639) @@ -88,17 +88,17 @@ return stream_chunck->size+4; } -static const char asf_stream_header_guid[16] = {0x91, 0x07, 0xdc, 0xb7, +static const uint8_t asf_stream_header_guid[16] = {0x91, 0x07, 0xdc, 0xb7, 0xb7, 0xa9, 0xcf, 0x11, 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65}; -static const char asf_file_header_guid[16] = {0xa1, 0xdc, 0xab, 0x8c, +static const uint8_t asf_file_header_guid[16] = {0xa1, 0xdc, 0xab, 0x8c, 0x47, 0xa9, 0xcf, 0x11, 0x8e, 0xe4, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65}; -static const char asf_content_desc_guid[16] = {0x33, 0x26, 0xb2, 0x75, +static const uint8_t asf_content_desc_guid[16] = {0x33, 0x26, 0xb2, 0x75, 0x8e, 0x66, 0xcf, 0x11, 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c}; -static const char asf_stream_group_guid[16] = {0xce, 0x75, 0xf8, 0x7b, +static const uint8_t asf_stream_group_guid[16] = {0xce, 0x75, 0xf8, 0x7b, 0x8d, 0x46, 0xd1, 0x11, 0x8d, 0x82, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2}; -static const char asf_data_chunk_guid[16] = {0x36, 0x26, 0xb2, 0x75, +static const uint8_t asf_data_chunk_guid[16] = {0x36, 0x26, 0xb2, 0x75, 0x8e, 0x66, 0xcf, 0x11, 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c}; -static int find_asf_guid(char *buf, const char *guid, int cur_pos, int buf_len) +static int find_asf_guid(char *buf, const uint8_t *guid, int cur_pos, int buf_len) { int i; for (i = cur_pos; i < buf_len - 19; i++) { Modified: mplayerxp/libmpstream2/s_ftp.cpp =================================================================== --- mplayerxp/libmpstream2/s_ftp.cpp 2013-05-14 12:02:20 UTC (rev 638) +++ mplayerxp/libmpstream2/s_ftp.cpp 2013-05-14 14:45:21 UTC (rev 639) @@ -275,7 +275,7 @@ // Close current download if(tcp.established()) { - static const char pre_cmd[]={TELNET_IAC,TELNET_IP,TELNET_IAC,TELNET_SYNCH}; + static const uint8_t pre_cmd[]={TELNET_IAC,TELNET_IP,TELNET_IAC,TELNET_SYNCH}; //int fl; // Send send the telnet sequence needed to make the server react Modified: mplayerxp/libmpsub/subreader.cpp =================================================================== --- mplayerxp/libmpsub/subreader.cpp 2013-05-14 12:02:20 UTC (rev 638) +++ mplayerxp/libmpsub/subreader.cpp 2013-05-14 14:45:21 UTC (rev 639) @@ -8,8 +8,9 @@ * Some code cleanup & mp_realloc() by A'rpi/ESP-team * dunnowhat sub format by szabi */ +#include <iostream> +#include <fstream> - #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -53,8 +54,7 @@ while (i > 0 && isspace(s[i])) s[i--] = '\0'; } - -static subtitle * __FASTCALL__ sub_read_line_sami(FILE *fd, subtitle *current) { +static subtitle * __FASTCALL__ sub_read_line_sami(std::ifstream& fd, subtitle *current) { static char line[LINE_LEN+1]; static char *s = NULL, *slacktime_s; char text[LINE_LEN+1], *p=NULL, *q; @@ -64,9 +64,10 @@ state = 0; /* read the first line */ - if (!s) - if (!(s = fgets(line, LINE_LEN, fd))) return 0; - + if (!s) { + fd.getline(line,LINE_LEN); + if (!fd.good()) return 0; + } do { switch (state) { @@ -124,7 +125,8 @@ } /* read next line */ - if (state != 99 && !(s = fgets (line, LINE_LEN, fd))) { + fd.getline(line,LINE_LEN); + if (state != 99 && !fd.good()) { if (current->start > 0) { break; // if it is the last subtitle } else { @@ -166,7 +168,7 @@ else return NULL; // last text field } -static subtitle * __FASTCALL__ sub_read_line_microdvd(FILE *fd,subtitle *current) { +static subtitle * __FASTCALL__ sub_read_line_microdvd(std::ifstream& fd,subtitle *current) { char line[LINE_LEN+1]; char line2[LINE_LEN+1]; char *p; @@ -174,7 +176,8 @@ int i; do { - if (!fgets (line, LINE_LEN, fd)) return NULL; + fd.getline(line,LINE_LEN); + if (!fd.good()) return NULL; } while ((sscanf (line, "{%ld}{}%[^\r\n]", &(current->start), line2) < 2) && @@ -195,19 +198,21 @@ return current; } -static subtitle * __FASTCALL__ sub_read_line_subrip(FILE *fd, subtitle *current) { +static subtitle * __FASTCALL__ sub_read_line_subrip(std::ifstream& fd, subtitle *current) { char line[LINE_LEN+1]; int a1,a2,a3,a4,b1,b2,b3,b4; char *p=NULL, *q=NULL; int len; while (1) { - if (!fgets (line, LINE_LEN, fd)) return NULL; + fd.getline(line, LINE_LEN); + if (!fd.good()) return NULL; if (sscanf (line, "%d:%d:%d.%d,%d:%d:%d.%d",&a1,&a2,&a3,&a4,&b1,&b2,&b3,&b4) < 8) continue; current->start = a1*360000+a2*6000+a3*100+a4; current->end = b1*360000+b2*6000+b3*100+b4; - if (!fgets (line, LINE_LEN, fd)) return NULL; + fd.getline(line, LINE_LEN); + if (!fd.good()) return NULL; p=q=line; for (current->lines=1; current->lines < SUB_MAX_TEXT; current->lines++) { @@ -224,20 +229,22 @@ return current; } -static subtitle * __FASTCALL__ sub_read_line_subviewer(FILE *fd,subtitle *current) { +static subtitle * __FASTCALL__ sub_read_line_subviewer(std::ifstream& fd,subtitle *current) { char line[LINE_LEN+1]; int a1,a2,a3,a4,b1,b2,b3,b4; char *p=NULL; int i,len; while (!current->text[0]) { - if (!fgets (line, LINE_LEN, fd)) return NULL; + fd.getline(line, LINE_LEN); + if (!fd.good()) return NULL; if ((len=sscanf (line, "%d:%d:%d,%d --> %d:%d:%d,%d",&a1,&a2,&a3,&a4,&b1,&b2,&b3,&b4)) < 8) continue; current->start = a1*360000+a2*6000+a3*100+a4/10; current->end = b1*360000+b2*6000+b3*100+b4/10; for (i=0; i<SUB_MAX_TEXT;) { - if (!fgets (line, LINE_LEN, fd)) break; + fd.getline(line, LINE_LEN); + if (!fd.good()) break; len=0; for (p=line; *p!='\n' && *p!='\r' && *p; p++,len++); if (len) { @@ -254,7 +261,7 @@ return current; } -static subtitle * __FASTCALL__ sub_read_line_vplayer(FILE *fd,subtitle *current) { +static subtitle * __FASTCALL__ sub_read_line_vplayer(std::ifstream& fd,subtitle *current) { char line[LINE_LEN+1]; int a1,a2,a3; char *p=NULL, separator; @@ -262,7 +269,8 @@ int i,len,plen; while (!current->text[0]) { - if (!fgets (line, LINE_LEN, fd)) return NULL; + fd.getline(line, LINE_LEN); + if (!fd.good()) return NULL; if ((len=sscanf (line, "%d:%d:%d%c%n",&a1,&a2,&a3,&separator,&plen)) < 4) continue; @@ -288,7 +296,7 @@ return current; } -static subtitle * __FASTCALL__ sub_read_line_rt(FILE *fd,subtitle *current) { +static subtitle * __FASTCALL__ sub_read_line_rt(std::ifstream& fd,subtitle *current) { //TODO: This format uses quite rich (sub/super)set of xhtml // I couldn't check it since DTD is not included. // WARNING: full XML parses can be required for proper parsing @@ -299,7 +307,8 @@ int i,len,plen; while (!current->text[0]) { - if (!fgets (line, LINE_LEN, fd)) return NULL; + fd.getline(line, LINE_LEN); + if (!fd.good()) return NULL; //TODO: it seems that format of time is not easily determined, it may be 1:12, 1:12.0 or 0:1:12.0 //to describe the same moment in time. Maybe there are even more formats in use. //if ((len=sscanf (line, "<Time Begin=\"%d:%d:%d.%d\" End=\"%d:%d:%d.%d\"",&a1,&a2,&a3,&a4,&b1,&b2,&b3,&b4)) < 8) @@ -327,7 +336,7 @@ return current; } -static subtitle * __FASTCALL__ sub_read_line_ssa(FILE *fd,subtitle *current) { +static subtitle * __FASTCALL__ sub_read_line_ssa(std::ifstream& fd,subtitle *current) { int hour1, min1, sec1, hunsec1, hour2, min2, sec2, hunsec2, nothing; int num; @@ -338,7 +347,8 @@ char *tmp; do { - if (!fgets (line, LINE_LEN, fd)) return NULL; + fd.getline(line, LINE_LEN); + if (!fd.good()) return NULL; } while (sscanf (line, "Dialogue: Marked=%d,%d:%d:%d.%d,%d:%d:%d.%d," "%[^\n\r]", ¬hing, &hour1, &min1, &sec1, &hunsec1, @@ -369,12 +379,12 @@ return current; } -static subtitle * __FASTCALL__ sub_read_line_dunnowhat(FILE *fd,subtitle *current) { +static subtitle * __FASTCALL__ sub_read_line_dunnowhat(std::ifstream& fd,subtitle *current) { char line[LINE_LEN+1]; char text[LINE_LEN+1]; - if (!fgets (line, LINE_LEN, fd)) - return NULL; + fd.getline(line, LINE_LEN); + if (!fd.good()) return NULL; if (sscanf (line, "%ld,%ld,\"%[^\"]", &(current->start), &(current->end), text) <3) return (subtitle*)ERR; @@ -384,7 +394,7 @@ return current; } -static subtitle * __FASTCALL__ sub_read_line_mpsub(FILE *fd, subtitle *current) { +static subtitle * __FASTCALL__ sub_read_line_mpsub(std::ifstream& fd, subtitle *current) { char line[LINE_LEN+1]; float a,b; int num=0; @@ -392,7 +402,8 @@ do { - if (!fgets(line, LINE_LEN, fd)) return NULL; + fd.getline(line, LINE_LEN); + if (!fd.good()) return NULL; } while (sscanf (line, "%f %f", &a, &b) !=2); mpsub_position += a*(sub_uses_time ? 100.0 : 1.0); @@ -401,7 +412,8 @@ current->end=(int) mpsub_position; while (num < SUB_MAX_TEXT) { - if (!fgets (line, LINE_LEN, fd)) { + fd.getline(line, LINE_LEN); + if (!fd.good()) { if (num == 0) return NULL; else return current; } @@ -425,12 +437,13 @@ static subtitle *previous_aqt_sub = NULL; -static subtitle * __FASTCALL__ sub_read_line_aqt(FILE *fd,subtitle *current) { +static subtitle * __FASTCALL__ sub_read_line_aqt(std::ifstream& fd,subtitle *current) { char line[LINE_LEN+1]; while (1) { // try to locate next subtitle - if (!fgets (line, LINE_LEN, fd)) + fd.getline(line, LINE_LEN); + if (!fd.good()) return NULL; if (!(sscanf (line, "-->> %ld", &(current->start)) <1)) break; @@ -441,15 +454,15 @@ previous_aqt_sub = current; - if (!fgets (line, LINE_LEN, fd)) - return NULL; + fd.getline(line, LINE_LEN); + if (!fd.good()) return NULL; sub_readtext(line,¤t->text[0]); current->lines = 1; current->end = current->start; // will be corrected by next subtitle - if (!fgets (line, LINE_LEN, fd)) - return current;; + fd.getline(line, LINE_LEN); + if (!fd.good()) return current; sub_readtext(line,¤t->text[1]); current->lines = 2; @@ -463,15 +476,15 @@ return current; } -static int sub_autodetect (FILE *fd) { +static int sub_autodetect (std::ifstream& fd) { char line[LINE_LEN+1]; int i,j=0; char p; while (j < 100) { j++; - if (!fgets (line, LINE_LEN, fd)) - return SUB_INVALID; + fd.getline(line, LINE_LEN); + if (!fd.good()) return SUB_INVALID; if (sscanf (line, "{%d}{%d}", &i, &i)==2) {sub_uses_time=0;return SUB_MICRODVD;} @@ -628,7 +641,7 @@ static const char *fmtname[] = { "microdvd", "subrip", "subviewer", "sami", "vplayer", "rt", "ssa", "dunnowhat", "mpsub", "aqt" }; -static subtitle * (*__FASTCALL__ func[])(FILE *fd,subtitle *dest)= +static subtitle * (*__FASTCALL__ func[])(std::ifstream& fd,subtitle *dest)= { sub_read_line_microdvd, sub_read_line_subrip, @@ -642,18 +655,18 @@ sub_read_line_aqt }; -subtitle* sub_read_file (const char *filename, float fps) { - FILE *fd; +subtitle* sub_read_file (const std::string& filename, float fps) { + std::ifstream fd; int n_max; subtitle *first; - if(filename==NULL) return NULL; //qnx segfault - fd=fopen (filename, "r"); if (!fd) return NULL; + if(filename.empty()) return NULL; //qnx segfault + fd.open (filename.c_str(),std::ios_base::in); if (!fd.is_open()) return NULL; sub_format=sub_autodetect (fd); - if (sub_format==SUB_INVALID) { MSG_ERR ("SUB: Could not determine file format\n"); fclose(fd); return NULL;} + if (sub_format==SUB_INVALID) { MSG_ERR ("SUB: Could not determine file format\n"); fd.close(); return NULL;} MSG_INFO ("SUB: Detected subtitle file format: %s\n", fmtname[sub_format]); - rewind (fd); + fd.seekg(0,std::ios_base::beg); #ifdef USE_ICONV subcp_open(); @@ -661,7 +674,7 @@ sub_num=0;n_max=32; first=(subtitle *)mp_malloc(n_max*sizeof(subtitle)); - if(!first) { fclose(fd); return NULL; } + if(!first) { fd.close(); return NULL; } while(1){ subtitle *sub; @@ -679,7 +692,7 @@ if(sub==ERR) ++sub_errs; else ++sub_num; // Error vs. Valid } - fclose(fd); + fd.close(); #ifdef USE_ICONV subcp_close(); @@ -729,31 +742,28 @@ ".aqt", ".AQT" }; -char * sub_filename(const char* path,const char * fname ) +std::string sub_filename(const std::string& path,const std::string& fname ) { char * sub_name1; char * sub_name2; char * aviptr1, * aviptr2; - const char * tmp; unsigned i,j; - FILE * f; - int pos=0; + std::ifstream f; + if (fname.empty()) return NULL; - if ( fname == NULL ) return NULL; - - sub_name1=(char *)strrchr(fname,'.'); + sub_name1=(char *)strrchr(fname.c_str(),'.'); if (!sub_name1) return NULL; - pos=sub_name1-fname; - sub_name1=new char [strlen(fname)+8]; - strcpy(sub_name1,fname); + sub_name1=new char [fname.length()+8]; + strcpy(sub_name1,fname.c_str()); - sub_name2=new char [strlen(path) + strlen(fname) + 8]; - if ((tmp=strrchr(fname,'/'))) - sprintf (sub_name2, "%s%s", path, tmp+1); + sub_name2=new char [path.length() + fname.length() + 8]; + size_t tmp=fname.rfind('/'); + if (tmp!=std::string::npos) + sprintf (sub_name2, "%s%s", path.c_str(), fname.substr(tmp+1).c_str()); else - sprintf (sub_name2, "%s%s", path, fname); + sprintf (sub_name2, "%s%s", path.c_str(), fname.c_str()); aviptr1=strrchr(sub_name1,'.'); aviptr2=strrchr(sub_name2,'.'); @@ -766,8 +776,9 @@ for ( i=0;i<(sizeof(sub_exts)/sizeof(char*));i++ ) { #endif strcpy(j?aviptr1:aviptr2,sub_exts[i]); - if((f=fopen( sub_name,"rt" ))) { - fclose( f ); + f.open(sub_name); + if(f.is_open()) { + f.close(); MSG_INFO( "SUB: Detected sub file: %s\n",sub_name ); if (i<2) sub_data.utf8=1; return sub_name; @@ -776,7 +787,7 @@ } delete sub_name1; delete sub_name2; - return NULL; + return ""; } void list_sub_file(subtitle* subs){ @@ -802,48 +813,44 @@ void dump_mpsub(subtitle* subs, float fps){ int i,j; - FILE *fd; + std::ofstream fd; float a,b; mpsub_position=0; if (mp_conf.sub_fps==0) mp_conf.sub_fps=fps; - fd=fopen ("dump.mpsub", "w"); - if (!fd) { + fd.open ("dump.mpsub",std::ios_base::out); + if (!fd.is_open()) { perror ("dump_mpsub: fopen"); return; } - if (sub_uses_time) fprintf (fd,"FORMAT=TIME\n\n"); - else fprintf (fd, "FORMAT=%5.2f\n\n", fps); + if (sub_uses_time) fd<<"FORMAT=TIME"<<std::endl<<std::endl; + else fd<<"FORMAT="<<fps<<std::endl<<std::endl; for(j=0;j<sub_num;j++){ subtitle* egysub=&subs[j]; if (sub_uses_time) { a=((egysub->start-mpsub_position)/100.0); b=((egysub->end-egysub->start)/100.0); - if ( (float)((int)a) == a) - fprintf (fd, "%.0f",a); - else - fprintf (fd, "%.2f",a); + if ( (float)((int)a) == a) fd<<(int)a; + else fd<<a; - if ( (float)((int)b) == b) - fprintf (fd, " %.0f\n",b); - else - fprintf (fd, " %.2f\n",b); + if ( (float)((int)b) == b) fd<<(int)b; + else fd<<b; } else { - fprintf (fd, "%ld %ld\n", (long)((egysub->start*(fps/mp_conf.sub_fps))-((mpsub_position*(fps/mp_conf.sub_fps)))), - (long)(((egysub->end)-(egysub->start))*(fps/mp_conf.sub_fps))); + fd<<(long)((egysub->start*(fps/mp_conf.sub_fps))-((mpsub_position*(fps/mp_conf.sub_fps)))) + <<" "<<(long)(((egysub->end)-(egysub->start))*(fps/mp_conf.sub_fps)); } mpsub_position = egysub->end; for (i=0; i<egysub->lines; i++) { - fprintf (fd, "%s\n",egysub->text[i]); + fd<<" "<<egysub->text[i]<<std::endl; } - fprintf (fd, "\n"); + fd<<std::endl; } - fclose (fd); + fd.close (); MSG_DBG2 ("SUB: Subtitles dumped in \'dump.mpsub\'.\n"); } Modified: mplayerxp/libmpsub/subreader.h =================================================================== --- mplayerxp/libmpsub/subreader.h 2013-05-14 12:02:20 UTC (rev 638) +++ mplayerxp/libmpsub/subreader.h 2013-05-14 14:45:21 UTC (rev 639) @@ -1,6 +1,8 @@ #ifndef __MPLAYER_SUBREADER_H #define __MPLAYER_SUBREADER_H +#include <string> + namespace usr { class Video_Output; } @@ -36,15 +38,15 @@ char *text[SUB_MAX_TEXT]; }; -extern subtitle* sub_read_file (const char *filename, float pts); -extern char * sub_filename(const char *path,const char *fname); +extern subtitle* sub_read_file (const std::string& filename, float pts); +extern std::string sub_filename(const std::string& path,const std::string& fname); extern void list_sub_file(subtitle* subs); extern void dump_mpsub(subtitle* subs, float fps); extern void sub_free(subtitle* subs ); extern void find_sub(subtitle* subtitles,unsigned long key,Video_Output*vo_data); -extern void subcp_open (void); -extern void subcp_close (void); +extern void subcp_open (); +extern void subcp_close (); extern subtitle* subcp_recode (subtitle *sub); extern subtitle* subcp_recode1 (subtitle *sub); Modified: mplayerxp/libmpsub/vobsub.cpp =================================================================== --- mplayerxp/libmpsub/vobsub.cpp 2013-05-14 12:02:20 UTC (rev 638) +++ mplayerxp/libmpsub/vobsub.cpp 2013-05-14 14:45:21 UTC (rev 639) @@ -5,7 +5,9 @@ * Some code freely inspired from VobSub <URL:http://vobsub.edensrising.com>, * with kind permission from Gabest <ga...@fr...> */ -/* #define HAVE_GETLINE */ +#include <iostream> +#include <fstream> + #include <ctype.h> #include <errno.h> #include <limits.h> @@ -23,12 +25,9 @@ #include "spudec.h" #include "mpsub_msg.h" -#ifdef HAVE_GETLINE -extern ssize_t getline(char **, size_t *, FILE *); -#else /* FIXME This should go into a general purpose library or even a separate file. */ -static ssize_t __FASTCALL__ __getline (char **lineptr, size_t *n, FILE *stream) +static ssize_t __FASTCALL__ __getline (char **lineptr, size_t *n, std::ifstream& stream) { size_t res = 0; int c; @@ -47,7 +46,7 @@ if (*lineptr == NULL || *n == 0) return -1; - for (c = fgetc(stream); c != EOF; c = fgetc(stream)) { + for (c = stream.get(); stream.good(); c = stream.get()) { if (res + 1 >= *n) { char *tmp = (char*)mp_realloc(*lineptr, *n * 2); if (tmp == NULL) @@ -66,7 +65,6 @@ (*lineptr)[res] = 0; return res; } -#endif /********************************************************************** * MPEG parsing @@ -725,7 +723,7 @@ return 0; } -static int __FASTCALL__ vobsub_parse_one_line(vobsub_t *vob, FILE *fd) +static int __FASTCALL__ vobsub_parse_one_line(vobsub_t *vob, std::ifstream& fd) { ssize_t line_size; int res = -1; @@ -773,15 +771,17 @@ { vobsub_t *vob = (vobsub_t*)_vob; int res = -1; - FILE *fd = ::fopen(name.c_str(), "rb"); - if (fd == NULL) { + std::ifstream fd; + fd.open(name.c_str(),std::ios_base::in|std::ios_base::binary); + if (!fd.is_open()) { if (force) mpxp_warn<<"VobSub: Can't open IFO file"<<std::endl; } else { // parse IFO header unsigned char block[0x800]; const char *const ifo_magic = "DVDVIDEO-VTS"; - if (fread(block, sizeof(block), 1, fd) != 1) { + fd.read((char*)block, sizeof(block)); + if (!fd.good()) { if (force) mpxp_err<<"VobSub: Can't read IFO header"<<std::endl; } else if (memcmp(block, ifo_magic, strlen(ifo_magic) + 1)) @@ -814,9 +814,9 @@ char *tmp = (char *)block + 0x256 + sid * 6 + 2; langid.assign(tmp,2); } - if (fseek(fd, pgci_sector * sizeof(block), SEEK_SET) - || fread(block, sizeof(block), 1, fd) != 1) - mpxp_err<<"VobSub: Can't read IFO PGCI"<<std::endl; + fd.seekg(pgci_sector * sizeof(block), std::ios_base::beg); + fd.read((char*)block, sizeof(block)); + if (!fd.good()) mpxp_err<<"VobSub: Can't read IFO PGCI"<<std::endl; else { unsigned long idx; unsigned long pgc_offset = block[0xc] << 24 | block[0xd] << 16 @@ -830,7 +830,7 @@ res = 0; } } - fclose(fd); + fd.close(); } return res; } @@ -851,7 +851,7 @@ vob->delay = 0; vob->forced_subs=0; std::string buf; - FILE *fd; + std::ifstream fd; mpeg_t *mpg; /* read in the info file */ std::string stmp=""; @@ -862,8 +862,8 @@ vobsub_parse_ifo(vob,ifo, vob->palette, &vob->orig_frame_width, &vob->orig_frame_height, force, -1, stmp); /* read in the index */ buf=name+".idx"; - fd = ::fopen(buf.c_str(), "rb"); - if (fd == NULL) { + fd.open(buf.c_str(),std::ios_base::in|std::ios_base::binary); + if (!fd.is_open()) { if(force) mpxp_err<<"VobSub: Can't open IDX file"<<std::endl; else { @@ -872,7 +872,7 @@ } } else { while (vobsub_parse_one_line(vob, fd) >= 0) /* NOOP */ ; - ::fclose(fd); + fd.close(); } /* if no palette in .idx then use custom colors */ if ((vob->custom == 0)&&(vob->have_palette!=1)) Modified: mplayerxp/libvo2/font_load.cpp =================================================================== --- mplayerxp/libvo2/font_load.cpp 2013-05-14 12:02:20 UTC (rev 638) +++ mplayerxp/libvo2/font_load.cpp 2013-05-14 14:45:21 UTC (rev 639) @@ -2,6 +2,9 @@ #include "osdep/mplib.h" using namespace usr; +#include <iostream> +#include <fstream> + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -12,40 +15,40 @@ #include "sub.h" #include "vo_msg.h" -raw_file* load_raw(const char *name,int verbose){ +raw_file* load_raw(const std::string& name,int verbose){ int bpp; raw_file* raw=new raw_file; unsigned char head[32]; - FILE *f=fopen(name,"rb"); - if(!f) { delete raw; return NULL; } // can't open - if(fread(head,32,1,f)<1) { delete raw; fclose(f); return NULL; } // too small - if(memcmp(head,"mhwanh",6)) { delete raw; fclose(f); return NULL; } // not raw file + std::ifstream f; + f.open(name.c_str(),std::ios_base::in|std::ios_base::binary); + if(!f.is_open()) { delete raw; return NULL; } // can't open + f.read((char*)(head),32); if(!f.good()) { delete raw; f.close(); return NULL; } // too small + if(memcmp(head,"mhwanh",6)) { delete raw; f.close(); return NULL; } // not raw file raw->w=head[8]*256+head[9]; raw->h=head[10]*256+head[11]; raw->c=head[12]*256+head[13]; if(raw->w == 0) /* 2 bytes were not enough for the width... read 4 bytes from the end of the header */ raw->w = ((head[28]*0x100 + head[29])*0x100 + head[30])*0x100 + head[31]; - if(raw->c>256) { delete raw; fclose(f); return NULL; } // too many colors!? + if(raw->c>256) { delete raw; f.close(); return NULL; } // too many colors!? mpxp_v<<"RAW: "<<name<<" "<<raw->w<<" x "<<raw->h<<", "<<raw->c<<" colors"<<std::endl; if(raw->c){ raw->pal=new unsigned char [raw->c*3]; - fread(raw->pal,3,raw->c,f); + f.read((char*)(raw->pal),3*raw->c); bpp=1; } else { raw->pal=NULL; bpp=3; } raw->bmp=new unsigned char [raw->h*raw->w*bpp]; - fread(raw->bmp,raw->h*raw->w*bpp,1,f); - fclose(f); + f.read((char*)(raw->bmp),raw->h*raw->w*bpp); + f.close(); return raw; } -font_desc_t* read_font_desc(const char* fname,float factor,int verbose){ +font_desc_t* read_font_desc(const std::string& fname,float factor,int verbose){ char sor[1024]; unsigned char sor2[1024]; font_desc_t *desc; - FILE *f; char *dn; char section[64]; int i,j; @@ -55,16 +58,17 @@ desc=new(zeromem) font_desc_t; if(!desc) return NULL; - f=fopen(fname,"rt"); - if(!f) { + std::ifstream f; + f.open(fname.c_str(),std::ios_base::in); + if(!f.is_open()) { mpxp_err<<"font: can't open file: "<<fname<<std::endl; delete desc; return NULL; } - i = strlen (fname) - 9; + i = fname.length() - 9; if ((dn = new char [i+1])){ - strncpy (dn, fname, i); + strncpy (dn, fname.c_str(), i); dn[i]='\0'; } @@ -77,7 +81,7 @@ section[0]=0; - while(fgets(sor,1020,f)){ + while(f.getline(sor,1020)){ char* p[8]; int pdb=0; unsigned char *s=(unsigned char *)sor; @@ -223,7 +227,7 @@ } mpxp_err<<"Syntax error in font desc: "<<sor<<std::endl; } - fclose(f); + f.close(); for(i=0;i<=fontdb;i++){ if(!desc->pic_a[i] || !desc->pic_b[i]){ mpxp_err<<"font: Missing bitmap(s) for sub-font #"<<i<<std::endl; @@ -231,19 +235,18 @@ return NULL; } // re-sample alpha - int f=factor*256.0f; + int ff=factor*256.0f; int size=desc->pic_a[i]->w*desc->pic_a[i]->h; - int j; - mpxp_v<<"font: resampling alpha by factor "<<factor<<" ("<<f<<")"<<std::endl; + mpxp_v<<"font: resampling alpha by factor "<<factor<<" ("<<ff<<")"<<std::endl; for(j=0;j<size;j++){ int x=desc->pic_a[i]->bmp[j]; // alpha int y=desc->pic_b[i]->bmp[j]; // bitmap #ifdef FAST_OSD - x=(x<(255-f))?0:1; + x=(x<(255-ff))?0:1; #else - x=255-((x*f)>>8); // scale + x=255-((x*ff)>>8); // scale if(x+y>255) x=255-y; // to avoid overflows Modified: mplayerxp/libvo2/font_load.h =================================================================== --- mplayerxp/libvo2/font_load.h 2013-05-14 12:02:20 UTC (rev 638) +++ mplayerxp/libvo2/font_load.h 2013-05-14 14:45:21 UTC (rev 639) @@ -1,5 +1,6 @@ #ifndef __FONT_LOAD_H #define __FONT_LOAD_H 1 +#include <string> struct raw_file { unsigned char *bmp; @@ -22,7 +23,7 @@ short width[65536]; }; -raw_file* load_raw(const char *name,int verbose); -font_desc_t* read_font_desc(const char* fname,float factor,int verbose); +raw_file* load_raw(const std::string& name,int verbose); +font_desc_t* read_font_desc(const std::string& fname,float factor,int verbose); #endif Modified: mplayerxp/libvo2/screenshot.cpp =================================================================== --- mplayerxp/libvo2/screenshot.cpp 2013-05-14 12:02:20 UTC (rev 638) +++ mplayerxp/libvo2/screenshot.cpp 2013-05-14 14:45:21 UTC (rev 639) @@ -9,6 +9,8 @@ * Uses libpng (which uses zlib), so see according licenses. * */ +#include <iostream> +#include <fstream> #include <stdio.h> #include <stdlib.h> @@ -123,62 +125,61 @@ /* Note: this is LE version */ static void write_bmp(const char *fname,unsigned w,unsigned h,uint8_t *data) { - FILE* out; + std::ofstream f; char c[4]; uint32_t udata; unsigned i; unsigned long fsize_off,data_off,fsize_val,data_val; - if(!(out=fopen(fname,"wb"))) return; + f.open(fname,std::ios_base::out|std::ios_base::binary); + if(!f.is_open()) return; c[0]='B'; c[1]='M'; - fwrite(c,2,1,out); - fsize_off = ftello(out); - fseeko(out,4,SEEK_CUR); + f.write(c,2); + fsize_off = f.tellp(); + f.seekp(4,std::ios_base::cur); memset(c,0,4); - fwrite(c,4,1,out); - data_off=ftello(out); - fseeko(out,4,SEEK_CUR); + f.write(c,4); + data_off=f.tellp(); + f.seekp(4,std::ios_base::cur); udata=40; - fwrite(&udata,4,1,out); /* sizeof BITMAPINFOHEADER == biSize */ + f.write((char*)&udata,4); /* sizeof BITMAPINFOHEADER == biSize */ udata=w; - fwrite(&udata,4,1,out); /* sizeof biWidth */ + f.write((char*)&udata,4); /* sizeof biWidth */ udata=h; - fwrite(&udata,4,1,out); /* sizeof biHeight */ + f.write((char*)&udata,4); /* sizeof biHeight */ udata=1; - fwrite(&udata,2,1,out); /* sizeof biPlanes */ + f.write((char*)&udata,2); /* sizeof biPlanes */ udata=24; - fwrite(&udata,2,1,out); /* sizeof biBitCount */ + f.write((char*)&udata,2); /* sizeof biBitCount */ udata=0; - fwrite(&udata,4,1,out); /* sizeof biCompression */ + f.write((char*)&udata,4); /* sizeof biCompression */ udata=w*h*3; - fwrite(&udata,4,1,out); /* sizeof biSizeImage */ + f.write((char*)&udata,4); /* sizeof biSizeImage */ udata=0; - fwrite(&udata,4,1,out); /* sizeof biXPelsPerMeter */ + f.write((char*)&udata,4); /* sizeof biXPelsPerMeter */ udata=0; - fwrite(&udata,4,1,out); /* sizeof biYPelsPerMeter */ + f.write((char*)&udata,4); /* sizeof biYPelsPerMeter */ udata=0; - fwrite(&udata,4,1,out); /* sizeof biClrUsed */ + f.write((char*)&udata,4); /* sizeof biClrUsed */ udata=0; - fwrite(&udata,4,1,out); /* sizeof biClrImportant */ - data_val=ftello(out); - for(i=0;i<h;i++) /* flip picture here */ - { - fwrite(data+(w*3)*(h-i-1),w*3,1,out); + f.write((char*)&udata,4); /* sizeof biClrImportant */ + data_val=f.tellp(); + for(i=0;i<h;i++) {/* flip picture here */ + f.write((char*)(data+(w*3)*(h-i-1)),w*3); } - fsize_val=ftello(out); - fseeko(out,fsize_off,SEEK_SET); - fwrite(&fsize_val,4,1,out); - fseeko(out,data_off,SEEK_SET); - fwrite(&data_val,2,1,out); - fseeko(out,fsize_val,SEEK_SET); - fclose(out); + fsize_val=f.tellp(); + f.seekp(fsize_off,std::ios_base::beg); + f.write((char*)&fsize_val,4); + f.seekp(data_off,std::ios_base::beg); + f.write((char*)&data_val,2); + f.seekp(fsize_val,std::ios_base::beg); + f.close(); } #endif MPXP_Rc gr_screenshot(const char *fname,const uint8_t *planes[],const unsigned *strides,uint32_t fourcc,unsigned w,unsigned h) { - unsigned k; char buf[256]; #ifdef HAVE_PNG struct pngdata png; @@ -186,7 +187,6 @@ uint8_t *image_data=NULL; uint8_t *dst[3]; int dstStride[3]; - unsigned bpp = 24; struct SwsContext * sws = NULL; Modified: mplayerxp/postproc/af_hrtf.cpp =================================================================== --- mplayerxp/postproc/af_hrtf.cpp 2013-05-14 12:02:20 UTC (rev 638) +++ mplayerxp/postproc/af_hrtf.cpp 2013-05-14 14:45:21 UTC (rev 639) @@ -136,17 +136,6 @@ float l_agc, r_agc, lpr_agc, lmr_agc; float f, d_gain, c_gain, c_agc_cfk; -#if 0 - static int counter = 0; - static FILE *fp_out; - - if(counter == 0) - fp_out = fopen("af_hrtf.log", "w"); - if(counter % 240 == 0) - fprintf(fp_out, "%g %g %g %g %g ", counter * (1.0 / 48000), - l_gain, r_gain, lpr_gain, lmr_gain); -#endif - /*** AXIS NO. 1: (Lt, Rt) -> (C, Ls, Rs) ***/ /* AGC adaption */ d_gain = (fabs(l_gain - *adapt_l_gain) + Modified: mplayerxp/postproc/af_raw.cpp =================================================================== --- mplayerxp/postproc/af_raw.cpp 2013-05-14 12:02:20 UTC (rev 638) +++ mplayerxp/postproc/af_raw.cpp 2013-05-14 14:45:21 UTC (rev 639) @@ -5,6 +5,8 @@ This audio filter exports the incoming signal to raw or RIFF WAVE file TODO: add length + pts to export into sockets */ +#include <iostream> +#include <fstream> #include <stdio.h> #include <stdlib.h> @@ -50,7 +52,7 @@ char* filename; // File to export data int wav_mode; struct WaveHeader wavhdr; - FILE *fd; + std::ofstream fd; }; /* Initialization and runtime control_af @@ -64,13 +66,14 @@ char *pt; // Accepts any streams memcpy(&af->conf,arg,sizeof(af_conf_t)); - if(!s->fd) { /* reenterability */ - if(!(s->fd=fopen(s->filename,"wb"))) + if(s->fd.is_open()) { /* reenterability */ + s->fd.open(s->filename,std::ios_base::out|std::ios_base::binary); + if(!(s->fd.is_open())) MSG_ERR("Can't open %s\n",s->filename); pt=strchr(s->filename,'.'); s->wav_mode=0; if(pt) if(strcmp(pt+1,"wav")==0) s->wav_mode=1; - if(s->wav_mode && s->fd) + if(s->wav_mode && s->fd.is_open()) { uint16_t fmt=af->conf.format>>16; if(!fmt) fmt=0x01; /* pcm */ @@ -87,7 +90,7 @@ s->wavhdr.bits = le2me_16((af->conf.format&MPAF_BPS_MASK)*8); s->wavhdr.data=le2me_32(WAV_ID_DATA); s->wavhdr.data_length=le2me_32(0x7ffff000); - fwrite(&s->wavhdr,sizeof(struct WaveHeader),1,s->fd); + s->fd.write((char*)(&s->wavhdr),sizeof(struct WaveHeader)); s->wavhdr.file_length=s->wavhdr.data_length=0; } } @@ -119,21 +122,20 @@ { af_raw_t* s = reinterpret_cast<af_raw_t*>(af->setup); if(s) { - if(s->fd) { - off_t pos = ftello(s->fd); + if(s->fd.is_open()) { + off_t pos = s->fd.tellp(); if(s->wav_mode){ /* Write wave header */ - fseeko(s->fd, 0, SEEK_SET); + s->fd.seekp(0, std::ios_base::beg); s->wavhdr.file_length = pos-8; s->wavhdr.file_length = le2me_32(s->wavhdr.file_length); s->wavhdr.data_length = le2me_32(s->wavhdr.data_length); - fwrite(&s->wavhdr,sizeof(struct WaveHeader),1,s->fd); - fseeko(s->fd, pos, SEEK_SET); + s->fd.write((c... [truncated message content] |