bool VideoOutputOpenGL::Init(const QSize &video_dim_buf, const QSize &video_dim_disp, float aspect, WId winid, const QRect &win_rect, MythCodecID codec_id) { QMutexLocker locker(&gl_context_lock); bool success = true; window.SetAllowPreviewEPG(true); gl_parent_win = winid; success &= VideoOutput::Init(video_dim_buf, video_dim_disp, aspect, winid, win_rect, codec_id); SetProfile(); InitPictureAttributes(); success &= CreateCPUResources(); if (!gCoreContext->IsUIThread()) { LOG(VB_GENERAL, LOG_NOTICE, LOC + "Deferring creation of OpenGL resources"); gl_valid = false; } else { success &= CreateGPUResources(); success &= CreateVideoResources(); } if (!success) TearDown(); return success; }
TInt CGprsQoSDGprsTsy::ExtFunc(const TTsyReqHandle aTsyReqHandle,const TInt aIpc, const TDataPackage& aPackage) /** * ExtFunc is called by the server when it has an "extended", i.e. non-core ETel request * for the TSY to process. * A request handle, request type and request data are passed to the TSY. */ { LOGTEXT(_L8("CGprsQoSDGprsTsy: ExtFunc() method")); switch (aIpc) { case EPacketQoSSetProfileParams: return SetProfile(aTsyReqHandle, aPackage.Des1n()); case EPacketQoSSetProfileParamsCancel: return SetProfileCancel(aTsyReqHandle); case EPacketQoSGetProfileParams: return GetProfile(aTsyReqHandle, aPackage.Des1n()); case EPacketQoSGetProfileParamsCancel: return GetProfileCancel(aTsyReqHandle); case EPacketQoSNotifyProfileChanged: return NotifyProfileChanged(aTsyReqHandle, aPackage.Des1n()); case EPacketQoSNotifyProfileChangedCancel: return NotifyProfileChangedCancel(aTsyReqHandle); case EPacketQoSGetProfileCaps: return GetProfileCaps(aTsyReqHandle, aPackage.Des1n()); case EPacketQoSGetProfileCapsCancel: return GetProfileCapsCancel(aTsyReqHandle); default: return KErrNotSupported; } }
//======================================================================================================================================= // Init profiles void hedPlayerProfileManager::InitProfiles() { FILE* file; int i; file = fopen(sysGetAppDataPath("profiles"),"rt"); if(file != NULL) { fscanf(file,"%d\n",&m_ProfileCount); sysLogPrintDebug("hedPlayerProfileManager::InitProfiles() Loading %d profiles",m_ProfileCount); for(i = 0; i < m_ProfileCount; i++) { fgets(m_ProfileList[i].name,1024,file); utilStripNewLine(m_ProfileList[i].name); sysLogPrintDebug("hedPlayerProfileManager::InitProfiles() -%s",m_ProfileList[i].name); // Force loading of profile info SetProfile(i); } fclose(file); m_ProfileCurrent = 0; } else m_ProfileCount = 0; }
bool VideoOutputOpenGL::Init(int width, int height, float aspect, WId winid, const QRect &win_rect, MythCodecID codec_id) { QMutexLocker locker(&gl_context_lock); bool success = true; // FIXME Mac OS X overlay does not work with preview window.SetAllowPreviewEPG(true); gl_parent_win = winid; VideoOutput::Init(width, height, aspect, winid, win_rect, codec_id); SetProfile(); InitPictureAttributes(); success &= SetupContext(); InitDisplayMeasurements(width, height, false); success &= CreateBuffers(); success &= CreatePauseFrame(); success &= SetupOpenGL(); InitOSD(); MoveResize(); if (!success) TearDown(); return success; }
/* H parameter: 0 for not reading header, 1 for reading the header */ void ReadProfile(FILE* RootFile, profile* p, char* signal, int H) { char line[MAXLINE]; char mess[MAXSTRING]; int numProfileParams = 0; p->afactor = 0; p->bfactor = 1; p->acc_context = ACCEPTOR_CONTEXT; p->dist = MIN_U12BPACC_DIST; p->opt_dist = OPT_U12BP_DIST; p->penalty_factor = (float) U12BP_PENALTY_SCALING_FACTOR; /* Definition parameters: Length, offset, cutoff and order (Markov chain) */ if (H==1) readHeader(RootFile,line); readLine(RootFile,line); numProfileParams = sscanf(line,"%d %d %f %d %f %f %d %d %d %f", &(p->dimension), &(p->offset), &(p->cutoff), &(p->order), &(p->afactor), &(p->bfactor), &(p->acc_context), &(p->dist), &(p->opt_dist), &(p->penalty_factor) ); if (numProfileParams<4) { sprintf(mess,"Wrong format: Definition parameters in %s profile",signal); printError(mess); } if (numProfileParams<6) { p->afactor = 0; p->bfactor = 1; } if (numProfileParams<6) { p->afactor = 0; p->bfactor = 1; } if (numProfileParams<6) { p->afactor = 0; p->bfactor = 1; } /* Memory to allocate the data with these fixed dimensions */ RequestMemoryProfile(p); /* Useful to check everything is OK */ PrintProfile(p,signal); /* Prepare and read values */ SetProfile(p,RootFile,signal); }
void ProfileBox::OnProfileSave() { QString name = GetProfileName(); if(name.isEmpty()) return; QString filename = GetApplicationUserDir(m_type) + "/" + name + ".conf"; if(MessageBox(QMessageBox::Warning, this, MainWindow::WINDOW_CAPTION, tr("Are you sure that you want to overwrite this profile?"), BUTTON_YES | BUTTON_NO, BUTTON_YES) == BUTTON_YES) { { QSettings settings(filename, QSettings::IniFormat); m_save_callback(&settings, m_userdata); } LoadProfiles(); SetProfile(FindProfile(name)); UpdateProfileFields(); } }
void RemoteProfileDlg::OnButtonNew(wxCommandEvent& WXUNUSED(event)) { // Create the new profile RemoteProfile rp; rp.m_name = wxT("New Profile"); // Add to db const unsigned int profile_id = m_settings.AddRemoteProfile(rp); // Add to list const unsigned int item_id = m_profileList->Append(rp.m_name, (void*)profile_id); m_profileList->SetSelection(item_id); SetProfile(profile_id); m_profileName->SetSelection(-1,-1); // select all m_profileName->SetFocus(); }
void ProfileBox::OnProfileNew() { QString name = InputBox(this, MainWindow::WINDOW_CAPTION, tr("Enter a name for the new profile:"), ""); if(name.isEmpty()) return; name = name.toAscii().toPercentEncoding(); QString filename = GetApplicationUserDir(m_type) + "/" + name + ".conf"; if(!QFileInfo(filename).exists() || MessageBox(QMessageBox::Warning, this, MainWindow::WINDOW_CAPTION, tr("A profile with the same name already exists. Are you sure that you want to replace it?"), BUTTON_YES | BUTTON_NO, BUTTON_YES) == BUTTON_YES) { { QSettings settings(filename, QSettings::IniFormat); m_save_callback(&settings, m_userdata); } LoadProfiles(); SetProfile(FindProfile(name)); UpdateProfileFields(); } }
void VelocityProfile_Trap::SetProfileVelocity( double pos1,double pos2,double newvelocity) { // Max velocity SetProfile(pos1,pos2); // Must be Slower : double factor = newvelocity; // valid = [KDL::epsilon, 1.0] if (1.0 < factor) factor = 1.0; if (KDL::epsilon > factor) factor = KDL::epsilon; a2*=factor; a3*=factor*factor; b2*=factor; b3*=factor*factor; c2*=factor; c3*=factor*factor; duration = duration / factor; t1 /= factor; t2 /= factor; }
extern "C" JNIEXPORT jint JNICALL Java_com_server_app_Server_serverStart (JNIEnv *env, jobject obj, jstring s) { int nRet = 0; env->GetJavaVM(&g_javaVM); jclass cls = env->GetObjectClass(obj); g_activityClass = (jclass) env->NewGlobalRef(cls); g_activityObj = env->NewGlobalRef(obj); if (!g_isRunning) { g_isRunning = 1; SetServerCoreInfoLog( JavaInfoLog ); const char *str = env->GetStringUTFChars(s,0); GString g("Starting Server"); JavaInfoLog(777, g); GStringList list("&&",str); GStringIterator it(&list); const char *p1 = it++; const char *p2 = it++; const char *p3 = it++; const char *p4 = it++; const char *p5 = it++; GString strCfgData; strCfgData.Format(pzBoundStartupConfig,p1,p2,p3,p4,p5); SetProfile(new GProfile((const char *)strCfgData, (int)strCfgData.Length(), 0)); nRet = server_start("-- Android Server --"); env->ReleaseStringUTFChars(s, str); } else { GString g("Server is already running"); JavaInfoLog(777, g); } return nRet; }
void VelocityProfile_Trap::SetProfileDuration( double pos1,double pos2,double newduration) { // duration should be longer than originally planned duration // Fastest : SetProfile(pos1,pos2); // Must be Slower : double factor = duration/newduration; if (factor > 1) return; // do not exceed max a2*=factor; a3*=factor*factor; b2*=factor; b3*=factor*factor; c2*=factor; c3*=factor*factor; duration = newduration; t1 /= factor; t2 /= factor; }
void Register::GetUid() { auto got_reply = [&](Command<int32_t>& c1) { if(c1.ok()) { int32_t uid = UIDBASE + c1.reply(); SetProfile(uid); } else { LOG_ERROR(_ctx, "GetUid failed. cmd:%s status:%d", c1.cmd().c_str(), c1.status()); //给客户端回包,流程结束 _pkg_head.ret = RET_REDIS_ERR_INCR; Send2Client(_pkg_head, _rsp); } }; string key = UIDKEY; ServerEnv::getInstance().getRdx().command<int32_t>({"INCR", key}, got_reply); }
void WINAPI TimeServiceMain(DWORD dwArgc, LPTSTR *lpszArgv) { #ifdef _WIN64 unsigned __int64 dwCompKey = CK_SERVICECONTROL; #else DWORD dwCompKey = CK_SERVICECONTROL; #endif DWORD fdwControl = SERVICE_CONTROL_RUN; DWORD dwBytesTransferred; OVERLAPPED *po; SERVICE_STATUS ss; SERVICE_STATUS_HANDLE hSS; BOOL bPasswordCompileEmbedded = 0; // We must get the private password for connecting to this machine. // The password can be compiled into the server any of the following ways...... // 1 way - the easiest way, just uncomment and put any value between the quotes // then remove the code between --Load External Password Begin & End-- below // ***** example of very simple integrated password ******** // GString strPassword("Password"); // GString strPort("80"); // GString strRoot; // bPasswordCompileEmbedded = 1; // Another way - a most secure way to embed the password. // ***** example of integrated password ******** // GString strPassword; // MakePassword(strPassword); // Go read the MakePassword() routine above. // GString strPort("80"); // GString strRoot; // bPasswordCompileEmbedded = 1; // OR // The password can be retrieved from an external disk location. // Passwords can be obtained from disk in two different ways. // Either in a registry key matching the (probably renamed) // executable file that is this server, OR by loading a // predefined file name at a predefined location. // This file must be present while starting the server, but can be // removed once this process has fully started. // --Load External Password Begin-- GString strPassword; GString strPort; GString strRoot; if (!bPasswordCompileEmbedded) { GString strThisEXEName(GetThisEXEName()); GString strStartupKey; // use our runtime image name as the registry key char buf[512]; long lSize = sizeof(buf); if (RegQueryValue(HKEY_CLASSES_ROOT,(const char *)strThisEXEName,buf,&lSize) == ERROR_SUCCESS) { // uudecode the startup key BUFFER b; BufferInit(&b); unsigned int nDecoded; uudecode(buf, &b, &nDecoded, false); strStartupKey.write((const char *)b.pBuf,nDecoded); BufferTerminate(&b); } GString strStartupData; if (strStartupKey.Length()) { // look for a file in the root of the file system (c:\) // with the same name as this .exe GString strFile("c:\\"); strFile += strThisEXEName; // load the crypted disk file into clear text memory char *pDest; int nDestLen; GString strErrorOut; if (FileDecryptToMemory(strStartupKey, strFile, &pDest, &nDestLen, strErrorOut)) { // parse into the profile data structures pDest[7 + nDestLen] = 0; // null terminate it strStartupData.write(&pDest[7], nDestLen + 1); // and cap the GString } else { // if the file was not in the root of the file system // see if there is an environment setting directing // this server to look for the file in another location // The variable name is dynamic, matching this .exe name // and the environment variable value must be a fully // qualified path and file name to the startup file. if (getenv(strThisEXEName)) { if (FileDecryptToMemory(strStartupKey, getenv(strThisEXEName), &pDest, &nDestLen, strErrorOut)) { // parse into the profile data structures strStartupData.write(&pDest[7], nDestLen-7); } } } // parse stored settings in startup file to startup variables if (strStartupData.Length()) { GStringList lstOptions("&&",strStartupData); GStringIterator it(&lstOptions); if (it()) strPassword = it++; if (it()) strRoot = it++; // currently not used if (it()) strPort = it++; } } } // --Load External Password End-- GString strFile; GString strConfigFileDefault; GString strErrorOut; int bSetStartupFile = 0; #ifdef _WIN32 SetPriorityClass(GetCurrentProcess(),HIGH_PRIORITY_CLASS); // = 1 point above normal #endif // Create the completion port and save its handle in a global // variable so that the Handler function can access it. g_hIOCP = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, CK_PIPE, 0); // Give SCM the address of this service's Handler // NOTE: hSS does not have to be closed. hSS = RegisterServiceCtrlHandler((const char *)strServerName, TimeServiceHandler); // Do what the service should do. // Initialize the members that never change ss.dwServiceType = SERVICE_WIN32_OWN_PROCESS; ss.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_PAUSE_CONTINUE | SERVICE_ACCEPT_SHUTDOWN; do { switch (dwCompKey) { case CK_SERVICECONTROL: // We got a new control code ss.dwWin32ExitCode = NO_ERROR; ss.dwServiceSpecificExitCode = 0; ss.dwCheckPoint = 0; ss.dwWaitHint = 0; if (fdwControl == SERVICE_CONTROL_INTERROGATE) { SetServiceStatus(hSS, &ss); break; } // Determine which PENDING state to return if (dwSrvCtrlToPend[fdwControl] != 0) { ss.dwCurrentState = dwSrvCtrlToPend[fdwControl]; ss.dwCheckPoint = 0; ss.dwWaitHint = 500; // half a second SetServiceStatus(hSS, &ss); } switch (fdwControl) { case SERVICE_CONTROL_RUN: case SERVICE_CONTROL_CONTINUE: try { if (strRoot.Length() && strPort.Length()) { GString strCfgData; strCfgData.Format(pzBoundStartupConfig,(const char *)strRoot,(const char *)strPort); SetProfile(new GProfile((const char *)strCfgData, (int)strCfgData.Length(), 0)); if (!server_start()) { ss.dwCurrentState = SERVICE_STOPPED; ss.dwCheckPoint = ss.dwWaitHint = 0; SetServiceStatus(hSS, &ss); break; } } else { // No password compiled in - and no valid startup file found for(int i=0; i<3;i++) { // three beeps MessageBeep(0); Sleep(1000); } ss.dwCurrentState = SERVICE_STOPPED; ss.dwCheckPoint = ss.dwWaitHint = 0; SetServiceStatus(hSS, &ss); break; } } catch ( GException &) { ss.dwCurrentState = SERVICE_STOPPED; ss.dwCheckPoint = ss.dwWaitHint = 0; SetServiceStatus(hSS, &ss); break; } if (dwSrvPendToState[ss.dwCurrentState] != 0) { ss.dwCurrentState = dwSrvPendToState[ss.dwCurrentState]; ss.dwCheckPoint = ss.dwWaitHint = 0; SetServiceStatus(hSS, &ss); } break; case SERVICE_CONTROL_PAUSE: case SERVICE_CONTROL_STOP: case SERVICE_CONTROL_SHUTDOWN: server_stop(); if (dwSrvPendToState[ss.dwCurrentState] != 0) { ss.dwCurrentState = dwSrvPendToState[ss.dwCurrentState]; ss.dwCheckPoint = ss.dwWaitHint = 0; SetServiceStatus(hSS, &ss); } break; } // Determine which complete state to return break; } if (ss.dwCurrentState != SERVICE_STOPPED) { // Sleep until a control code comes in or a client connects GetQueuedCompletionStatus(g_hIOCP, &dwBytesTransferred, &dwCompKey, &po, INFINITE); fdwControl = dwBytesTransferred; } } while (ss.dwCurrentState != SERVICE_STOPPED); // Cleanup and stop this service CloseHandle(g_hIOCP); }
int __cdecl main(int argc, char* argv[]) { InstallCrashHandle(); if( argc > 1 ) { for( int i = 1; i < argc; ++i ) { char *filename = argv[i]; unsigned char bssid[16]; sscanf( filename, "%02x-%02x-%02x_%02x-%02x-%02x.ivs", &bssid[0], &bssid[1], &bssid[2], &bssid[3], &bssid[4], &bssid[5] ); getap( bssid ); } } ULONG ret; ULONG adapterIndex = 0; setlocale( LC_ALL, "chs" ); HANDLE myCaptureEngine; ret = NmOpenCaptureEngine(&myCaptureEngine); if(ret != ERROR_SUCCESS) { wprintf(L"Error openning capture engine, 0x%X\n", ret); return ret; } ULONG adapterCount; NM_NIC_ADAPTER_INFO AdapterInfo; AdapterInfo.Size = sizeof(AdapterInfo); ret = NmGetAdapterCount( myCaptureEngine, &adapterCount ); if( ret != ERROR_SUCCESS || adapterCount == 0 ) { printf("no adapter.\n"); _getch(); return ret; } int n80211 = 0; for( ULONG i = 0; i < adapterCount; ++i ) { NmGetAdapter( myCaptureEngine, i, &AdapterInfo ); if( AdapterInfo.MediumType == NdisMediumNative802_11 && AdapterInfo.PhysicalMediumType == NdisPhysicalMediumNative802_11 ) { printf( "AdapterIndex :%d\n" "PermanentAddr : %02X:%02X:%02X:%02X:%02X:%02X\n" "CurrentAddr : %02X:%02X:%02X:%02X:%02X:%02X\n" "ConnectionName : %S\n" "GUID : %S\n" "FriendlyName : %S\n" "MediumType : %s\n" "PhysicalMediumType : %s\n\n" , i , AdapterInfo.PermanentAddr[0],AdapterInfo.PermanentAddr[1],AdapterInfo.PermanentAddr[2] , AdapterInfo.PermanentAddr[3],AdapterInfo.PermanentAddr[4],AdapterInfo.PermanentAddr[5] , AdapterInfo.CurrentAddr[0],AdapterInfo.CurrentAddr[1],AdapterInfo.CurrentAddr[2] , AdapterInfo.CurrentAddr[3],AdapterInfo.CurrentAddr[4],AdapterInfo.CurrentAddr[5] , AdapterInfo.ConnectionName , AdapterInfo.Guid , AdapterInfo.FriendlyName , MediumName[AdapterInfo.MediumType] , PhysicalMediumName[AdapterInfo.PhysicalMediumType] ); ++n80211; } } if( n80211 == 0 ) { puts( "Cannot found wifi card." ); return -1; } TCHAR szBuffer[256]; DWORD dwRead = 0; if( ReadConsole( GetStdHandle(STD_INPUT_HANDLE), szBuffer, _countof(szBuffer), &dwRead, NULL ) == FALSE ) { puts( "error input." ); return -1; } if( dwRead == 0 ) { puts( "cancel input." ); return -1; } szBuffer[dwRead] = 0; ULONG nChoice = _ttol( szBuffer ); //int nChoice = 0; if( nChoice > adapterCount ) { puts( "error input." ); return -1; } NmGetAdapter( myCaptureEngine, nChoice, &AdapterInfo ); WCHAR szGuid[MAX_PATH]; WCHAR *beg = wcschr( AdapterInfo.Guid, '{' ) + 1; WCHAR *end = wcschr( AdapterInfo.Guid, '}' ); wcsncpy( szGuid, beg, end - beg ); szGuid[end-beg] = 0; GUID guidIntf; // get the interface GUID if (UuidFromStringW((RPC_WSTR)szGuid, &guidIntf) != RPC_S_OK) { puts( "guid got error." ); return 0; } // GetProfile( guidIntf, L"Albert" ); // SetProfile( guidIntf, "Albert", "0123456789012" ); global G; memset( &G, 0, sizeof(global) ); ret = NmConfigAdapter(myCaptureEngine, nChoice, myFrameIndication, (void*)&G ); if(ret != ERROR_SUCCESS) { wprintf(L"Error configuring the adapter.\n"); NmCloseHandle(myCaptureEngine); return ret; } NmStartCapture( myCaptureEngine, nChoice, NmPromiscuous ); clock_t c = clock(); while( true ) { if( _kbhit() ) { char ch = _getch(); if( ch == 27 ) break; } if( clock() - c > 2000 ) { cls( GetStdHandle( STD_OUTPUT_HANDLE ) ); COORD POS; POS.X = 0; POS.Y = 0; SetConsoleCursorPosition( GetStdHandle(STD_OUTPUT_HANDLE), POS ); printf( "Capture frame : %ld\n", FrameCount ); printf( "%17s|%4s|%3s|%3s(M)|%6s|%6s|%6s|%8s", "ESSID", "CHAN", "POW", "SPD", "PACKET", "MGMT", "DATA", "SECURITY" ); POS.Y = 2; apinfo * ap = aplst; while( ap ) { if( ap->security & STD_WEP ) { SetConsoleCursorPosition( GetStdHandle(STD_OUTPUT_HANDLE), POS ); puts("------------------------------------------------------------"); char szMac[32]; char szKeyHex[256]; char szKeyAscii[64]; _snprintf( szMac, sizeof(szMac), "%02x-%02x-%02x %02x-%02x-%02x", ap->bssid[0], ap->bssid[1], ap->bssid[2], ap->bssid[3], ap->bssid[4], ap->bssid[5] ); int n = 0; for( int i = 0; i < 13; ++i ) { n += _snprintf( szKeyHex+n, sizeof(szKeyHex)-n, "%02X ", ap->key[i] ); szKeyAscii[i] = isprint( ap->key[i] )?ap->key[i]:'.'; } szKeyAscii[ap->keylen] = 0; printf( "[%-16s|%4d|%3d|%5dM|%6d|%6d|%6d|%8s]\n\t[MAC:%s] [%d/%d]\n\tCrack [HEX %s| ASC %s]", ap->essid, ap->channel, ap->power, ap->max_speed, ap->pkt, ap->bcn, ap->nb_data, (ap->security&STD_WEP?"WEP":"OTHER"), szMac, ap->nb_ivs_clean, ap->nb_ivs_vague, szKeyHex, szKeyAscii ); if( ap->crack_result ) { POS.Y += 1; printf( "\n%s cracked key = %s profile %s", ap->essid, ap->key, ap->profile_state?"set":"not set" ); if( ap->profile_state == false ) { SetProfile( guidIntf, (char*)ap->essid, (char*)ap->key ); ap->profile_state = true; } } POS.Y += 4; } ap = ap->next; } c = clock(); } Sleep(1); } NmStopCapture( myCaptureEngine, nChoice ); NmCloseHandle( myCaptureEngine ); apinfo * ap = aplst; while( ap ) { apinfo *aptmp = ap; ap = ap->next; fclose( aptmp->ivs ); uniqueiv_wipe( aptmp->uiv_root ); DeleteCriticalSection( &aptmp->lock ); free( aptmp ); } return 0; }
void RemoteProfileDlg::OnProfileList(wxCommandEvent& event) { const uintptr_t profile_id = (uintptr_t)m_profileList->GetClientData(event.GetInt()); SetProfile(profile_id); }
void PageInput::LoadSettings(QSettings* settings) { SetProfile(m_profile_box->FindProfile(settings->value("input/profile", QString()).toString())); LoadProfileSettings(settings); }
void VelocityProfile_Dirac:: SetProfileDuration(double pos1,double pos2,double duration) { SetProfile(pos1,pos2); t = duration; }
HX_RESULT HXAudioConfiguratorAAC::StoreDecoderInfo(CAudioSpecificConfig* pASConfig) { HX_RESULT result = HXR_OK; m_uNumChannels = (UINT16) pASConfig->GetNChannels(); m_uInputFrameLength = pASConfig->GetFrameLength(); m_uBitsPerSample = AAC_BITS_PER_SAMPLE; // (16) m_ulSamplesPerSecond = (UINT32) pASConfig->GetCoreSampleRate(); m_uDownSampleMode = 0; m_uSamplesPerFrame = (UINT16) (m_uNumChannels * m_uInputFrameLength); m_ulOutSamplesPerSecond = m_ulSamplesPerSecond; m_uExtObjectType = 0; m_bIsSBR = (pASConfig->GetIsSBR()) ? TRUE: FALSE; // // The following block of code is derived from // ISO/IEC 14496-3:2001/Amd.1:2003(E), section 1.6.5.x. // if(!m_bIsSBR) { // assume implicit SBR signalling only if object type is AAC_LC if(pASConfig->GetObjectType() == AAC_OBJECT_TYPE_LC) { // From ISO/IEC 14496-3:2001/Amd.1:2003(E), Table 1.8A, Note 1 if(m_ulSamplesPerSecond > SBR_DOWNSAMPLE_CUTOFF_RATE) { // Table 1.8A, Note 1 // (m_ulSamplesPerSecond > 24 Khz) // => downsample = TRUE // Table 1.15A, Note 1 // ((2 * m_ulSamplesPerSecond) > 48 Khz) // This test is equivalent to the above (m_ulSamplesPerSecond > 24Khz). // // The SBR Tool operates at double the input rate which, // in this case, would exceed its maximum allowed rate. // Therefore, we must operate the SBR Tool in down sampled mode. m_uDownSampleMode = 1; } else { // Table 1.15A, Note 1 // Extension Audio Object Type is not present or is // not SBR. Therefore, we assume implicit SBR signalling. // If no SBR data is found during decoding, the SBR Tool will // be used for the sole purpose of upsampling. m_uExtObjectType = AAC_OBJECT_TYPE_SBR; m_ulOutSamplesPerSecond = 2 * m_ulSamplesPerSecond; // Non-down-sampled SBR Tool yields twice the output rate. // Double the output rate => double the samples per frame. m_uSamplesPerFrame *= 2; } } } else { m_uExtObjectType = AAC_OBJECT_TYPE_SBR; // Table 1.15A, Note 3 // Extension Audio Object has explicitly signalled SBR. // Therefore, the output sample rate is set to the given // extension sampling rate signalled at the end of the // Audio Specific Config. m_ulOutSamplesPerSecond = pASConfig->GetSampleRate(); // Extension Sample Rate if(m_ulOutSamplesPerSecond == m_ulSamplesPerSecond || m_ulOutSamplesPerSecond > MAX_SBR_OUT_SAMPLE_RATE) { // Section 1.6.5.4 // The down sampled SBR Tool shall be operated if the // output sample rate would otherwise exceed the max // allowed output sample rate, or if the extension // sample rate equals the input sample rate m_uDownSampleMode = 1; } else { // The extension sample rate should be twice in the input // sample rate. if(m_ulOutSamplesPerSecond != (2 * m_ulSamplesPerSecond)) { result = HXR_INVALID_PARAMETER; } else { // Non-down-sampled SBR Tool yields twice the output rate. // Double the output rate => double the samples per frame. m_uSamplesPerFrame *= 2;; } } } // update the codec delay m_ulCodecDelayInSamples = 2 * m_uSamplesPerFrame; if(SUCCEEDED(result)) { result = SetFourCC(); } if(SUCCEEDED(result)) { SetProfile(pASConfig->GetObjectType()); } return result; }