VLSI Solution Oy VLSI Solution Oy Evaluation MP3 Player Source Code Documentation

Main Page | Class List | File List | Class Members | File Members | Related Pages

aviplay.c File Reference

Experimental functions to play sound track from AVIfile. More...

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Defines

#define btUNKNOWN   0
#define btLIST   1
#define btSTR   2
#define btAUDIO   3
#define GetLongWord()

Functions

void GetAVIBlock ()
unsigned char PlayAvi ()
 Try to play an avi file at current sector.


Detailed Description

Experimental functions to play sound track from AVIfile.

Definition in file aviplay.c.


Define Documentation

#define btAUDIO   3
 

Definition at line 7 of file aviplay.c.

Referenced by GetAVIBlock().

#define btLIST   1
 

Definition at line 5 of file aviplay.c.

Referenced by GetAVIBlock().

#define btSTR   2
 

Definition at line 6 of file aviplay.c.

#define btUNKNOWN   0
 

Definition at line 4 of file aviplay.c.

 
#define GetLongWord  ) 
 

Value:

{instream.b.b0 = FGetChar(); \ instream.b.b1 = FGetChar();\ instream.b.b2 = FGetChar();\ instream.b.b3 = FGetChar();}

Definition at line 10 of file aviplay.c.

Referenced by GetAVIBlock().


Function Documentation

void GetAVIBlock  ) 
 

Definition at line 15 of file aviplay.c.

References addressType, AvailableProcessorTime(), btAUDIO, btLIST, DiskBlock::Raw::buf, dataBufPtr, diskSect, FGetChar(), fileSize, GetLongWord, GREEN_LED, Temp::i, Address::l, LED_OFF, LED_ON, MP3_DREQ, MP3_XDCS, Mp3DeselectData, Mp3SelectData, DiskBlock::raw, ReadDiskSector(), sectorAddress, SPIPutChar, SPIPutCharWithoutWaiting, SPIWait, and temp.

Referenced by PlayAvi().

00015 { 00016 00017 xdata addressType instream; 00018 xdata unsigned char blockType = 0; 00019 bit isPadded = 0; 00020 00021 GetLongWord(); 00022 if ((instream.b.b2 == 'w') && (instream.b.b3 == 'b')){ 00023 blockType = btAUDIO; 00024 } 00025 if (instream.l==1414744396){ //LIST 00026 blockType = btLIST; 00027 } 00028 GetLongWord(); 00029 //instream.l should now contain the chunk size. 00030 //its length must be even by spec. if it's odd, a pad byte is 00031 //in the file but its NOT part of chunk data. 00032 if (instream.b.b0&1){ 00033 isPadded = 1; //There is a pad byte to make chunk len even 00034 }else{ 00035 isPadded = 0; 00036 } 00037 00038 00039 if (blockType == btAUDIO){ 00040 //--------THIS PACKET IS SENT TO VS10xx--------- 00041 //superbly hilarious effects could happen if the avifile has 00042 //more than 1 soundtrack as all of them would be sent to VS10xx 00043 00044 while(instream.l){ 00045 unsigned char c; 00046 00047 while ((instream.l>16)&&(dataBufPtr < diskSect.raw.buf+496)){ 00048 //We have at least 16 octets of continuous stream in mem. 00049 if (!MP3_DREQ){ 00050 GREEN_LED = LED_ON; 00051 while (!MP3_DREQ){ 00052 Mp3DeselectData(); 00053 AvailableProcessorTime(); 00054 } 00055 } 00056 GREEN_LED = LED_OFF; 00057 Mp3SelectData(); 00058 SPIPutCharWithoutWaiting(*dataBufPtr++); 00059 SPIWait(); 00060 SPIPutChar(*dataBufPtr++); 00061 SPIPutChar(*dataBufPtr++); 00062 SPIPutChar(*dataBufPtr++); 00063 SPIPutChar(*dataBufPtr++); 00064 SPIPutChar(*dataBufPtr++); 00065 SPIPutChar(*dataBufPtr++); 00066 SPIPutChar(*dataBufPtr++); 00067 SPIPutChar(*dataBufPtr++); 00068 SPIPutChar(*dataBufPtr++); 00069 SPIPutChar(*dataBufPtr++); 00070 SPIPutChar(*dataBufPtr++); 00071 SPIPutChar(*dataBufPtr++); 00072 SPIPutChar(*dataBufPtr++); 00073 SPIPutChar(*dataBufPtr++); 00074 SPIPutChar(*dataBufPtr++); 00075 instream.l-=16; 00076 fileSize-=16; 00077 SPIWait(); 00078 } 00079 00080 MP3_XDCS=1; 00081 instream.l--; 00082 c=FGetChar(); //data comes first until end of sector and 00083 //then a new sector is loaded automagically. 00084 MP3_XDCS=0; 00085 SPIPutCharWithoutWaiting(c); 00086 //SPIWait(); 00087 } 00088 MP3_XDCS=1; 00089 }else if (blockType == btLIST){ 00090 ConsoleWrite("\rAVI: List of "); 00091 GetLongWord(); 00092 ConsolePutChar(instream.b.b0); 00093 ConsolePutChar(instream.b.b1); 00094 ConsolePutChar(instream.b.b2); 00095 ConsolePutChar(instream.b.b3); 00096 00097 }else{ 00098 //We don't need this chunk. Let's quickly skip over it. 00099 00100 //Is pad byte insertion needed? 00101 if (isPadded){ 00102 instream.l++; //instream.l contains chunk size 00103 isPadded = 0; 00104 } 00105 00106 //Skip to the end of sector 00107 if (instream.l>(temp.i=diskSect.raw.buf+512-dataBufPtr)){ 00108 //The packet continues after end of sector 00109 instream.l -= temp.i; 00110 fileSize -= temp.i; 00111 sectorAddress.l++; //Sector handled, go to next. 00112 dataBufPtr = 0; //Complete sector is handled. 00113 } 00114 00115 //Skip unnecessary sectors 00116 if (instream.l>512){ 00117 while (instream.l>512){ 00118 sectorAddress.l++; 00119 instream.l -= 512; 00120 fileSize -= 512; 00121 } 00122 dataBufPtr = 0; //Initialize for next call to FGetChar(); 00123 } 00124 00125 //Read last sector into memory 00126 if (dataBufPtr == 0){ 00127 ReadDiskSector(sectorAddress.l); 00128 dataBufPtr = diskSect.raw.buf; 00129 } 00130 while (instream.l--){ 00131 dataBufPtr++; 00132 } 00133 }//nothing interesting,skip block 00134 00135 if (isPadded){ 00136 FGetChar(); 00137 } 00138 00139 }

Here is the call graph for this function:

unsigned char PlayAvi  ) 
 

Try to play an avi file at current sector.

Returns 0x11 if AVI header is not found, 0 if the file is played.

Definition at line 144 of file aviplay.c.

References DiskBlock::Raw::buf, dataBufPtr, diskSect, fileSize, GetAVIBlock(), Address::l, DiskBlock::raw, ReadDiskSector(), and sectorAddress.

Referenced by PlayDiskSectors().

00144 { 00145 00146 ReadDiskSector(sectorAddress.l); 00147 00148 //DumpDiskSector(); 00149 00150 if (diskSect.raw.buf[8]!='A') return 0x11; 00151 if (diskSect.raw.buf[9]!='V') return 0x11; 00152 if (diskSect.raw.buf[10]!='I') return 0x11; 00153 ConsoleWrite("\rPlayAvi()\r"); 00154 00155 dataBufPtr=diskSect.raw.buf+12; 00156 00157 while(fileSize){ 00158 GetAVIBlock(); 00159 } 00160 00161 return 0; 00162 }

Here is the call graph for this function:


All software copyright 2000-2004 VLSI Solution OY. Redistribution of these software modules are limited to promotional use only and only with the VS1011 / VS1002 / VS1003 MP3-Evakit evaluation boards. Free or commercial use of these software modules in MP3 players is ok if the product includes MP3 decoder chip(s) from VLSI. You can request the complete (compilable) package from mp3@vlsi.fi