mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-30 17:26:31 +00:00
1b75d91002
Add arg to SATARep to specify drive types to show. Add checks in AHCIPortInit to verify port signatures, add helper method to get signatures from port.
1113 lines
51 KiB
HTML
Executable file
1113 lines
51 KiB
HTML
Executable file
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
|
|
<meta name="generator" content="ZealOS V0.13">
|
|
<style type="text/css">
|
|
body {background-color:#fef1f0;}
|
|
.cF0{color:#000000;background-color:#fef1f0;}
|
|
.cF1{color:#0148a4;background-color:#fef1f0;}
|
|
.cF2{color:#3b7901;background-color:#fef1f0;}
|
|
.cF3{color:#057c7e;background-color:#fef1f0;}
|
|
.cF4{color:#bb2020;background-color:#fef1f0;}
|
|
.cF5{color:#9e42ae;background-color:#fef1f0;}
|
|
.cF6{color:#b57901;background-color:#fef1f0;}
|
|
.cF7{color:#b2b6af;background-color:#fef1f0;}
|
|
.cF8{color:#555753;background-color:#fef1f0;}
|
|
.cF9{color:#678fbb;background-color:#fef1f0;}
|
|
.cFA{color:#82bc49;background-color:#fef1f0;}
|
|
.cFB{color:#0097a2;background-color:#fef1f0;}
|
|
.cFC{color:#e26a6a;background-color:#fef1f0;}
|
|
.cFD{color:#c671bc;background-color:#fef1f0;}
|
|
.cFE{color:#c7ab00;background-color:#fef1f0;}
|
|
.cFF{color:#fef1f0;background-color:#fef1f0;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<pre style="font-family:monospace;font-size:12pt">
|
|
<a name="l1"></a><span class=cF0>#include <stdio.h>
|
|
<a name="l2"></a>#include <stdlib.h>
|
|
<a name="l3"></a>#include <memory.h>
|
|
<a name="l4"></a>#include <math.h>
|
|
<a name="l5"></a>
|
|
<a name="l6"></a>#pragma pack(1)
|
|
<a name="l7"></a>
|
|
<a name="l8"></a>#define TRUE 1
|
|
<a name="l9"></a>#define FALSE 0
|
|
<a name="l10"></a>#define BYTE_MAX 0xFF
|
|
<a name="l11"></a>#define CHAR_MIN (-0x80)
|
|
<a name="l12"></a>#define CHAR_MAX 0x7F
|
|
<a name="l13"></a>#define SHORT_MIN (-0x8000)
|
|
<a name="l14"></a>#define SHORT_MAX 0x7FFF
|
|
<a name="l15"></a>#define INT_MIN (-0x80000000)
|
|
<a name="l16"></a>#define INT_MAX 0x7FFFFFFF
|
|
<a name="l17"></a>#define LONG_LONG_MIN (-0x8000000000000000l)
|
|
<a name="l18"></a>#define LONG_LONG_MAX 0x7FFFFFFFFFFFFFFFl
|
|
<a name="l19"></a>#define DWORD_MIN 0
|
|
<a name="l20"></a>#define DWORD_MAX 0xFFFFFFFF
|
|
<a name="l21"></a>#define CDATE_FREQ 49710 // Hz
|
|
<a name="l22"></a>
|
|
<a name="l23"></a>typedef unsigned char BYTE;
|
|
<a name="l24"></a>typedef unsigned short WORD;
|
|
<a name="l25"></a>typedef unsigned int DWORD;
|
|
<a name="l26"></a>typedef unsigned char BOOL;
|
|
<a name="l27"></a>
|
|
<a name="l28"></a>class CDate
|
|
<a name="l29"></a>{public:
|
|
<a name="l30"></a> DWORD time;
|
|
<a name="l31"></a> int date;
|
|
<a name="l32"></a>};
|
|
<a name="l33"></a>
|
|
<a name="l34"></a>WORD EndianWORD(WORD d)
|
|
<a name="l35"></a>{
|
|
<a name="l36"></a> return ((d&255)<<8)|((d>>8)&255);
|
|
<a name="l37"></a>}
|
|
<a name="l38"></a>
|
|
<a name="l39"></a>DWORD EndianDWORD(DWORD d)
|
|
<a name="l40"></a>{
|
|
<a name="l41"></a> return ((d&255)<<24)|(((d>>8)&255)<<16)|
|
|
<a name="l42"></a> (((d>>16)&255)<<8)|((d>>24)&255);
|
|
<a name="l43"></a>}
|
|
<a name="l44"></a>
|
|
<a name="l45"></a>DWORD StrOcc(char *src, char ch)
|
|
<a name="l46"></a>{//Count occurrences of a char.
|
|
<a name="l47"></a> DWORD i=0;
|
|
<a name="l48"></a> if (!src) return 0;
|
|
<a name="l49"></a> while (*src)
|
|
<a name="l50"></a> if (*src++==ch)
|
|
<a name="l51"></a> i++;
|
|
<a name="l52"></a> return i;
|
|
<a name="l53"></a>}
|
|
<a name="l54"></a>
|
|
<a name="l55"></a>void *CAlloc(DWORD size)
|
|
<a name="l56"></a>{
|
|
<a name="l57"></a> BYTE *res=(BYTE *)malloc(size);
|
|
<a name="l58"></a> memset(res,0,size);
|
|
<a name="l59"></a> return res;
|
|
<a name="l60"></a>}
|
|
<a name="l61"></a>
|
|
<a name="l62"></a>void Free(void *ptr)
|
|
<a name="l63"></a>{
|
|
<a name="l64"></a> if (ptr) free(ptr);
|
|
<a name="l65"></a>}
|
|
<a name="l66"></a>
|
|
<a name="l67"></a>int FSize(FILE *f)
|
|
<a name="l68"></a>{
|
|
<a name="l69"></a> int res,original=ftell(f);
|
|
<a name="l70"></a> fseek(f,0,SEEK_END);
|
|
<a name="l71"></a> res=ftell(f);
|
|
<a name="l72"></a> fseek(f,original,SEEK_SET);
|
|
<a name="l73"></a> return res;
|
|
<a name="l74"></a>}
|
|
<a name="l75"></a>
|
|
<a name="l76"></a>class CQue
|
|
<a name="l77"></a>{public:
|
|
<a name="l78"></a> CQue *next,*last;
|
|
<a name="l79"></a>};
|
|
<a name="l80"></a>
|
|
<a name="l81"></a>void QueIns(void *entry,void *pred)
|
|
<a name="l82"></a>{
|
|
<a name="l83"></a> CQue * succ;
|
|
<a name="l84"></a> succ=((CQue *)pred)->next;
|
|
<a name="l85"></a> ((CQue *)entry)->last=(CQue *)pred;
|
|
<a name="l86"></a> ((CQue *)entry)->next=succ;
|
|
<a name="l87"></a> succ ->last=(CQue *)entry;
|
|
<a name="l88"></a> ((CQue *)pred)->next=(CQue *)entry;
|
|
<a name="l89"></a>}
|
|
<a name="l90"></a>
|
|
<a name="l91"></a>void QueRem(void *entry)
|
|
<a name="l92"></a>{
|
|
<a name="l93"></a> ((CQue *)entry)->last->next=((CQue *)entry)->next;
|
|
<a name="l94"></a> ((CQue *)entry)->next->last=((CQue *)entry)->last;
|
|
<a name="l95"></a>}
|
|
<a name="l96"></a>
|
|
<a name="l97"></a>void QueDel(void *head,BOOL querem=FALSE)
|
|
<a name="l98"></a>{//Free entries in queue, not head.
|
|
<a name="l99"></a> CQue *tmpq=((CQue *)head)->next,*tmpq1;
|
|
<a name="l100"></a> while (tmpq!=head) {
|
|
<a name="l101"></a> tmpq1=((CQue *)tmpq)->next;
|
|
<a name="l102"></a> if (querem)
|
|
<a name="l103"></a> QueRem(tmpq);
|
|
<a name="l104"></a> Free(tmpq);
|
|
<a name="l105"></a> tmpq=tmpq1;
|
|
<a name="l106"></a> }
|
|
<a name="l107"></a>}
|
|
<a name="l108"></a>
|
|
<a name="l109"></a>void QueInit(void *head)
|
|
<a name="l110"></a>{//Free entries in queue, not head.
|
|
<a name="l111"></a> ((CQue *)head)->next=(CQue *)head;
|
|
<a name="l112"></a> ((CQue *)head)->last=(CQue *)head;
|
|
<a name="l113"></a>}
|
|
<a name="l114"></a>
|
|
<a name="l115"></a>int QueCnt(CQue *head)
|
|
<a name="l116"></a>{//Count of nodes in queue, not head.
|
|
<a name="l117"></a> CQue *tmpq=((CQue *)head)->next;
|
|
<a name="l118"></a> int res=0;
|
|
<a name="l119"></a> while (tmpq!=head) {
|
|
<a name="l120"></a> res++;
|
|
<a name="l121"></a> tmpq=((CQue *)tmpq)->next;
|
|
<a name="l122"></a> }
|
|
<a name="l123"></a> return res;
|
|
<a name="l124"></a>}
|
|
<a name="l125"></a>
|
|
<a name="l126"></a>#define ARC_MAX_BITS 12
|
|
<a name="l127"></a>
|
|
<a name="l128"></a>#define CT_NONE 1
|
|
<a name="l129"></a>#define CT_7_BIT 2
|
|
<a name="l130"></a>#define CT_8_BIT 3
|
|
<a name="l131"></a>
|
|
<a name="l132"></a>class CArcEntry
|
|
<a name="l133"></a>{ public:
|
|
<a name="l134"></a> CArcEntry *next;
|
|
<a name="l135"></a> WORD basecode;
|
|
<a name="l136"></a> BYTE ch,pad;
|
|
<a name="l137"></a>};
|
|
<a name="l138"></a>
|
|
<a name="l139"></a>class CArcCtrl //control structure
|
|
<a name="l140"></a>{ public:
|
|
<a name="l141"></a> DWORD src_pos,src_size,
|
|
<a name="l142"></a> dst_pos,dst_size;
|
|
<a name="l143"></a> BYTE *src_buf,*dst_buf;
|
|
<a name="l144"></a> DWORD min_bits,min_table_entry;
|
|
<a name="l145"></a> CArcEntry *cur_entry,*next_entry;
|
|
<a name="l146"></a> DWORD cur_bits_in_use,next_bits_in_use;
|
|
<a name="l147"></a> BYTE *stk_ptr,*stk_base;
|
|
<a name="l148"></a> DWORD free_idx,free_limit,
|
|
<a name="l149"></a> saved_basecode,
|
|
<a name="l150"></a> entry_used,
|
|
<a name="l151"></a> last_ch;
|
|
<a name="l152"></a> CArcEntry compress[1<<ARC_MAX_BITS],
|
|
<a name="l153"></a> *hash[1<<ARC_MAX_BITS];
|
|
<a name="l154"></a>};
|
|
<a name="l155"></a>
|
|
<a name="l156"></a>class CArcCompress
|
|
<a name="l157"></a>{ public:
|
|
<a name="l158"></a> DWORD compressed_size,compressed_size_hi,
|
|
<a name="l159"></a> expanded_size,expanded_size_hi;
|
|
<a name="l160"></a> BYTE compression_type;
|
|
<a name="l161"></a> BYTE body[1];
|
|
<a name="l162"></a>};
|
|
<a name="l163"></a>
|
|
<a name="l164"></a>int Bt(int bit_num, BYTE *bit_field)
|
|
<a name="l165"></a>{
|
|
<a name="l166"></a> bit_field+=bit_num>>3;
|
|
<a name="l167"></a> bit_num&=7;
|
|
<a name="l168"></a> return (*bit_field & (1<<bit_num)) ? 1:0;
|
|
<a name="l169"></a>}
|
|
<a name="l170"></a>
|
|
<a name="l171"></a>int Bts(int bit_num, BYTE *bit_field)
|
|
<a name="l172"></a>{
|
|
<a name="l173"></a> int res;
|
|
<a name="l174"></a> bit_field+=bit_num>>3;
|
|
<a name="l175"></a> bit_num&=7;
|
|
<a name="l176"></a> res=*bit_field & (1<<bit_num);
|
|
<a name="l177"></a> *bit_field|=(1<<bit_num);
|
|
<a name="l178"></a> return (res) ? 1:0;
|
|
<a name="l179"></a>}
|
|
<a name="l180"></a>
|
|
<a name="l181"></a>DWORD BFieldExtDWORD(BYTE *src,DWORD pos,DWORD bits)
|
|
<a name="l182"></a>{
|
|
<a name="l183"></a> DWORD i,res=0;
|
|
<a name="l184"></a> for (i=0;i<bits;i++)
|
|
<a name="l185"></a> if (Bt(pos+i,src))
|
|
<a name="l186"></a> Bts(i,(BYTE *)&res);
|
|
<a name="l187"></a> return res;
|
|
<a name="l188"></a>}
|
|
<a name="l189"></a>
|
|
<a name="l190"></a>void ArcEntryGet(CArcCtrl *c)
|
|
<a name="l191"></a>{
|
|
<a name="l192"></a> DWORD i;
|
|
<a name="l193"></a> CArcEntry *tmp,*tmp1;
|
|
<a name="l194"></a>
|
|
<a name="l195"></a> if (c->entry_used) {
|
|
<a name="l196"></a> i=c->free_idx;
|
|
<a name="l197"></a>
|
|
<a name="l198"></a> c->entry_used=FALSE;
|
|
<a name="l199"></a> c->cur_entry=c->next_entry;
|
|
<a name="l200"></a> c->cur_bits_in_use=c->next_bits_in_use;
|
|
<a name="l201"></a> if (c->next_bits_in_use<ARC_MAX_BITS) {
|
|
<a name="l202"></a> c->next_entry = &c->compress[i++];
|
|
<a name="l203"></a> if (i==c->free_limit) {
|
|
<a name="l204"></a> c->next_bits_in_use++;
|
|
<a name="l205"></a> c->free_limit=1<<c->next_bits_in_use;
|
|
<a name="l206"></a> }
|
|
<a name="l207"></a> } else {
|
|
<a name="l208"></a> do if (++i==c->free_limit) i=c->min_table_entry;
|
|
<a name="l209"></a> while (c->hash[i]);
|
|
<a name="l210"></a> tmp=&c->compress[i];
|
|
<a name="l211"></a> c->next_entry=tmp;
|
|
<a name="l212"></a> tmp1=(CArcEntry *)&c->hash[tmp->basecode];
|
|
<a name="l213"></a> while (tmp1 && tmp1->next!=tmp)
|
|
<a name="l214"></a> tmp1=tmp1->next;
|
|
<a name="l215"></a> if (tmp1)
|
|
<a name="l216"></a> tmp1->next=tmp->next;
|
|
<a name="l217"></a> }
|
|
<a name="l218"></a> c->free_idx=i;
|
|
<a name="l219"></a> }
|
|
<a name="l220"></a>}
|
|
<a name="l221"></a>
|
|
<a name="l222"></a>void ArcExpandBuf(CArcCtrl *c)
|
|
<a name="l223"></a>{
|
|
<a name="l224"></a> BYTE *dst_ptr,*dst_limit;
|
|
<a name="l225"></a> DWORD basecode,lastcode,code;
|
|
<a name="l226"></a> CArcEntry *tmp,*tmp1;
|
|
<a name="l227"></a>
|
|
<a name="l228"></a> dst_ptr=c->dst_buf+c->dst_pos;
|
|
<a name="l229"></a> dst_limit=c->dst_buf+c->dst_size;
|
|
<a name="l230"></a>
|
|
<a name="l231"></a> while (dst_ptr<dst_limit && c->stk_ptr!=c->stk_base)
|
|
<a name="l232"></a> *dst_ptr++ = * -- c->stk_ptr;
|
|
<a name="l233"></a>
|
|
<a name="l234"></a> if (c->stk_ptr==c->stk_base && dst_ptr<dst_limit) {
|
|
<a name="l235"></a> if (c->saved_basecode==0xFFFFFFFFl) {
|
|
<a name="l236"></a> lastcode=BFieldExtDWORD(c->src_buf,c->src_pos,
|
|
<a name="l237"></a> c->next_bits_in_use);
|
|
<a name="l238"></a> c->src_pos=c->src_pos+c->next_bits_in_use;
|
|
<a name="l239"></a> *dst_ptr++=lastcode;
|
|
<a name="l240"></a> ArcEntryGet(c);
|
|
<a name="l241"></a> c->last_ch=lastcode;
|
|
<a name="l242"></a> } else
|
|
<a name="l243"></a> lastcode=c->saved_basecode;
|
|
<a name="l244"></a> while (dst_ptr<dst_limit && c->src_pos+c->next_bits_in_use<=c->src_size) {
|
|
<a name="l245"></a> basecode=BFieldExtDWORD(c->src_buf,c->src_pos,
|
|
<a name="l246"></a> c->next_bits_in_use);
|
|
<a name="l247"></a> c->src_pos=c->src_pos+c->next_bits_in_use;
|
|
<a name="l248"></a> if (c->cur_entry==&c->compress[basecode]) {
|
|
<a name="l249"></a> *c->stk_ptr++=c->last_ch;
|
|
<a name="l250"></a> code=lastcode;
|
|
<a name="l251"></a> } else
|
|
<a name="l252"></a> code=basecode;
|
|
<a name="l253"></a> while (code>=c->min_table_entry) {
|
|
<a name="l254"></a> *c->stk_ptr++=c->compress[code].ch;
|
|
<a name="l255"></a> code=c->compress[code].basecode;
|
|
<a name="l256"></a> }
|
|
<a name="l257"></a> *c->stk_ptr++=code;
|
|
<a name="l258"></a> c->last_ch=code;
|
|
<a name="l259"></a>
|
|
<a name="l260"></a> c->entry_used=TRUE;
|
|
<a name="l261"></a> tmp=c->cur_entry;
|
|
<a name="l262"></a> tmp->basecode=lastcode;
|
|
<a name="l263"></a> tmp->ch=c->last_ch;
|
|
<a name="l264"></a> tmp1=(CArcEntry *)&c->hash[lastcode];
|
|
<a name="l265"></a> tmp->next=tmp1->next;
|
|
<a name="l266"></a> tmp1->next=tmp;
|
|
<a name="l267"></a>
|
|
<a name="l268"></a> ArcEntryGet(c);
|
|
<a name="l269"></a> while (dst_ptr<dst_limit && c->stk_ptr!=c->stk_base)
|
|
<a name="l270"></a> *dst_ptr++ = * -- c->stk_ptr;
|
|
<a name="l271"></a> lastcode=basecode;
|
|
<a name="l272"></a> }
|
|
<a name="l273"></a> c->saved_basecode=lastcode;
|
|
<a name="l274"></a> }
|
|
<a name="l275"></a> c->dst_pos=dst_ptr-c->dst_buf;
|
|
<a name="l276"></a>}
|
|
<a name="l277"></a>
|
|
<a name="l278"></a>CArcCtrl *ArcCtrlNew(DWORD expand,DWORD compression_type)
|
|
<a name="l279"></a>{
|
|
<a name="l280"></a> CArcCtrl *c;
|
|
<a name="l281"></a> c=(CArcCtrl *)CAlloc(sizeof(CArcCtrl));
|
|
<a name="l282"></a> if (expand) {
|
|
<a name="l283"></a> c->stk_base=(BYTE *)malloc(1<<ARC_MAX_BITS);
|
|
<a name="l284"></a> c->stk_ptr=c->stk_base;
|
|
<a name="l285"></a> }
|
|
<a name="l286"></a> if (compression_type==CT_7_BIT)
|
|
<a name="l287"></a> c->min_bits=7;
|
|
<a name="l288"></a> else
|
|
<a name="l289"></a> c->min_bits=8;
|
|
<a name="l290"></a> c->min_table_entry=1<<c->min_bits;
|
|
<a name="l291"></a> c->free_idx=c->min_table_entry;
|
|
<a name="l292"></a> c->next_bits_in_use=c->min_bits+1;
|
|
<a name="l293"></a> c->free_limit=1<<c->next_bits_in_use;
|
|
<a name="l294"></a> c->saved_basecode=0xFFFFFFFFl;
|
|
<a name="l295"></a> c->entry_used=TRUE;
|
|
<a name="l296"></a> ArcEntryGet(c);
|
|
<a name="l297"></a> c->entry_used=TRUE;
|
|
<a name="l298"></a> return c;
|
|
<a name="l299"></a>}
|
|
<a name="l300"></a>
|
|
<a name="l301"></a>void ArcCtrlDel(CArcCtrl *c)
|
|
<a name="l302"></a>{
|
|
<a name="l303"></a> Free(c->stk_base);
|
|
<a name="l304"></a> Free(c);
|
|
<a name="l305"></a>}
|
|
<a name="l306"></a>
|
|
<a name="l307"></a>BYTE *ExpandBuf(CArcCompress *arc)
|
|
<a name="l308"></a>{
|
|
<a name="l309"></a> CArcCtrl *c;
|
|
<a name="l310"></a> BYTE *res;
|
|
<a name="l311"></a>
|
|
<a name="l312"></a> if (!(CT_NONE<=arc->compression_type && arc->compression_type<=CT_8_BIT) ||
|
|
<a name="l313"></a> arc->expanded_size>=0x20000000l)
|
|
<a name="l314"></a> return NULL;
|
|
<a name="l315"></a>
|
|
<a name="l316"></a> res=(BYTE *)malloc(arc->expanded_size+1);
|
|
<a name="l317"></a> res[arc->expanded_size]=0; //terminate
|
|
<a name="l318"></a> switch (arc->compression_type) {
|
|
<a name="l319"></a> case CT_NONE:
|
|
<a name="l320"></a> memcpy(res,arc->body,arc->expanded_size);
|
|
<a name="l321"></a> break;
|
|
<a name="l322"></a> case CT_7_BIT:
|
|
<a name="l323"></a> case CT_8_BIT:
|
|
<a name="l324"></a> c=ArcCtrlNew(TRUE,arc->compression_type);
|
|
<a name="l325"></a> c->src_size=arc->compressed_size*8;
|
|
<a name="l326"></a> c->src_pos=(sizeof(CArcCompress)-1)*8;
|
|
<a name="l327"></a> c->src_buf=(BYTE *)arc;
|
|
<a name="l328"></a> c->dst_size=arc->expanded_size;
|
|
<a name="l329"></a> c->dst_buf=res;
|
|
<a name="l330"></a> c->dst_pos=0;
|
|
<a name="l331"></a> ArcExpandBuf(c);
|
|
<a name="l332"></a> ArcCtrlDel(c);
|
|
<a name="l333"></a> break;
|
|
<a name="l334"></a> }
|
|
<a name="l335"></a> return res;
|
|
<a name="l336"></a>}
|
|
<a name="l337"></a>
|
|
<a name="l338"></a>BOOL Cvt(char *in_name,char *out_name,BOOL cvt_ascii)
|
|
<a name="l339"></a>{
|
|
<a name="l340"></a> DWORD out_size,i,j,in_size;
|
|
<a name="l341"></a> CArcCompress *arc;
|
|
<a name="l342"></a> BYTE *out_buf;
|
|
<a name="l343"></a> FILE *io_file;
|
|
<a name="l344"></a> BOOL okay=FALSE;
|
|
<a name="l345"></a> if (io_file=fopen(in_name,"rb")) {
|
|
<a name="l346"></a> in_size=FSize(io_file);
|
|
<a name="l347"></a> arc=(CArcCompress *)malloc(in_size);
|
|
<a name="l348"></a> fread(arc,1,in_size,io_file);
|
|
<a name="l349"></a> out_size=arc->expanded_size;
|
|
<a name="l350"></a> printf("%-45s %d-->%d\r\n",in_name,(DWORD) in_size,out_size);
|
|
<a name="l351"></a> fclose(io_file);
|
|
<a name="l352"></a> if (arc->compressed_size==in_size &&
|
|
<a name="l353"></a> arc->compression_type && arc->compression_type<=3) {
|
|
<a name="l354"></a> if (out_buf=ExpandBuf(arc)) {
|
|
<a name="l355"></a> if (cvt_ascii) {
|
|
<a name="l356"></a> j=0;
|
|
<a name="l357"></a> for (i=0;i<out_size;i++)
|
|
<a name="l358"></a> if (out_buf[i]==31)
|
|
<a name="l359"></a> out_buf[j++]=32;
|
|
<a name="l360"></a> else if (out_buf[i]!=5)
|
|
<a name="l361"></a> out_buf[j++]=out_buf[i];
|
|
<a name="l362"></a> out_size=j;
|
|
<a name="l363"></a> }
|
|
<a name="l364"></a> if (io_file=fopen(out_name,"wb")) {
|
|
<a name="l365"></a> fwrite(out_buf,1,out_size,io_file);
|
|
<a name="l366"></a> fclose(io_file);
|
|
<a name="l367"></a> okay=TRUE;
|
|
<a name="l368"></a> }
|
|
<a name="l369"></a> Free(out_buf);
|
|
<a name="l370"></a> }
|
|
<a name="l371"></a> }
|
|
<a name="l372"></a> Free(arc);
|
|
<a name="l373"></a> }
|
|
<a name="l374"></a> return okay;
|
|
<a name="l375"></a>}
|
|
<a name="l376"></a>
|
|
<a name="l377"></a>long long ona2freq[256]=
|
|
<a name="l378"></a>{0x0000000000000000,0x3F825AA2E3AF0B1E,0x3F83720820155763,0x3F849A0A791E127D,
|
|
<a name="l379"></a>0x3F85D3A6D600CAB9,0x3F871FE927CA0DE9,0x3F887FED4E47AE02,0x3F89F4E00A91D08B,
|
|
<a name="l380"></a>0x3F8B800000000000,0x3F8D229EC465C8A4,0x3F8EDE22007F7915,0x3F905A0250C2B956,
|
|
<a name="l381"></a>0x3F9152EC0E758E71,0x3F925AA2E3AF0B1E,0x3F93720820155763,0x3F949A0A791E127D,
|
|
<a name="l382"></a>0x3F95D3A6D600CAB9,0x3F971FE927CA0DE9,0x3F987FED4E47AE02,0x3F99F4E00A91D08B,
|
|
<a name="l383"></a>0x3F9B800000000000,0x3F9D229EC465C8A4,0x3F9EDE22007F7915,0x3FA05A0250C2B956,
|
|
<a name="l384"></a>0x3FA152EC0E758E71,0x3FA25AA2E3AF0B1E,0x3FA3720820155763,0x3FA49A0A791E127D,
|
|
<a name="l385"></a>0x3FA5D3A6D600CAB9,0x3FA71FE927CA0DE9,0x3FA87FED4E47AE02,0x3FA9F4E00A91D08B,
|
|
<a name="l386"></a>0x3FAB800000000000,0x3FAD229EC465C89F,0x3FAEDE22007F791A,0x3FB05A0250C2B956,
|
|
<a name="l387"></a>0x3FB152EC0E758E6E,0x3FB25AA2E3AF0B22,0x3FB3720820155763,0x3FB49A0A791E127A,
|
|
<a name="l388"></a>0x3FB5D3A6D600CABC,0x3FB71FE927CA0DE9,0x3FB87FED4E47ADFE,0x3FB9F4E00A91D08F,
|
|
<a name="l389"></a>0x3FBB800000000000,0x3FBD229EC465C89F,0x3FBEDE22007F791A,0x3FC05A0250C2B956,
|
|
<a name="l390"></a>0x3FC152EC0E758E6E,0x3FC25AA2E3AF0B22,0x3FC3720820155763,0x3FC49A0A791E127A,
|
|
<a name="l391"></a>0x3FC5D3A6D600CABC,0x3FC71FE927CA0DE9,0x3FC87FED4E47ADFE,0x3FC9F4E00A91D08F,
|
|
<a name="l392"></a>0x3FCB800000000000,0x3FCD229EC465C89F,0x3FCEDE22007F791A,0x3FD05A0250C2B956,
|
|
<a name="l393"></a>0x3FD152EC0E758E6E,0x3FD25AA2E3AF0B22,0x3FD3720820155763,0x3FD49A0A791E127A,
|
|
<a name="l394"></a>0x3FD5D3A6D600CABC,0x3FD71FE927CA0DE9,0x3FD87FED4E47ADFE,0x3FD9F4E00A91D08F,
|
|
<a name="l395"></a>0x3FDB800000000000,0x3FDD229EC465C89F,0x3FDEDE22007F791A,0x3FE05A0250C2B956,
|
|
<a name="l396"></a>0x3FE152EC0E758E6E,0x3FE25AA2E3AF0B22,0x3FE3720820155763,0x3FE49A0A791E127A,
|
|
<a name="l397"></a>0x3FE5D3A6D600CABC,0x3FE71FE927CA0DE9,0x3FE87FED4E47ADFE,0x3FE9F4E00A91D08F,
|
|
<a name="l398"></a>0x3FEB800000000000,0x3FED229EC465C8A2,0x3FEEDE22007F7918,0x3FF05A0250C2B956,
|
|
<a name="l399"></a>0x3FF152EC0E758E6F,0x3FF25AA2E3AF0B20,0x3FF3720820155763,0x3FF49A0A791E127B,
|
|
<a name="l400"></a>0x3FF5D3A6D600CABB,0x3FF71FE927CA0DE9,0x3FF87FED4E47AE00,0x3FF9F4E00A91D08D,
|
|
<a name="l401"></a>0x3FFB800000000000,0x3FFD229EC465C8A2,0x3FFEDE22007F7918,0x40005A0250C2B956,
|
|
<a name="l402"></a>0x400152EC0E758E6F,0x40025AA2E3AF0B20,0x4003720820155763,0x40049A0A791E127B,
|
|
<a name="l403"></a>0x4005D3A6D600CABB,0x40071FE927CA0DE9,0x40087FED4E47AE00,0x4009F4E00A91D08D,
|
|
<a name="l404"></a>0x400B800000000000,0x400D229EC465C8A0,0x400EDE22007F791A,0x40105A0250C2B956,
|
|
<a name="l405"></a>0x401152EC0E758E6F,0x40125AA2E3AF0B21,0x4013720820155763,0x40149A0A791E127A,
|
|
<a name="l406"></a>0x4015D3A6D600CABC,0x40171FE927CA0DE9,0x40187FED4E47ADFE,0x4019F4E00A91D08E,
|
|
<a name="l407"></a>0x401B800000000000,0x401D229EC465C8A0,0x401EDE22007F7918,0x40205A0250C2B956,
|
|
<a name="l408"></a>0x402152EC0E758E6F,0x40225AA2E3AF0B20,0x4023720820155763,0x40249A0A791E127A,
|
|
<a name="l409"></a>0x4025D3A6D600CABC,0x40271FE927CA0DE9,0x40287FED4E47ADFF,0x4029F4E00A91D08E,
|
|
<a name="l410"></a>0x402B800000000000,0x402D229EC465C8A0,0x402EDE22007F7918,0x40305A0250C2B956,
|
|
<a name="l411"></a>0x403152EC0E758E6F,0x40325AA2E3AF0B21,0x4033720820155763,0x40349A0A791E127B,
|
|
<a name="l412"></a>0x4035D3A6D600CABC,0x40371FE927CA0DE9,0x40387FED4E47ADFF,0x4039F4E00A91D08E,
|
|
<a name="l413"></a>0x403B800000000000,0x403D229EC465C8A0,0x403EDE22007F791A,0x40405A0250C2B956,
|
|
<a name="l414"></a>0x404152EC0E758E6F,0x40425AA2E3AF0B21,0x4043720820155763,0x40449A0A791E127A,
|
|
<a name="l415"></a>0x4045D3A6D600CABC,0x40471FE927CA0DE9,0x40487FED4E47ADFE,0x4049F4E00A91D08E,
|
|
<a name="l416"></a>0x404B800000000000,0x404D229EC465C8A2,0x404EDE22007F7918,0x40505A0250C2B956,
|
|
<a name="l417"></a>0x405152EC0E758E6F,0x40525AA2E3AF0B20,0x4053720820155763,0x40549A0A791E127B,
|
|
<a name="l418"></a>0x4055D3A6D600CABB,0x40571FE927CA0DE9,0x40587FED4E47AE00,0x4059F4E00A91D08D,
|
|
<a name="l419"></a>0x405B800000000000,0x405D229EC465C8A2,0x405EDE22007F7918,0x40605A0250C2B956,
|
|
<a name="l420"></a>0x406152EC0E758E6F,0x40625AA2E3AF0B20,0x4063720820155763,0x40649A0A791E127B,
|
|
<a name="l421"></a>0x4065D3A6D600CABB,0x40671FE927CA0DE9,0x40687FED4E47AE00,0x4069F4E00A91D08D,
|
|
<a name="l422"></a>0x406B800000000000,0x406D229EC465C89F,0x406EDE22007F791A,0x40705A0250C2B956,
|
|
<a name="l423"></a>0x407152EC0E758E6E,0x40725AA2E3AF0B22,0x4073720820155763,0x40749A0A791E127A,
|
|
<a name="l424"></a>0x4075D3A6D600CABC,0x40771FE927CA0DE9,0x40787FED4E47ADFE,0x4079F4E00A91D08F,
|
|
<a name="l425"></a>0x407B800000000000,0x407D229EC465C89F,0x407EDE22007F791A,0x40805A0250C2B956,
|
|
<a name="l426"></a>0x408152EC0E758E6E,0x40825AA2E3AF0B22,0x4083720820155763,0x40849A0A791E127A,
|
|
<a name="l427"></a>0x4085D3A6D600CABC,0x40871FE927CA0DE9,0x40887FED4E47ADFE,0x4089F4E00A91D08F,
|
|
<a name="l428"></a>0x408B800000000000,0x408D229EC465C89F,0x408EDE22007F791A,0x40905A0250C2B956,
|
|
<a name="l429"></a>0x409152EC0E758E6E,0x40925AA2E3AF0B22,0x4093720820155763,0x40949A0A791E127A,
|
|
<a name="l430"></a>0x4095D3A6D600CABC,0x40971FE927CA0DE9,0x40987FED4E47ADFE,0x4099F4E00A91D08F,
|
|
<a name="l431"></a>0x409B800000000000,0x409D229EC465C89F,0x409EDE22007F791A,0x40A05A0250C2B956,
|
|
<a name="l432"></a>0x40A152EC0E758E6E,0x40A25AA2E3AF0B22,0x40A3720820155763,0x40A49A0A791E127A,
|
|
<a name="l433"></a>0x40A5D3A6D600CABC,0x40A71FE927CA0DE9,0x40A87FED4E47ADFE,0x40A9F4E00A91D08F,
|
|
<a name="l434"></a>0x40AB800000000000,0x40AD229EC465C8A4,0x40AEDE22007F7915,0x40B05A0250C2B956,
|
|
<a name="l435"></a>0x40B152EC0E758E71,0x40B25AA2E3AF0B1E,0x40B3720820155763,0x40B49A0A791E127D,
|
|
<a name="l436"></a>0x40B5D3A6D600CAB9,0x40B71FE927CA0DE9,0x40B87FED4E47AE02,0x40B9F4E00A91D08B,
|
|
<a name="l437"></a>0x40BB800000000000,0x40BD229EC465C8A4,0x40BEDE22007F7915,0x40C05A0250C2B956,
|
|
<a name="l438"></a>0x40C152EC0E758E71,0x40C25AA2E3AF0B1E,0x40C3720820155763,0x40C49A0A791E127D,
|
|
<a name="l439"></a>0x40C5D3A6D600CAB9,0x40C71FE927CA0DE9,0x40C87FED4E47AE02,0x40C9F4E00A91D08B,
|
|
<a name="l440"></a>0x40CB800000000000,0x40CD229EC465C8A4,0x40CEDE22007F7915,0x40D05A0250C2B956,
|
|
<a name="l441"></a>0x40D152EC0E758E71,0x40D25AA2E3AF0B1E,0x40D3720820155763,0x40D49A0A791E127D};
|
|
<a name="l442"></a>
|
|
<a name="l443"></a>#define ONA_REST CHAR_MIN
|
|
<a name="l444"></a>
|
|
<a name="l445"></a>double Ona2Freq(char ona)
|
|
<a name="l446"></a>{//Ona to freq. Ona=60 is 440.0Hz.
|
|
<a name="l447"></a> double *d;
|
|
<a name="l448"></a> if (ona==ONA_REST)
|
|
<a name="l449"></a> return 0;
|
|
<a name="l450"></a> else {
|
|
<a name="l451"></a>// return 440.0/32*pow(2.0,ona/12.0);
|
|
<a name="l452"></a>
|
|
<a name="l453"></a>//This avoids needing to link math library to this file.
|
|
<a name="l454"></a> d=(double *)&ona2freq[ona+128];
|
|
<a name="l455"></a> return *d;
|
|
<a name="l456"></a> }
|
|
<a name="l457"></a>}
|
|
<a name="l458"></a>
|
|
<a name="l459"></a>class CAUData
|
|
<a name="l460"></a>{public:
|
|
<a name="l461"></a> long long cdt;
|
|
<a name="l462"></a> char ona;
|
|
<a name="l463"></a>};
|
|
<a name="l464"></a>
|
|
<a name="l465"></a>class CSndData
|
|
<a name="l466"></a>{public:
|
|
<a name="l467"></a> CSndData *next,*last;
|
|
<a name="l468"></a> double tS;
|
|
<a name="l469"></a> char ona;
|
|
<a name="l470"></a>};
|
|
<a name="l471"></a>
|
|
<a name="l472"></a>class CSndWaveCtrl
|
|
<a name="l473"></a>{public:
|
|
<a name="l474"></a> int sample_rate;
|
|
<a name="l475"></a> double phase,last_y,next_y;
|
|
<a name="l476"></a>};
|
|
<a name="l477"></a>
|
|
<a name="l478"></a>CSndWaveCtrl *SndWaveCtrlNew(int sample_rate=8000)
|
|
<a name="l479"></a>{
|
|
<a name="l480"></a> CSndWaveCtrl *swc=(CSndWaveCtrl *)CAlloc(sizeof(CSndWaveCtrl));
|
|
<a name="l481"></a> swc->sample_rate=sample_rate;
|
|
<a name="l482"></a> return swc;
|
|
<a name="l483"></a>}
|
|
<a name="l484"></a>
|
|
<a name="l485"></a>void SndWaveAddBuf(CSndWaveCtrl *swc,BYTE *buf,int num_samples,
|
|
<a name="l486"></a> double _freq,double _amp=1.0)
|
|
<a name="l487"></a>{
|
|
<a name="l488"></a> int i,j,k;
|
|
<a name="l489"></a> double a,f,amp,phase;
|
|
<a name="l490"></a> if (!swc) return;
|
|
<a name="l491"></a> if (!_freq||!_amp)
|
|
<a name="l492"></a> swc->last_y=swc->phase=0;
|
|
<a name="l493"></a> else {
|
|
<a name="l494"></a> phase=swc->phase;
|
|
<a name="l495"></a> i=0;
|
|
<a name="l496"></a> if (INT_MAX<INT_MAX*_amp)
|
|
<a name="l497"></a> amp=INT_MAX;
|
|
<a name="l498"></a> else
|
|
<a name="l499"></a> amp=INT_MAX*_amp;
|
|
<a name="l500"></a> f=2.0/swc->sample_rate*_freq;
|
|
<a name="l501"></a> while (phase<0)
|
|
<a name="l502"></a> phase+=2;
|
|
<a name="l503"></a> while (phase>=2)
|
|
<a name="l504"></a> phase-=2;
|
|
<a name="l505"></a> while (i<num_samples) {
|
|
<a name="l506"></a> if (phase>=1.0)
|
|
<a name="l507"></a> j=-amp;
|
|
<a name="l508"></a> else
|
|
<a name="l509"></a> j=amp;
|
|
<a name="l510"></a> k=j>>16;
|
|
<a name="l511"></a> *((short *)buf+i++)+=k;
|
|
<a name="l512"></a> phase+=f;
|
|
<a name="l513"></a> while (phase>=2)
|
|
<a name="l514"></a> phase-=2;
|
|
<a name="l515"></a> }
|
|
<a name="l516"></a> swc->phase=phase;
|
|
<a name="l517"></a> }
|
|
<a name="l518"></a>}
|
|
<a name="l519"></a>
|
|
<a name="l520"></a>#define SNDFILE_SAMPLE_RATE 8000
|
|
<a name="l521"></a>//Header for a ".SND" file
|
|
<a name="l522"></a>class CFileSND
|
|
<a name="l523"></a>{public:
|
|
<a name="l524"></a> DWORD signature; //0x646e732e
|
|
<a name="l525"></a> DWORD offset; //24
|
|
<a name="l526"></a> DWORD data_size;
|
|
<a name="l527"></a> DWORD coding; //3=16bit uncompressed
|
|
<a name="l528"></a> DWORD sample_rate; //Hz
|
|
<a name="l529"></a> DWORD channels; //1=mono
|
|
<a name="l530"></a> short body[1];
|
|
<a name="l531"></a>};
|
|
<a name="l532"></a>
|
|
<a name="l533"></a>#define SND_FILE_MAX 0x007FF000
|
|
<a name="l534"></a>
|
|
<a name="l535"></a>int SndFileCreate(CSndData *head,char *print_fmt,double vol=1.0)
|
|
<a name="l536"></a>{
|
|
<a name="l537"></a> int i,i1,k,cnt,cnt2,file_num;
|
|
<a name="l538"></a> double dt;
|
|
<a name="l539"></a> CFileSND *s;
|
|
<a name="l540"></a> CSndWaveCtrl *swc=SndWaveCtrlNew(SNDFILE_SAMPLE_RATE);
|
|
<a name="l541"></a> CSndData *tmpsd;
|
|
<a name="l542"></a> char st[512];
|
|
<a name="l543"></a> FILE *out_file;
|
|
<a name="l544"></a>
|
|
<a name="l545"></a> dt=head->last->tS-head->tS;
|
|
<a name="l546"></a> if (!dt) return 0;
|
|
<a name="l547"></a> cnt=dt*SNDFILE_SAMPLE_RATE;
|
|
<a name="l548"></a> cnt++; //Terminator
|
|
<a name="l549"></a>
|
|
<a name="l550"></a> s=(CFileSND *)CAlloc(sizeof(CFileSND)-sizeof(short)+cnt*sizeof(short));
|
|
<a name="l551"></a> s->signature=0x646e732e;
|
|
<a name="l552"></a> s->offset=EndianDWORD(sizeof(CFileSND)-sizeof(short));
|
|
<a name="l553"></a> s->coding=EndianDWORD(3);
|
|
<a name="l554"></a> s->sample_rate=EndianDWORD(SNDFILE_SAMPLE_RATE);
|
|
<a name="l555"></a> s->channels=EndianDWORD(1);
|
|
<a name="l556"></a>
|
|
<a name="l557"></a> k=0;
|
|
<a name="l558"></a> i=head->tS*SNDFILE_SAMPLE_RATE;
|
|
<a name="l559"></a> tmpsd=head->next;
|
|
<a name="l560"></a> while (tmpsd!=head) {
|
|
<a name="l561"></a> i1=tmpsd->tS*SNDFILE_SAMPLE_RATE;
|
|
<a name="l562"></a> if (i1-i>0) {
|
|
<a name="l563"></a> if (k+i1-i>cnt) {
|
|
<a name="l564"></a> i1=cnt-k+i;
|
|
<a name="l565"></a> if (i1-i<=0)
|
|
<a name="l566"></a> break;
|
|
<a name="l567"></a> }
|
|
<a name="l568"></a> SndWaveAddBuf(swc,(BYTE *)&s->body[k],i1-i,
|
|
<a name="l569"></a> Ona2Freq(tmpsd->last->ona),vol);
|
|
<a name="l570"></a> k+=i1-i;
|
|
<a name="l571"></a> i=i1;
|
|
<a name="l572"></a> }
|
|
<a name="l573"></a> tmpsd=tmpsd->next;
|
|
<a name="l574"></a> }
|
|
<a name="l575"></a>
|
|
<a name="l576"></a> for (i=0;i<cnt-1;i++)
|
|
<a name="l577"></a> s->body[i]=EndianWORD(s->body[i]);
|
|
<a name="l578"></a> s->body[cnt-1]=0;
|
|
<a name="l579"></a>
|
|
<a name="l580"></a> cnt2=cnt;
|
|
<a name="l581"></a> file_num=0;
|
|
<a name="l582"></a> while (cnt2>0) {
|
|
<a name="l583"></a> i=cnt2;
|
|
<a name="l584"></a> if (i>SND_FILE_MAX)
|
|
<a name="l585"></a> i=SND_FILE_MAX;
|
|
<a name="l586"></a> s->data_size=EndianDWORD(i*sizeof(short));
|
|
<a name="l587"></a> memcpy(s->body,&s->body[file_num*SND_FILE_MAX],i*sizeof(short));
|
|
<a name="l588"></a> sprintf(st,print_fmt,file_num++);
|
|
<a name="l589"></a> if (out_file=fopen(st,"wb")) {
|
|
<a name="l590"></a> fwrite(s,1,sizeof(CFileSND)-sizeof(short)+i*sizeof(short),out_file);
|
|
<a name="l591"></a> fclose(out_file);
|
|
<a name="l592"></a> }
|
|
<a name="l593"></a> cnt2-=i;
|
|
<a name="l594"></a> }
|
|
<a name="l595"></a> Free(s);
|
|
<a name="l596"></a> Free(swc);
|
|
<a name="l597"></a> return file_num;
|
|
<a name="l598"></a>}
|
|
<a name="l599"></a>
|
|
<a name="l600"></a>void AURead(CSndData *head,char *au_name)
|
|
<a name="l601"></a>{
|
|
<a name="l602"></a> CSndData *tmpsd;
|
|
<a name="l603"></a> FILE *in_file;
|
|
<a name="l604"></a> CAUData aud;
|
|
<a name="l605"></a> long long t0_cdt;
|
|
<a name="l606"></a> BOOL first=TRUE;
|
|
<a name="l607"></a>
|
|
<a name="l608"></a> memset(head,0,sizeof(CSndData));
|
|
<a name="l609"></a> QueInit(head);
|
|
<a name="l610"></a> if (in_file=fopen(au_name,"rb")) {
|
|
<a name="l611"></a> while (fread(&aud,1,sizeof(CAUData),in_file)) {
|
|
<a name="l612"></a> if (first) {
|
|
<a name="l613"></a> tmpsd=head;
|
|
<a name="l614"></a> t0_cdt=aud.cdt;
|
|
<a name="l615"></a> first=FALSE;
|
|
<a name="l616"></a> } else {
|
|
<a name="l617"></a> tmpsd=(CSndData *)malloc(sizeof(CSndData));
|
|
<a name="l618"></a> QueIns(tmpsd,head->last);
|
|
<a name="l619"></a> }
|
|
<a name="l620"></a> tmpsd->ona=aud.ona;
|
|
<a name="l621"></a> tmpsd->tS=1.0*(aud.cdt-t0_cdt)/CDATE_FREQ;
|
|
<a name="l622"></a> }
|
|
<a name="l623"></a> fclose(in_file);
|
|
<a name="l624"></a> }
|
|
<a name="l625"></a>}
|
|
<a name="l626"></a>
|
|
<a name="l627"></a>#define GR_WIDTH 640
|
|
<a name="l628"></a>#define GR_HEIGHT 480
|
|
<a name="l629"></a>#define COLORS_NUM 16
|
|
<a name="l630"></a>
|
|
<a name="l631"></a>class CBGR24
|
|
<a name="l632"></a>{public:
|
|
<a name="l633"></a> BYTE b,g,r,pad;
|
|
<a name="l634"></a>};
|
|
<a name="l635"></a>
|
|
<a name="l636"></a>class CBGR48
|
|
<a name="l637"></a>{public:
|
|
<a name="l638"></a> WORD b,g,r,pad;
|
|
<a name="l639"></a>} gr_palette_std[COLORS_NUM]={
|
|
<a name="l640"></a>{0x0000,0x0000,0x0000,0},{0xAAAA,0x0000,0x0000,0},
|
|
<a name="l641"></a>{0x0000,0xAAAA,0x0000,0},{0xAAAA,0xAAAA,0x0000,0},
|
|
<a name="l642"></a>{0x0000,0x0000,0xAAAA,0},{0xAAAA,0x0000,0xAAAA,0},
|
|
<a name="l643"></a>{0x0000,0x5555,0xAAAA,0},{0xAAAA,0xAAAA,0xAAAA,0},
|
|
<a name="l644"></a>{0x5555,0x5555,0x5555,0},{0xFFFF,0x5555,0x5555,0},
|
|
<a name="l645"></a>{0x5555,0xFFFF,0x5555,0},{0xFFFF,0xFFFF,0x5555,0},
|
|
<a name="l646"></a>{0x5555,0x5555,0xFFFF,0},{0xFFFF,0x5555,0xFFFF,0},
|
|
<a name="l647"></a>{0x5555,0xFFFF,0xFFFF,0},{0xFFFF,0xFFFF,0xFFFF,0}};
|
|
<a name="l648"></a>
|
|
<a name="l649"></a>#define DCF_COMPRESSED 1
|
|
<a name="l650"></a>#define DCF_PALETTE 2
|
|
<a name="l651"></a>
|
|
<a name="l652"></a>class CDC
|
|
<a name="l653"></a>{public:
|
|
<a name="l654"></a> long long cdt;
|
|
<a name="l655"></a> int x0,y0,
|
|
<a name="l656"></a> width,width_internal,
|
|
<a name="l657"></a> height,
|
|
<a name="l658"></a> flags;
|
|
<a name="l659"></a> CBGR48 palette[COLORS_NUM];
|
|
<a name="l660"></a> BYTE *body;
|
|
<a name="l661"></a>};
|
|
<a name="l662"></a>
|
|
<a name="l663"></a>CDC *DCNew(DWORD width,DWORD height)
|
|
<a name="l664"></a>{
|
|
<a name="l665"></a> CDC *res=(CDC *)CAlloc(sizeof(CDC));
|
|
<a name="l666"></a> res->width=width;
|
|
<a name="l667"></a> res->width_internal=(width+7)&~7;
|
|
<a name="l668"></a> res->height=height;
|
|
<a name="l669"></a> res->body=(BYTE *)CAlloc(res->width_internal*res->height);
|
|
<a name="l670"></a> return res;
|
|
<a name="l671"></a>}
|
|
<a name="l672"></a>
|
|
<a name="l673"></a>void DCDel(CDC *dc)
|
|
<a name="l674"></a>{//Free dc, image body, rot mat and depth buf.
|
|
<a name="l675"></a> if (!dc) return;
|
|
<a name="l676"></a> Free(dc->body);
|
|
<a name="l677"></a> Free(dc);
|
|
<a name="l678"></a>}
|
|
<a name="l679"></a>
|
|
<a name="l680"></a>CDC *DCLoad(BYTE *src,DWORD *_size)
|
|
<a name="l681"></a>{//Loads device context from mem.
|
|
<a name="l682"></a> BYTE *ptr=src;
|
|
<a name="l683"></a> CArcCompress *arc;
|
|
<a name="l684"></a> DWORD body_size;
|
|
<a name="l685"></a> CDC *res=(CDC *)CAlloc(sizeof(CDC));
|
|
<a name="l686"></a> memcpy(res,ptr,sizeof(CDC)-sizeof(BYTE *)-COLORS_NUM*sizeof(CBGR48));
|
|
<a name="l687"></a> ptr+=sizeof(CDC)-sizeof(BYTE *)-COLORS_NUM*sizeof(CBGR48);
|
|
<a name="l688"></a> if (res->flags&DCF_PALETTE) {
|
|
<a name="l689"></a> memcpy(&res->palette,ptr,COLORS_NUM*sizeof(CBGR48));
|
|
<a name="l690"></a> ptr+=COLORS_NUM*sizeof(CBGR48);
|
|
<a name="l691"></a> } else
|
|
<a name="l692"></a> memcpy(&res->palette,gr_palette_std,sizeof(gr_palette_std));
|
|
<a name="l693"></a>
|
|
<a name="l694"></a> body_size=res->width_internal*res->height;
|
|
<a name="l695"></a> if (res->flags&DCF_COMPRESSED) {
|
|
<a name="l696"></a> res->flags&=~DCF_COMPRESSED;
|
|
<a name="l697"></a> arc=(CArcCompress *)ptr;
|
|
<a name="l698"></a> res->body=ExpandBuf(arc);
|
|
<a name="l699"></a> ptr+=arc->compressed_size;
|
|
<a name="l700"></a> } else {
|
|
<a name="l701"></a> res->body=(BYTE *)malloc(body_size);
|
|
<a name="l702"></a> memcpy(res->body,ptr,body_size);
|
|
<a name="l703"></a> ptr+=body_size;
|
|
<a name="l704"></a> }
|
|
<a name="l705"></a> *_size=ptr-src;
|
|
<a name="l706"></a> return res;
|
|
<a name="l707"></a>}
|
|
<a name="l708"></a>
|
|
<a name="l709"></a>BOOL GrBlot(CDC *dc,int x,int y,CDC *img)
|
|
<a name="l710"></a>{
|
|
<a name="l711"></a> int j,k,k1,w1,h1,w2,h2;
|
|
<a name="l712"></a> if (x<0)
|
|
<a name="l713"></a> w1=-x;
|
|
<a name="l714"></a> else
|
|
<a name="l715"></a> w1=0;
|
|
<a name="l716"></a> if (y<0)
|
|
<a name="l717"></a> h1=-y;
|
|
<a name="l718"></a> else
|
|
<a name="l719"></a> h1=0;
|
|
<a name="l720"></a> w2=img->width;
|
|
<a name="l721"></a> h2=img->height;
|
|
<a name="l722"></a> if (x+w2>dc->width)
|
|
<a name="l723"></a> w2=dc->width-x;
|
|
<a name="l724"></a> if (y+h2>dc->height)
|
|
<a name="l725"></a> h2=dc->height-y;
|
|
<a name="l726"></a> if (w1<w2 && w2<=img->width && h1<h2 && h2<=img->height) {
|
|
<a name="l727"></a> k = h1 *img ->width_internal+w1;
|
|
<a name="l728"></a> k1=(h1+y)*dc->width_internal+x+w1;
|
|
<a name="l729"></a> for (j=h1;j<h2;j++) {
|
|
<a name="l730"></a> memcpy(dc->body+k1,img->body+k,w2-w1);
|
|
<a name="l731"></a> k +=img->width_internal;
|
|
<a name="l732"></a> k1+=dc->width_internal;
|
|
<a name="l733"></a> }
|
|
<a name="l734"></a> return TRUE;
|
|
<a name="l735"></a> } else
|
|
<a name="l736"></a> return FALSE;
|
|
<a name="l737"></a>}
|
|
<a name="l738"></a>
|
|
<a name="l739"></a>#define BMP_COLORS_NUM 16
|
|
<a name="l740"></a>class CFileBMP
|
|
<a name="l741"></a>{public:
|
|
<a name="l742"></a> WORD type;
|
|
<a name="l743"></a> DWORD file_size;
|
|
<a name="l744"></a> DWORD reserved;
|
|
<a name="l745"></a> DWORD data_offset;
|
|
<a name="l746"></a>
|
|
<a name="l747"></a> DWORD header_size;
|
|
<a name="l748"></a> DWORD width;
|
|
<a name="l749"></a> DWORD height;
|
|
<a name="l750"></a> WORD planes;
|
|
<a name="l751"></a> WORD bit_cnt;
|
|
<a name="l752"></a> DWORD compression;
|
|
<a name="l753"></a> DWORD image_size;
|
|
<a name="l754"></a> DWORD x_pixs_per_meter;
|
|
<a name="l755"></a> DWORD y_pixs_per_meter;
|
|
<a name="l756"></a> DWORD colors_used;
|
|
<a name="l757"></a> DWORD important_colors;
|
|
<a name="l758"></a>
|
|
<a name="l759"></a> CBGR24 palette[BMP_COLORS_NUM];
|
|
<a name="l760"></a>};
|
|
<a name="l761"></a>
|
|
<a name="l762"></a>CFileBMP *BMPRLE4To(CDC *dc)
|
|
<a name="l763"></a>{//To Windows RLE4 bit BMP.
|
|
<a name="l764"></a> BYTE *src,*ptr,*start;
|
|
<a name="l765"></a> int i,x,y,w=dc->width,cnt,pattern;
|
|
<a name="l766"></a> CBGR48 palette[COLORS_NUM];
|
|
<a name="l767"></a> CFileBMP *bmp =(CFileBMP *)CAlloc(sizeof(CFileBMP)+
|
|
<a name="l768"></a> 2*(dc->width+1)*dc->height);
|
|
<a name="l769"></a> bmp->type ='B'+('M'<<8);
|
|
<a name="l770"></a> bmp->planes =1;
|
|
<a name="l771"></a> bmp->data_offset=sizeof(CFileBMP);
|
|
<a name="l772"></a> bmp->header_size=sizeof(CFileBMP)-BMP_COLORS_NUM*sizeof(CBGR24)-14;
|
|
<a name="l773"></a> bmp->width =dc->width;
|
|
<a name="l774"></a> bmp->height =dc->height;
|
|
<a name="l775"></a> bmp->bit_cnt =4;
|
|
<a name="l776"></a> bmp->compression=2; //RLE4
|
|
<a name="l777"></a> memcpy(&palette,&gr_palette_std,sizeof(gr_palette_std));
|
|
<a name="l778"></a> for (i=0;i<BMP_COLORS_NUM;i++) {
|
|
<a name="l779"></a> bmp->palette[i].b=palette[i].b>>8;
|
|
<a name="l780"></a> bmp->palette[i].g=palette[i].g>>8;
|
|
<a name="l781"></a> bmp->palette[i].r=palette[i].r>>8;
|
|
<a name="l782"></a> bmp->palette[i].pad=0;
|
|
<a name="l783"></a> }
|
|
<a name="l784"></a> start=ptr=(BYTE *)bmp+bmp->data_offset;
|
|
<a name="l785"></a> for (y=dc->height-1;y>=0;y--) {
|
|
<a name="l786"></a> src=y*dc->width_internal+dc->body;
|
|
<a name="l787"></a> x=0;
|
|
<a name="l788"></a> while (x<w) {
|
|
<a name="l789"></a> pattern=((src[0]&15)<<4)+(src[1]&15);
|
|
<a name="l790"></a> if ((x+1<w) && ((src[0]&15)==(src[1]&15))) {
|
|
<a name="l791"></a> src+=2;
|
|
<a name="l792"></a> cnt=2;
|
|
<a name="l793"></a> x+=2;
|
|
<a name="l794"></a> while ((x<w) && (cnt<BYTE_MAX)) {
|
|
<a name="l795"></a> if ((*src&15)==(pattern&15)) {
|
|
<a name="l796"></a> src++;
|
|
<a name="l797"></a> cnt++;
|
|
<a name="l798"></a> x++;
|
|
<a name="l799"></a> } else
|
|
<a name="l800"></a> break;
|
|
<a name="l801"></a> }
|
|
<a name="l802"></a> } else {
|
|
<a name="l803"></a> src+=2;
|
|
<a name="l804"></a> if (x+1<w)
|
|
<a name="l805"></a> cnt=2;
|
|
<a name="l806"></a> else
|
|
<a name="l807"></a> cnt=1;
|
|
<a name="l808"></a> x+=2;
|
|
<a name="l809"></a> }
|
|
<a name="l810"></a> *ptr++=cnt;
|
|
<a name="l811"></a> *ptr++=pattern;
|
|
<a name="l812"></a> }
|
|
<a name="l813"></a> *ptr++=0;
|
|
<a name="l814"></a> *ptr++=0;
|
|
<a name="l815"></a> }
|
|
<a name="l816"></a> bmp->image_size=ptr-start;
|
|
<a name="l817"></a> bmp->file_size=sizeof(CFileBMP)+bmp->image_size;
|
|
<a name="l818"></a> return bmp;
|
|
<a name="l819"></a>}
|
|
<a name="l820"></a>
|
|
<a name="l821"></a>void BMPWrite(char *filename,CDC *dc)
|
|
<a name="l822"></a>{//Window's BMP Files.
|
|
<a name="l823"></a> CFileBMP *bmp=BMPRLE4To(dc);
|
|
<a name="l824"></a> FILE *out_file;
|
|
<a name="l825"></a> if (out_file=fopen(filename,"wb")) {
|
|
<a name="l826"></a> fwrite(bmp,1,bmp->file_size,out_file);
|
|
<a name="l827"></a> fclose(out_file);
|
|
<a name="l828"></a> }
|
|
<a name="l829"></a> Free(bmp);
|
|
<a name="l830"></a>}
|
|
<a name="l831"></a>
|
|
<a name="l832"></a>int MV2BMPLst(char *mv_print_fmt,char *dir_print_fmt,char *bmp_print_fmt,
|
|
<a name="l833"></a> char *mp4_print_fmt,char *out_name,double fps=30000.0/1001)
|
|
<a name="l834"></a>{//Cvt GR list MV file to BMP lst
|
|
<a name="l835"></a> DWORD bmp_num,size;
|
|
<a name="l836"></a> BOOL cont=TRUE;
|
|
<a name="l837"></a> int num=0,remaining,mv_percent_cnt,bmp_percent_cnt,dir_percent_cnt,
|
|
<a name="l838"></a> mp4_percent_cnt;
|
|
<a name="l839"></a> CDC *dc,*base;
|
|
<a name="l840"></a> BYTE *src,*src_base;
|
|
<a name="l841"></a> char st[512],st_dir[512],st_bmp[512],st_mp4[512];
|
|
<a name="l842"></a> long long cdt=LONG_LONG_MIN;
|
|
<a name="l843"></a> FILE *mv_file,*lst_file=fopen("TOSZTEMP_VID_LIST.TXT","wt");
|
|
<a name="l844"></a>
|
|
<a name="l845"></a> if (mv_print_fmt)
|
|
<a name="l846"></a> mv_percent_cnt=StrOcc(mv_print_fmt,'%');
|
|
<a name="l847"></a> else
|
|
<a name="l848"></a> mv_percent_cnt=0;
|
|
<a name="l849"></a> if (bmp_print_fmt)
|
|
<a name="l850"></a> bmp_percent_cnt=StrOcc(bmp_print_fmt,'%');
|
|
<a name="l851"></a> else
|
|
<a name="l852"></a> bmp_percent_cnt=0;
|
|
<a name="l853"></a> if (dir_print_fmt)
|
|
<a name="l854"></a> dir_percent_cnt=StrOcc(dir_print_fmt,'%');
|
|
<a name="l855"></a> else
|
|
<a name="l856"></a> dir_percent_cnt=0;
|
|
<a name="l857"></a> if (mp4_print_fmt)
|
|
<a name="l858"></a> mp4_percent_cnt=StrOcc(mp4_print_fmt,'%');
|
|
<a name="l859"></a> else
|
|
<a name="l860"></a> mp4_percent_cnt=0;
|
|
<a name="l861"></a> do {
|
|
<a name="l862"></a> if (mv_percent_cnt)
|
|
<a name="l863"></a> sprintf(st,mv_print_fmt,num);
|
|
<a name="l864"></a> else
|
|
<a name="l865"></a> strcpy(st,mv_print_fmt);
|
|
<a name="l866"></a> if (mv_file=fopen(st,"rb")) {
|
|
<a name="l867"></a> if (dir_percent_cnt)
|
|
<a name="l868"></a> sprintf(st_dir,dir_print_fmt,num);
|
|
<a name="l869"></a> else
|
|
<a name="l870"></a> strcpy(st_dir,dir_print_fmt);
|
|
<a name="l871"></a> sprintf(st,"mkdir %s",st_dir);
|
|
<a name="l872"></a> system(st);
|
|
<a name="l873"></a> bmp_num=0;
|
|
<a name="l874"></a>
|
|
<a name="l875"></a> remaining=FSize(mv_file);
|
|
<a name="l876"></a> src=src_base=(BYTE *)malloc(remaining+1);
|
|
<a name="l877"></a> fread(src_base,1,remaining,mv_file);
|
|
<a name="l878"></a> src_base[remaining]=0;
|
|
<a name="l879"></a> base=DCNew(GR_WIDTH,GR_HEIGHT);
|
|
<a name="l880"></a> while (cont && remaining>0) {
|
|
<a name="l881"></a> dc=DCLoad(src,&size);
|
|
<a name="l882"></a> if (!size) {
|
|
<a name="l883"></a> cont=FALSE;
|
|
<a name="l884"></a> break;
|
|
<a name="l885"></a> }
|
|
<a name="l886"></a> GrBlot(base,dc->x0,dc->y0,dc);
|
|
<a name="l887"></a> if (cdt==LONG_LONG_MIN)
|
|
<a name="l888"></a> cdt=dc->cdt;
|
|
<a name="l889"></a> while (cdt<=dc->cdt) {
|
|
<a name="l890"></a> if (bmp_percent_cnt)
|
|
<a name="l891"></a> sprintf(st_bmp,bmp_print_fmt,bmp_num);
|
|
<a name="l892"></a> else
|
|
<a name="l893"></a> strcpy(st_bmp,bmp_print_fmt);
|
|
<a name="l894"></a> sprintf(st,"%s/%s",st_dir,st_bmp);
|
|
<a name="l895"></a> BMPWrite(st,base);
|
|
<a name="l896"></a> cdt+=(DWORD)(CDATE_FREQ/fps);
|
|
<a name="l897"></a> if (!bmp_percent_cnt) {
|
|
<a name="l898"></a> cont=FALSE;
|
|
<a name="l899"></a> break;
|
|
<a name="l900"></a> }
|
|
<a name="l901"></a> bmp_num++;
|
|
<a name="l902"></a> }
|
|
<a name="l903"></a> DCDel(dc);
|
|
<a name="l904"></a> src+=size;
|
|
<a name="l905"></a> remaining-=size;
|
|
<a name="l906"></a> }
|
|
<a name="l907"></a> DCDel(base);
|
|
<a name="l908"></a> Free(src_base);
|
|
<a name="l909"></a> fclose(mv_file);
|
|
<a name="l910"></a> } else
|
|
<a name="l911"></a> break;
|
|
<a name="l912"></a> if (mp4_print_fmt) {
|
|
<a name="l913"></a> if (mp4_percent_cnt)
|
|
<a name="l914"></a> sprintf(st_mp4,mp4_print_fmt,num);
|
|
<a name="l915"></a> else
|
|
<a name="l916"></a> strcpy(st_mp4,mp4_print_fmt);
|
|
<a name="l917"></a> sprintf(st,"ffmpeg -framerate %0.16f -i %s/%s "
|
|
<a name="l918"></a> "-c:v libx264 -vf \"scale=2*trunc(iw/2):-2,setsar=1\" "
|
|
<a name="l919"></a> "-profile:v main -pix_fmt yuv420p %s",
|
|
<a name="l920"></a> fps,st_dir,bmp_print_fmt,st_mp4);
|
|
<a name="l921"></a> system(st);
|
|
<a name="l922"></a> fprintf(lst_file,"file '%s'\r\n",st_mp4);
|
|
<a name="l923"></a> }
|
|
<a name="l924"></a> num++;
|
|
<a name="l925"></a> if (!mv_percent_cnt)
|
|
<a name="l926"></a> break;
|
|
<a name="l927"></a> } while (cont);
|
|
<a name="l928"></a>
|
|
<a name="l929"></a> if (lst_file) {
|
|
<a name="l930"></a> fclose(lst_file);
|
|
<a name="l931"></a> if (num && out_name) {
|
|
<a name="l932"></a> sprintf(st,"ffmpeg -f concat -i TOSZTEMP_VID_LIST.TXT -c copy %s",
|
|
<a name="l933"></a> out_name);
|
|
<a name="l934"></a> system(st);
|
|
<a name="l935"></a> }
|
|
<a name="l936"></a> }
|
|
<a name="l937"></a> system("rm -R TOSZTEMP*");
|
|
<a name="l938"></a> return num;
|
|
<a name="l939"></a>}
|
|
<a name="l940"></a>
|
|
<a name="l941"></a>int SND2MP4Lst(char *snd_print_fmt,char *mp4_print_fmt,char *out_name,
|
|
<a name="l942"></a> int rate=24000)
|
|
<a name="l943"></a>{//Cvt SND lst to MP4
|
|
<a name="l944"></a> int num=0,snd_percent_cnt,mp4_percent_cnt,mkdir_percent_cnt;
|
|
<a name="l945"></a> char st[512],st_snd[512],st_mp4[512];
|
|
<a name="l946"></a> FILE *snd_file,*lst_file=fopen("TOSZTEMP_AUD_LIST.TXT","wt");
|
|
<a name="l947"></a>
|
|
<a name="l948"></a> if (snd_print_fmt)
|
|
<a name="l949"></a> snd_percent_cnt=StrOcc(snd_print_fmt,'%');
|
|
<a name="l950"></a> else
|
|
<a name="l951"></a> snd_percent_cnt=0;
|
|
<a name="l952"></a> if (mp4_print_fmt)
|
|
<a name="l953"></a> mp4_percent_cnt=StrOcc(mp4_print_fmt,'%');
|
|
<a name="l954"></a> else
|
|
<a name="l955"></a> mp4_percent_cnt=0;
|
|
<a name="l956"></a>
|
|
<a name="l957"></a> while (TRUE) {
|
|
<a name="l958"></a> if (snd_percent_cnt)
|
|
<a name="l959"></a> sprintf(st_snd,snd_print_fmt,num);
|
|
<a name="l960"></a> else
|
|
<a name="l961"></a> strcpy(st_snd,snd_print_fmt);
|
|
<a name="l962"></a> if (snd_file=fopen(st_snd,"rb")) {
|
|
<a name="l963"></a> fclose(snd_file);
|
|
<a name="l964"></a> if (mp4_percent_cnt)
|
|
<a name="l965"></a> sprintf(st_mp4,mp4_print_fmt,num);
|
|
<a name="l966"></a> else
|
|
<a name="l967"></a> strcpy(st_mp4,mp4_print_fmt);
|
|
<a name="l968"></a> sprintf(st,"ffmpeg -i %s -ar %d %s",st_snd,rate,st_mp4);
|
|
<a name="l969"></a> system(st);
|
|
<a name="l970"></a> fprintf(lst_file,"file '%s'\r\n",st_mp4);
|
|
<a name="l971"></a> } else
|
|
<a name="l972"></a> break;
|
|
<a name="l973"></a> num++;
|
|
<a name="l974"></a> if (!snd_percent_cnt)
|
|
<a name="l975"></a> break;
|
|
<a name="l976"></a> }
|
|
<a name="l977"></a>
|
|
<a name="l978"></a> if (lst_file) {
|
|
<a name="l979"></a> fclose(lst_file);
|
|
<a name="l980"></a> if (num && out_name) {
|
|
<a name="l981"></a> sprintf(st,"ffmpeg -f concat -i TOSZTEMP_AUD_LIST.TXT -c copy %s",
|
|
<a name="l982"></a> out_name);
|
|
<a name="l983"></a> system(st);
|
|
<a name="l984"></a> }
|
|
<a name="l985"></a> }
|
|
<a name="l986"></a> system("rm -R TOSZTEMP*");
|
|
<a name="l987"></a> return num;
|
|
<a name="l988"></a>}
|
|
<a name="l989"></a>
|
|
<a name="l990"></a>int AU2SNDLst(char *au_name,char *snd_print_fmt,
|
|
<a name="l991"></a> char *mp4_print_fmt,char *out_name,double vol=1.0,int rate=24000)
|
|
<a name="l992"></a>{//Cvt AU file to SND lst to MP4
|
|
<a name="l993"></a> int num=0,snd_percent_cnt;
|
|
<a name="l994"></a> FILE *au_file;
|
|
<a name="l995"></a> CSndData head;
|
|
<a name="l996"></a> if (snd_print_fmt)
|
|
<a name="l997"></a> snd_percent_cnt=StrOcc(snd_print_fmt,'%');
|
|
<a name="l998"></a> else
|
|
<a name="l999"></a> snd_percent_cnt=0;
|
|
<a name="l1000"></a> AURead(&head,au_name);
|
|
<a name="l1001"></a> num=SndFileCreate(&head,snd_print_fmt,vol);
|
|
<a name="l1002"></a> QueDel(&head);
|
|
<a name="l1003"></a> return SND2MP4Lst(snd_print_fmt,mp4_print_fmt,out_name,rate);
|
|
<a name="l1004"></a>}
|
|
<a name="l1005"></a>
|
|
<a name="l1006"></a>int main(int argc, char* argv[])
|
|
<a name="l1007"></a>{
|
|
<a name="l1008"></a> char *in_name,*out_name,st[256],*mv_print_fmt,*au_name;
|
|
<a name="l1009"></a> BOOL cvt_ascii,del_in=FALSE;
|
|
<a name="l1010"></a> int i=1,l;
|
|
<a name="l1011"></a> double vol=0.1;
|
|
<a name="l1012"></a> if (argc>i && !strcmp(argv[i],"-mp4")) {
|
|
<a name="l1013"></a> i++;
|
|
<a name="l1014"></a> if (argc>i)
|
|
<a name="l1015"></a> mv_print_fmt=argv[i++];
|
|
<a name="l1016"></a> else
|
|
<a name="l1017"></a> mv_print_fmt=(char *)"VID%03d.MV";
|
|
<a name="l1018"></a> if (argc>i)
|
|
<a name="l1019"></a> au_name=argv[i++];
|
|
<a name="l1020"></a> else
|
|
<a name="l1021"></a> au_name=(char *)"AUDIO.AU";
|
|
<a name="l1022"></a> MV2BMPLst(mv_print_fmt,(char *)"TOSZTEMP%03d",
|
|
<a name="l1023"></a> (char *)"TOSZTEMP%06d.BMP",(char *)"TOSZTEMPVID%03d.MP4",
|
|
<a name="l1024"></a> (char *)"TOSZVIDEO.MP4");
|
|
<a name="l1025"></a> AU2SNDLst(au_name,(char *)"TOSZTEMP%03d.SND",
|
|
<a name="l1026"></a> (char *)"TOSZTEMPAUD%03d.MP4",(char *)"TOSZAUDIO.MP4",vol);
|
|
<a name="l1027"></a> if (argc>i)
|
|
<a name="l1028"></a> out_name=argv[i++];
|
|
<a name="l1029"></a> else
|
|
<a name="l1030"></a> out_name=(char *)"MOVIE.MP4";
|
|
<a name="l1031"></a> sprintf(st,"ffmpeg -i TOSZVIDEO.MP4 -i TOSZAUDIO.MP4 %s",out_name);
|
|
<a name="l1032"></a> system(st);
|
|
<a name="l1033"></a> system("rm TOSZVIDEO.MP4");
|
|
<a name="l1034"></a> system("rm TOSZAUDIO.MP4");
|
|
<a name="l1035"></a> } else {
|
|
<a name="l1036"></a> if (argc>i && !strcmp(argv[i],"-ascii")) {
|
|
<a name="l1037"></a> cvt_ascii=TRUE;
|
|
<a name="l1038"></a> i++;
|
|
<a name="l1039"></a> } else
|
|
<a name="l1040"></a> cvt_ascii=FALSE;
|
|
<a name="l1041"></a> if (argc>i) {
|
|
<a name="l1042"></a> in_name=argv[i++];
|
|
<a name="l1043"></a> if (argc>i)
|
|
<a name="l1044"></a> out_name=argv[i++];
|
|
<a name="l1045"></a> else {
|
|
<a name="l1046"></a> strcpy(st,in_name);
|
|
<a name="l1047"></a> l=strlen(st);
|
|
<a name="l1048"></a> if (l>2 && st[l-1]=='Z' && st[l-2]=='.') {
|
|
<a name="l1049"></a> st[l-2]=0;
|
|
<a name="l1050"></a> del_in=TRUE;
|
|
<a name="l1051"></a> }
|
|
<a name="l1052"></a> out_name=st;
|
|
<a name="l1053"></a> }
|
|
<a name="l1054"></a> if (argc>i)
|
|
<a name="l1055"></a> out_name=argv[i++];
|
|
<a name="l1056"></a> else {
|
|
<a name="l1057"></a> strcpy(st,in_name);
|
|
<a name="l1058"></a> l=strlen(st);
|
|
<a name="l1059"></a> if (l>2 && st[l-1]=='Z' && st[l-2]=='.') {
|
|
<a name="l1060"></a> st[l-2]=0;
|
|
<a name="l1061"></a> del_in=TRUE;
|
|
<a name="l1062"></a> }
|
|
<a name="l1063"></a> out_name=st;
|
|
<a name="l1064"></a> }
|
|
<a name="l1065"></a> if (Cvt(in_name,out_name,cvt_ascii)) {
|
|
<a name="l1066"></a> if (del_in) {
|
|
<a name="l1067"></a> sprintf(st,"rm %s",in_name);
|
|
<a name="l1068"></a> system(st);
|
|
<a name="l1069"></a> }
|
|
<a name="l1070"></a> } else
|
|
<a name="l1071"></a> printf("Fail: %s %s\r\n",in_name,out_name);
|
|
<a name="l1072"></a> } else {
|
|
<a name="l1073"></a> puts("TOSZ [-ascii] in_name [out_name]\r\n"
|
|
<a name="l1074"></a> "expands a single TempleOS file. "
|
|
<a name="l1075"></a> "The -ascii flag will convert "
|
|
<a name="l1076"></a> "nonstandard TempleOS ASCII "
|
|
<a name="l1077"></a> "characters to regular ASCII.\r\n\r\n"
|
|
<a name="l1078"></a> "TOSZ -mp4 VID%03d.MV AUDIO.AU MOVIE.MP4\r\n"
|
|
<a name="l1079"></a> "will call ffmpeg to convert MV files and an AU file "
|
|
<a name="l1080"></a> "to a combined MP4 file.\r\n");
|
|
<a name="l1081"></a> }
|
|
<a name="l1082"></a> }
|
|
<a name="l1083"></a> return EXIT_SUCCESS;
|
|
<a name="l1084"></a>}
|
|
</span></pre></body>
|
|
</html>
|