//////////////////////////// // SET MODE void ModeFsm::SetMode( const Apg::CameraMode newMode ) { if( newMode == m_mode ) { //exit no need to change mode return; } if( !IsModeValid( newMode ) ) { std::stringstream msg; msg << "Invalid mode detected " << newMode; msg << " setting camera to mode " << Apg::CameraMode_Normal; std::string vinfo = apgHelper::mkMsg( m_fileName, msg.str(), __LINE__); ApgLogger::Instance().Write(ApgLogger::LEVEL_RELEASE,"warn",vinfo); SetMode( Apg::CameraMode_Normal ); return; } ExitOldMode(); EnterNewMode( newMode ); Apg::CameraMode old = m_mode; m_mode = newMode; std::stringstream msg; msg << "Succesfully transitioned from mode " << old; msg << " to mode " << m_mode; std::string str = apgHelper::mkMsg( m_fileName, msg.str(), __LINE__); ApgLogger::Instance().Write(ApgLogger::LEVEL_DEBUG,"info",str); }
OSCL_EXPORT_REF int32 CPvGsmAmrEncoder::InitializeEncoder(int32 aMaxOutputBufferSize, TEncodeProperties* aProps) { if (aProps == NULL) { // use default parameters TEncodeProperties dfltProps; aProps = &dfltProps; dfltProps.iInBitsPerSample = KDFLT_GAMR_BITS_PER_SAMPLE; dfltProps.iInSamplingRate = KDFLT_GAMR_SAMPLING_RATE; dfltProps.iInClockRate = dfltProps.iInSamplingRate; dfltProps.iInNumChannels = KDFLT_GAMR_NUM_CHANNELS; iGsmAmrMode = (GSM_AMR_MODES)KDFLT_GAMR_MODE; iBitStreamFormat = AMR_TX_WMF; } else { // check first if input parameters are valid if ((IsModeValid(aProps->iMode) == false) || (aProps->iInBitsPerSample == 0) || (aProps->iInClockRate == 0) || (aProps->iInSamplingRate == 0) || (aProps->iInNumChannels == 0)) { return GSMAMR_ENC_INVALID_PARAM; } // set AMR mode (bits per second) iGsmAmrMode = (GSM_AMR_MODES)aProps->iMode; if (aProps->iBitStreamFormat == AMR_TX_WMF) { iBitStreamFormat = AMR_TX_WMF; } else if (aProps->iBitStreamFormat == AMR_TX_IF2) { iBitStreamFormat = AMR_TX_IF2; } else { iBitStreamFormat = AMR_TX_ETS; } } iBytesPerSample = aProps->iInBitsPerSample / 8; // set maximum buffer size for encoded data iMaxOutputBufferSize = aMaxOutputBufferSize; // return output parameters that will be used aProps->iOutSamplingRate = KDFLT_GAMR_SAMPLING_RATE; aProps->iOutNumChannels = KDFLT_GAMR_NUM_CHANNELS; aProps->iOutClockRate = aProps->iOutSamplingRate; // initialize AMR encoder int32 nResult = AMREncodeInit(&iEncState, &iSidState, false); if (nResult < 0) return(GSMAMR_ENC_CODEC_INIT_FAILURE); return GSMAMR_ENC_NO_ERROR; }
/** * Changes display mode info in options xml file. Mode will take effect * after restart of game (if mode is valid). */ void tcDisplayModes::ChangeOptionsMode(unsigned width, unsigned height, unsigned bits, unsigned freq) { if (!IsModeValid(width, height, bits, freq)) { fprintf(stderr, "tcDisplayModes::ChangeOptionsMode - Invalid mode: " "W:%d, H:%d, Bits:%d Freq:%d\n", width, height, bits, freq); return; } wxString modeString = wxString::Format("%d %d %d %d", width, height, bits, freq); tcOptions::Get()->SetOptionString("DisplaySettings", modeString.GetData()); }
OSCL_EXPORT_REF int32 CPvGsmAmrEncoder::Encode(TInputAudioStream& aInStream, TOutputAudioStream& aOutStream) { // check first if mode specified is invalid if (IsModeValid(aInStream.iMode) == false) return GSMAMR_ENC_INVALID_MODE; // set AMR mode for this set of samples iGsmAmrMode = (GSM_AMR_MODES)aInStream.iMode; // get the maximum number of frames // BX int32 bytesPerFrame = iNumSamplesPerFrame * iBytesPerSample; int32 maxNumFrames = aInStream.iSampleLength / bytesPerFrame; uint8 *pFrameIn = aInStream.iSampleBuffer; uint8 *pFrameOut = aOutStream.iBitStreamBuffer; int32 i; // encode samples for (i = 0; i < maxNumFrames; i++) { // ////////////////////////////////////////// // encode this frame // ////////////////////////////////////////// int32 * temp = & iLastModeUsed; Word16 nStatus = AMREncode(iEncState, iSidState, // BX, Word16 instead of int32 to avoid wierd case(IF2 format): the function returns 31, but nStatus ends up with a big wierd number (Mode)iGsmAmrMode, (Word16 *)pFrameIn, (unsigned char *)pFrameOut, (Frame_Type_3GPP*) temp, iBitStreamFormat); if (nStatus < 0) { // an error when encoding was received, so quit return(GSMAMR_ENC_CODEC_ENCODE_FAILURE); } // save nStatus as this indicates the encoded frame size int32 encFrameSize = (int32)nStatus; aOutStream.iSampleFrameSize[i] = encFrameSize; pFrameOut += encFrameSize; pFrameIn += bytesPerFrame; } // set other values to be returned aOutStream.iNumSampleFrames = maxNumFrames; return(GSMAMR_ENC_NO_ERROR); }
void tcDisplayModes::ChangeMode(unsigned width, unsigned height, unsigned bits, unsigned freq) { DEVMODE winModeInfo; winModeInfo.dmSize = sizeof(DEVMODE); winModeInfo.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY; winModeInfo.dmBitsPerPel = bits; winModeInfo.dmPelsHeight = height; winModeInfo.dmPelsWidth = width; winModeInfo.dmDisplayFrequency = freq; if (!IsModeValid(width, height, bits, freq)) { fprintf(stderr, "tcDisplayModes::ChangeMode - Invalid mode: " "W:%d, H:%d, Bits:%d, Freq:%d\n", width, height, bits, freq); return; } long result = ChangeDisplaySettings(&winModeInfo, 0); // change dynamically if (result == DISP_CHANGE_SUCCESSFUL) { currentMode.bits = bits; currentMode.width = width; currentMode.height = height; currentMode.frequency = freq; } else if (result == DISP_CHANGE_BADMODE) { fprintf(stderr, "tcDisplayModes::ChangeMode - Mode not supported: " "W:%d, H:%d, Bits:%d Freq:%d\n", width, height, bits, freq); } else { fprintf(stderr, "tcDisplayModes::ChangeMode - Mode change failed (%d)", result); } }