⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filesys103.txt

📁 台湾凌阳方案300万数码相机源代码
💻 TXT
📖 第 1 页 / 共 5 页
字号:

	// convert to requested number of clusters
        freeCluster = (dataSize+G_DOS_ClusterSize-1)/G_DOS_ClusterSize+1;
        
        // search partial DOS FAT table for requested disk space
        return DOS_CheckDiskSpace(&freeCluster);
}

      
03. Snap a jpeg file
============================================
To snap a dsc image as jpeg file to card, call File_SnapJpg. During capture 
process, File_SnapJpg will call File_JpgStillImage(at imgxxx.c) to set asic 
related registers to capture an image to sdram.         

Below is an example, you could also refer to cardusr.c for example.

Example C05E030:

BYTE CaptureDscImage(void)
{
        BYTE sts;
        BYTE name[12];
        
        // G_SDRAM_ImageAddr sdram variable should already be set
        
        // possible values depend on sensor
        // for example, 1280x960
        G_Image_SensorWidth = K_SENSOR_WIDTH;
        G_Image_SensorHeight = K_SENSOR_HEIGHT;
        
        // possible values depend on sensor and asic
        // Normally, if sensor could output 1280x960,
        // subsample by 0 get 1280x960.
        // subsample by 1 get 640x480.
        // subsample by 2 get 320x240, etc.
        G_Image_HSubSample = 0;
        G_Image_VSubSample = 0;
        
        // possible value are K_Q50, K_Q70, K_Q80, K_Q85
        // K_Q88, K_Q90, K_Q92, K_Q95, hightest q table index, get better 
        // image quality. For small code size consideration, some q table
        // are not included. Please refer to quant.h for actual q table
        // that could be set.
        G_Image_QTableIndex = K_Q92;

        // This control capture dsc image output as 422 or 411.
        // Normally, dsc image is capture as 422 to get high quality.
        G_Image_SrcDataType = K_File_DataType_YUV422;
        
        // ui messages
        File_SendMessage( K_File_UI_Start_DscFile, G_USR_FileCount );
        
        // Besides above global variables to control capture factors,
        // some asic may have more variables to control capture factors,
        // please refer to that asic's imgxxx.c for details.
        
        sts = File_SnapJpg(name);
        if (sts)
        {
                G_USR_FileIndex++;
                G_USR_FileCount++;
                // ui messages
                File_SendMessage( K_File_UI_End_DscFile, G_USR_FileCount );
        }
        else
        	// ui messages
                File_SendMessage( K_File_UI_Err_DscFile, 0 );
                // restore to default q table
                INITIO_SetQTable(K_Qxx); 
        
        return sts;
}


04. Record an avi file
============================================
To record an avi file with or without audio, call File_RecordAvi. During record-
ing process, File_RecordAvi will call File_SetImageMode(at imgxxx.c) with imag-
emode set to 1 to prepare asic for video image recording.

If the asic must put the video image into sdram then File_VideoStrm1Image(at 
imgxxx.c) will be called to get put an video frame into sdram the write to card. 
If the asic able to output the video frame directly from its FIFO to card, then 
File_FifoVideoStrm1Image(at imgxxx.c) will be called.

If you are recording avi without audio, the recording go until card is full or
stop by users. For 500 asic, timer 0 is used to calculate time stamp, so 
TIMER0_Start, TIMER0_Stop is called. For other asic, we use asic's timer to 
calculate time stamp, so in these asics, you should enable and clear timer
in File_SetImageMode when imagemode is 1, File_StopClipMode is call when
avi is stopped, G_TimeStamp should be set here.

If you are recording avi with audio, the recording go until card is full or stop
by users or audio buffer is full. Video related issues are as above, File_
AudioSetMode(at audio.c) will be call to set audio related global variables and 
registers. File_AudioGetSample(at audio.c) which is called under TIMER0_Handler 
to get audio data from audio port to sdram. So TIMER0_Start, TIMER0_Stop is called 
no matter what asic to use. G_TimeStamp is mini second unit and is the the avi 
recording time.

Below is an example, you could also refer to cardusr.c for example.

Example C05E040:

BYTE CaptureVideoAvi(BYTE bAudio)
{
        BYTE sts;
        BYTE name[12];

        // these sdram variable should already be set
        // G_SDRAM_ImageAddr
        // G_File_SDRAM_AviIdx1BufAddr
        // G_File_SDRAM_AviIdx1BufSize

        // if bAudio is TRUE, these sdram variable should already be set
        // G_File_SDRAM_AudioBufAddr
        // G_File_SDRAM_AudioBufSize
        
        // NOTE:possible values depend on sensor
        // for example, 1280x960
        G_Image_SensorWidth = K_SENSOR_WIDTH;
        G_Image_SensorHeight = K_SENSOR_HEIGHT;
        
        // NOTE:possible values depend on sensor and asic
        // Normally, if sensor could output 1280x960,
        // subsample by 0 get 1280x960.
        // subsample by 1 get 640x480.
        // subsample by 2 get 320x240, etc.
        G_Image_HSubSample = 2;
        G_Image_VSubSample = 2;
        
        // possible value are K_Q50, K_Q70, K_Q80, K_Q85
        // K_Q88, K_Q90, K_Q92, K_Q95
        // lower q table index, get better frame rate.
 	// For small code size consideration, some q table
        // are not included. Please refer to quant.h for actual q table
        // that could be set.
        G_Image_QTableIndex = K_Q70;
        
        // This control capture video image output as 422 or 411.
        // Normally, video image is captured as 411 to get better
        // frame rate.
        G_Image_SrcDataType = K_File_DataType_YUV411;

	// make a DCF standard avi file name
        USR_SetAviName(name, G_USR_FileIndex);
        
        // ui message
        File_SendMessage( K_File_UI_Start_AviFile, G_USR_FileCount );
        
        sts = File_RecordAvi(&name[0], bAudio);
        if (sts)
        {
		G_USR_FileIndex++;
		G_USR_FileCount++;
		// ui message
		File_SendMessage( K_File_UI_End_AviFile, G_USR_FileCount );
        }
        else
        	// ui message
       		File_SendMessage( K_File_UI_Err_AviFile, 0 );
              
        // restore to default q table
        INITIO_SetQTable(K_Qxx);
      
	return sts;  
}

Example C05E041:

// When recording avi with audio, below function is called to prepare asic ready
// for audio recording.
void File_AudioSetMode(void) USING_0
{
	// use 8K sample rate
	G_AUDIO_RateScale = 1;
	G_AUDIO_Rate = 8000;
	
	// mono channel
	G_AUDIO_nChannel = 1;
	
	// bytes per sample is 1 byte
	G_AUDIO_nSampleSize = 1;
	
	// If 0x11 using IMA codec, this is built 
	// in supported 504a asic. If 1 using PCM
	// non compress codec.
	G_AUDIO_wFormatTag = 1;	
	
	if ( G_AUDIO_wFormatTag == 0x11 )
		// Sunplus Asic support 4 bit IMA audio compression
		G_AUDIO_Bits = 4;
	else
		G_AUDIO_Bits = 8;
	if ( G_AUDIO_wFormatTag == 0x11 )
	{
		G_AUDIO_wBlockAlign = 512;
		
		// wSamplesPerBlock = 
		// ((nBlockAlign-(4*nChannels))*8)/(wBitsPerSample*nChannels) + 1
		G_AUDIO_wSamplesPerBlock = 
		        ((G_AUDIO_wBlockAlign-(4*G_AUDIO_nChannel))*8)/
			(G_AUDIO_Bits*G_AUDIO_nChannel) + 1;
	}
	else
		G_AUDIO_wBlockAlign = 1;
		
	G_File_SubSampleFactor = K_AUDIO_SubSampleFactor;

        // enable audio capture, this should always 0
        // when not recording avi with audio
        G_File_AudioEnable = 1;

        // initialize audio size (unit: WORD)
        // avi with audio, this value is 4 for "01wb"+4 byte size
        G_File_AudioSize = 4;

        // initialize sample count
        G_File_AudioSampleCount = G_File_SubSampleFactor - 1;

        // should initial audio registers according to above variables
        // :
        // should clear status of audio and audio FIFO
        // :
        // should enable audio chip
        // :
        
        return;
}

05. Record an wave file
============================================
To record audio as wave file, call File_RecordWave. It call File_RecordAudio-
Stream to init and get audio data to sdram buffer, then save audio data as
wave file format.

Example C05E050:
BYTE CaptureAudioWave(void)
{
        BYTE sts;
        BYTE name[12];

        // these sdram variable should already be set
        // G_File_SDRAM_AudioBufAddr
        // G_File_SDRAM_AudioBufSize

	// make a DCF standard wave file name
        USR_SetWaveName(name, G_USR_FileIndex);
        
        // ui message
        File_SendMessage( K_File_UI_Start_WaveFile, G_USR_FileCount );
        
	sts = File_RecordWave(  &name[0], 
	                        G_File_SDRAM_AudioBufAddr, 
	                        G_File_SDRAM_AudioBufSize << 1, 
	                        K_FormatTag_NonCompress);
        if (sts)
        {
		G_USR_FileIndex++;
		G_USR_FileCount++;
        	// ui message
		File_SendMessage( K_File_UI_End_WaveFile, G_USR_FileCount );
        }
        else
        	// ui message
		File_SendMessage( K_File_UI_Err_WaveFile, 0 );
        
        return sts;
}


/*++

Routine Description:
        Record audio data to ramAddr of ramSize according to wFormatTag codec 
        choice.
Arguments:
	ramAddr         : sdram start address that to store audio data, unit is 
	                  word unit
	ramSize         : buffer size of ramAddr, unit is byte
	pAudsValue      : array of 7 long parameter to return to File_RecordWave
	                  to set wave file format values.
                          pAudsValue[0] is K_File_Wave_wFormatTag_Value
                                0x01: non compressed audio
                                0x11: IMA compressed audio, must make sure
                          pAudsValue[1] is K_File_Wave_nChannels_Value
                                0x01 : mono channel
                                0x02 : 2 channel
                          pAudsValue[2] is K_File_Wave_nSamplesPerSec_Value
                                samples per second
                          pAudsValue[3] is K_File_Wave_nAvgBytesPerSec_Value
                                average bytes per second
                          pAudsValue[4] is K_File_Wave_blockAlign_Value
                                block aligned, for non compressed it is 1.
                                For IMA, it could be 256, 512.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -