1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
void main()
{
H263Video OutVideo(300);
VideoColourExtraction Test;
int k=0,j=0,i=0;
char* ptr;
//char *INPUT_FILE;
//char *OUT_PATH;
const char *INPUT_FILE ="C:\\Test\\";
const char *OUT_PATH="C:\\Test\\OutTest\\"; // L'errore è indipendente dal percorso scelto per i file, xk ank posto il percorso pari a "" continua a crashare!
string headerIn(INPUT_FILE),fname,fpathIN,ext(".263");
string headerOut(OUT_PATH),outfile,fpathOUT;
//////////////////////////////////////////////////////////////////////////////
H263Video Video(500); // BlackVideo(500);
BitStream InStream,OutStream;
H263Decoder Dec;
H263Coder Cod;
clock_t start,end;
// string fpathIN(INPUT_FILE);
// string fpathOUT(OUT_PATH);
////////////// Inserimento Dati Da Input ///////////////////////////////////
cout<<"Insert input file name (don't type .263 extension!!): ";
cin>>fname;
fpathIN=headerIn+fname+ext;
cout<<"Insert output file name: ";
cin>>outfile;
fpathOUT=headerOut+outfile+ext;
//////////// Preparazione File In Ingresso /////////////////////////////
FILE *InFile;
InFile=fopen(fpathIN.c_str(),"rb");
while (feof(InFile)!=EOF) //// Il programma crasha qui..
{
fread(InStream.CurrFrame(),sizeof(Word16),50,InFile);
InStream.MoveNext();
//InStream.AddFrame(Data.Ptr);
}
fclose(InFile);
InStream.BuildStream(20000,100,Stream_Def_TLen, Stream_Def_TStr);
// string fpathIN(INPUT_FILE);
// string fpathOUT(OUT_PATH);
Word16 low=0,up=0;
MemoryBlock Data(100);
FileClass fc(fpathIN.c_str());
while (((low=fc.fp().get())!=EOF)){
if((up=fc.fp().get())!=EOF)
{
Data.Ptr[i]=(up<<8)|(low&0x00FF);
i++;
if(i==50){
//i=Data.Ptr[49];
InStream.AddFrame(Data.Ptr);
i=0;
}
}
else
break;
}
////////////////// Decodifica del InStream /////////////////////////////////
Dec.SetIn(&InStream);
Dec.SetOut(&Video);
Dec.Execute();
///////////////// Blocco di estrazione VideoColourExtraction ///////////////
Test.SetIn(&Video);
Test.SetOut(&OutVideo);
Test.MBAnalyse();
OutVideo = Test.GetOut();
////////////////////////// Codifica H263Codec ////////////////////
Cod.SetIn(&OutVideo);
Cod.SetOut(&OutStream);
Cod.Execute();
OutStream=Cod.GetOut();
///////////////////////// Preparazione File In Uscita ////////////////////
FILE *fp=fopen(fpathOUT.c_str(),"wb");
while(k<((OutStream.GetPos().FrameHandler))){
fwrite(OutStream.GetFrameByHandler(k),1,1000,fp);
k++;
}
j=0;
ptr=(char*)OutStream.GetFrameByHandler(k);
while(j<((OutStream.GetPos().Position)+1))
{
fputc(*ptr,fp);
(*ptr++);
j++;
}
fclose(fp);
////////////////////////////////////////////////////////////////////////////////
}
|