亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? mixengine.cpp

?? symbian 下的helix player源代碼
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
/* ***** BEGIN LICENSE BLOCK *****
 * Source last modified: $Id: mixengine.cpp,v 1.9.8.2 2004/07/09 02:08:08 hubbe Exp $
 * 
 * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved.
 * 
 * The contents of this file, and the files included with this file,
 * are subject to the current version of the RealNetworks Public
 * Source License (the "RPSL") available at
 * http://www.helixcommunity.org/content/rpsl unless you have licensed
 * the file under the current version of the RealNetworks Community
 * Source License (the "RCSL") available at
 * http://www.helixcommunity.org/content/rcsl, in which case the RCSL
 * will apply. You may also obtain the license terms directly from
 * RealNetworks.  You may not use this file except in compliance with
 * the RPSL or, if you have a valid RCSL with RealNetworks applicable
 * to this file, the RCSL.  Please see the applicable RPSL or RCSL for
 * the rights, obligations and limitations governing use of the
 * contents of the file.
 * 
 * Alternatively, the contents of this file may be used under the
 * terms of the GNU General Public License Version 2 or later (the
 * "GPL") in which case the provisions of the GPL are applicable
 * instead of those above. If you wish to allow use of your version of
 * this file only under the terms of the GPL, and not to allow others
 * to use your version of this file under the terms of either the RPSL
 * or RCSL, indicate your decision by deleting the provisions above
 * and replace them with the notice and other provisions required by
 * the GPL. If you do not delete the provisions above, a recipient may
 * use your version of this file under the terms of any one of the
 * RPSL, the RCSL or the GPL.
 * 
 * This file is part of the Helix DNA Technology. RealNetworks is the
 * developer of the Original Code and owns the copyrights in the
 * portions it created.
 * 
 * This file, and the files included with this file, is distributed
 * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY
 * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS
 * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET
 * ENJOYMENT OR NON-INFRINGEMENT.
 * 
 * Technology Compatibility Kit Test Suite(s) Location:
 *    http://www.helixcommunity.org/content/tck
 * 
 * Contributor(s):
 * 
 * ***** END LICENSE BLOCK ***** */


#include "hlxclib/limits.h"
#include "hlxclib/math.h"

#include "hxtypes.h"
#include "hxresult.h"
#include "hxassert.h"

#include "mixengine.h"

#ifdef HELIX_FEATURE_RESAMPLER
#include "RAResampler.h"
#endif
#ifdef HELIX_FEATURE_GAINTOOL
#include "gain.h"
#endif
#ifdef HELIX_FEATURE_CROSSFADE
#include "xfade.h"
#endif
#ifdef HELIX_FEATURE_LIMITER
#include "limiter.h"
#endif

#include "math64.h"

/*
   DSP is done in four stages:

   - input
       (1)
   - downmix
       (2)
   - resample
       (3)
   - mix into output buffer
       (4)

   In the general case, the number of samples/call in pipes (1)-(4) will be different.
   In the code below, nSamples_X denotes the number of samples flowing in pipe (X)

   For example, say the input is 44100 stereo, and the output is 22050 3-channel,
   and for some reason we want to downmix to mono before going through the resampler.

   if nSamples_4 == 3 * 22050 (1 seconds' worth of data), then
   nSamples_3 = nSamples_4 / 3 = 22050
   nSamples_2 = nSamples_3 * 44100/22050 = 44100
   nSamples_1 = nSamples_2 * 2 / 1 = 88200 (1 seconds' worth of data on the input);

   For convenience, we might also count sample frames; that's samples_X/nChannels_X

   All variables are postfixed by a indicator of where they are relevant; for example,
   m_nChannels_2 is the number of channels after downmixing, and m_pBuffer3 is the
   output buffer for the resampler.
 */

HXAudioSvcMixEngine::HXAudioSvcMixEngine()
: m_pResampler(0)
, m_pXFader(0)
, m_pGaintool(0)
, m_pLimiter(0)
, m_pBuffer_1(0)
, m_pBuffer_3(0)
, m_ulBytesPerSample(2)
, m_eCrossFadeDirection(FADE_OUT)
{}

HXAudioSvcMixEngine::~HXAudioSvcMixEngine()
{
    releaseResources() ;
}

void HXAudioSvcMixEngine::releaseResources()
{
    if (m_pBuffer_1) delete[] m_pBuffer_1 ; m_pBuffer_1 = 0 ;
    if (m_pBuffer_3) delete[] m_pBuffer_3 ; m_pBuffer_3 = 0 ;
#ifdef HELIX_FEATURE_RESAMPLER
    if (m_pResampler) delete m_pResampler ; m_pResampler = 0 ;
#endif /* HELIX_FEATURE_RESAMPLER */
#ifdef HELIX_FEATURE_GAINTOOL
    if (m_pGaintool) gainFree(m_pGaintool); m_pGaintool = 0 ;
#endif
#ifdef HELIX_FEATURE_CROSSFADE
    if (m_pXFader) XFader_free(m_pXFader) ; m_pXFader = 0 ;
#endif
#ifdef HELIX_FEATURE_LIMITER
    if (m_pLimiter) LimiterFree(m_pLimiter); m_pLimiter = 0 ;
#endif
}

HX_RESULT HXAudioSvcMixEngine::SetSampleConverter(CAudioSvcSampleConverter *pCvt)
{
    m_pCvt = pCvt ;
    return pCvt ? HXR_OK : HXR_FAIL ;
}

HX_RESULT HXAudioSvcMixEngine::SetupResamplerAndBuffers(void)
{
    if (m_ulSampleRate_1_2 == m_ulSampleRate_3_4)
    {
        // no resampling.
        m_ulChunkSize_1 = BATCHSIZE ;
        m_ulChunkSize_1 -= m_ulChunkSize_1 % m_nChannels_1 ;

        m_ulChunkSize_3 = m_ulChunkSize_1 / m_nChannels_1 * m_nChannels_2_3 ;
    }
    else
    {
#ifdef HELIX_FEATURE_RESAMPLER
        HX_RESULT res = RAExactResampler::Create(&m_pResampler, m_ulSampleRate_1_2, m_ulSampleRate_3_4, m_nChannels_2_3, NBITS_PER_AUDIOSAMPLE == 32 ? RAExactResampler::_INT32 : RAExactResampler::_INT16) ;
        if (FAILED(res))
            return res ;

        // determine the chunk sizes on resampler input and output. The side with the higher
        // datarate limits the other side
        if (m_nChannels_1 * m_ulSampleRate_1_2 <= m_nChannels_2_3 * m_ulSampleRate_3_4)
        {
            // downstream (right) side limits size
            m_ulChunkSize_3 = BATCHSIZE ;
            m_ulChunkSize_3 -= m_ulChunkSize_3 % m_nChannels_2_3 ;

            m_ulChunkSize_1 = m_pResampler->GetMinInput(m_ulChunkSize_3) ;
            m_ulChunkSize_1 = m_ulChunkSize_1 / m_nChannels_2_3 * m_nChannels_1 ;
        }
        else
        {
            // upstream side limits size
            m_ulChunkSize_1 = BATCHSIZE ;
            m_ulChunkSize_1 -= m_ulChunkSize_1 % m_nChannels_1 ;

            m_ulChunkSize_3 = m_pResampler->GetMaxOutput(m_ulChunkSize_1 / m_nChannels_1 * m_nChannels_2_3) ;

            while ((unsigned)m_pResampler->GetMinInput(m_ulChunkSize_3) / m_nChannels_2_3 * m_nChannels_1 > m_ulChunkSize_1)
            {
                m_ulChunkSize_3 -= m_nChannels_2_3 ;
            }
        }
        m_ulBufferSize_3 = m_ulChunkSize_3 + m_pResampler->GetMaxOutput(m_nChannels_2_3) ;
#else
        return HXR_NOTIMPL ; // resampler not implemented
#endif
    }

    // delay allocation of sample buffers until they are really needed.

    return HXR_OK ;
}

HX_RESULT HXAudioSvcMixEngine::Init(INT32 sampleRateIn, INT32 sampleRateOut, INT32 nChannelsIn, INT32 nChannelsOut)
{
    HX_RESULT res = HXR_OK;

    // if we have any old resources, release them
    releaseResources() ;

    m_ulSampleRate_1_2 = sampleRateIn ;
    m_ulSampleRate_3_4 = sampleRateOut ;
    m_nChannels_1 = nChannelsIn ;
    m_nChannels_4 = nChannelsOut ;

    res = SetupUpDownmix() ;
    if (FAILED(res))
        return res ;

    res = SetupResamplerAndBuffers() ;
    if (FAILED(res))
        return res ;

#ifdef HELIX_FEATURE_GAINTOOL
    m_pGaintool = gainInit(m_ulSampleRate_1_2, m_nChannels_2_3, 0) ;
    gainSetTimeConstant(100, m_pGaintool) ;
    gainSetImmediate(0.0, m_pGaintool) ;
#endif

#ifdef HELIX_FEATURE_CROSSFADE
    m_pXFader = XFader_init(m_ulSampleRate_1_2, m_nChannels_2_3, XFader_sin2tab) ;
#endif
    ResetTimeLineInMillis(0) ;

    return HXR_OK ;
}

HX_RESULT HXAudioSvcMixEngine::ResetTimeLineInMillis(INT64 millis)
{
    m_nOutputSamplesLeft_3 = 0 ;
    m_ulResamplerPhase = 0;

    // set the cross fade state to fade in, and the time so that we are post the fade in.
    m_llFadeStart = INT_MIN ; // or something really small
    m_eCrossFadeDirection = FADE_OUT ;
    m_bPastXFade = FALSE ;

    // sample frames, output side
    m_llTimestamp_1 = m_llTimestamp_3 = millis * m_ulSampleRate_3_4 / 1000 ; // llBufTimeInSamples / m_nChannels_4 ;
    // correct for resampler delay
#ifdef HELIX_FEATURE_RESAMPLER
    if (m_pResampler) m_llTimestamp_1 -= m_pResampler->GetDelay() ;
#endif
    // convert to input side, samples
    m_llTimestamp_1 = m_llTimestamp_1 * m_ulSampleRate_1_2 / m_ulSampleRate_3_4 * m_nChannels_1 ;
    // convert to samples
    m_llTimestamp_3 *= m_nChannels_2_3 ;

    return HXR_OK ;
}

void HXAudioSvcMixEngine::GetMixRange(UINT32 nBytesToMix, INT64& llStart, INT64& llEnd) const
{
    llStart = m_llTimestamp_1 ;
    // number of samples at resampler output
    INT32 n = nBytesToMix / (m_ulBytesPerSample * m_nChannels_4) * m_nChannels_2_3 ;
#ifdef HELIX_FEATURE_RESAMPLER
    if (m_pResampler) n = m_pResampler->GetMinInput(n - m_nOutputSamplesLeft_3) ;
#endif
    // number of samples at input
    n = n / m_nChannels_2_3 * m_nChannels_1 ;
    llEnd   = llStart + n ;
}

INT64 HXAudioSvcMixEngine::GetNextMixTimeMillis(void) const
{
    return INT64(1000) * m_llTimestamp_1 / (m_ulSampleRate_1_2 * m_nChannels_1) ;
}

HX_RESULT HXAudioSvcMixEngine::SetOutputBytesPerSample(UINT32 bps)
{
    switch (bps)
    {
    case 2: case 4:
        m_ulBytesPerSample = bps ; return HXR_OK ;
    default:
        return HXR_FAIL ;
    }
}

#ifdef HELIX_FEATURE_GAINTOOL
// set the volume. This is in tenth of a dB. 0 == unity gain, 6dB = twice as loud, -6 = half as loud
HX_RESULT HXAudioSvcMixEngine::SetVolume(INT32 tenthOfDB, BOOL bImmediate)
{
    // currently, no amplification is allowed
    if (tenthOfDB > 0)
        return HXR_FAIL ;

    if (bImmediate)
	gainSetImmediate(0.1f * tenthOfDB, m_pGaintool) ;
    else
	gainSetSmooth(0.1f * tenthOfDB, m_pGaintool) ;

    return HXR_OK ;
}

INT32 HXAudioSvcMixEngine::HXVolume2TenthOfDB(INT32 vol)
{
    // if HX_MAX_VOLUME changes from 100, need to re-generate the table below.
    // here is the formula:
    //  if (vol > 0) return (INT32)(100.0 * log10((float)vol / HX_MAX_VOLUME )) ;
    //  else return -2000 ;

#define HX_MAX_VOLUME 100
    static const unsigned char vol2TenthOfDb[HX_MAX_VOLUME+1] = {
        255,

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产成人av一区二区三区在线| 日本一区二区三区免费乱视频 | 欧美日韩精品三区| 亚洲精品美国一| 在线观看免费一区| 首页国产丝袜综合| 日韩免费观看高清完整版| 久久99久久精品| 欧美激情综合五月色丁香| caoporen国产精品视频| 一区二区三区国产| 在线不卡中文字幕播放| 精品一区二区三区不卡| 国产欧美精品国产国产专区| 91视频国产资源| 午夜国产精品一区| 久久久久久久久久久久久女国产乱| 国产麻豆9l精品三级站| 日韩美女视频一区| 91精品国产色综合久久不卡蜜臀| 精品一区二区三区视频在线观看| 亚洲成人激情自拍| 精品免费99久久| 99在线视频精品| 日韩国产在线观看一区| 久久久久高清精品| 在线观看日韩国产| 国产又黄又大久久| 亚洲精品国产a| 欧美www视频| 色香色香欲天天天影视综合网| 日韩成人免费电影| 国产精品久久久久一区| 欧美卡1卡2卡| 不卡电影一区二区三区| 免费在线观看不卡| 亚洲欧洲精品一区二区三区不卡| 在线播放日韩导航| 99久久伊人久久99| 激情综合色播五月| 亚洲成av人片一区二区三区| 日本一区二区三区视频视频| 欧美人xxxx| caoporn国产精品| 国产曰批免费观看久久久| 亚洲电影中文字幕在线观看| 中文字幕第一页久久| 欧美一区二区三区免费观看视频| 99久久免费精品高清特色大片| 久久国产福利国产秒拍| 亚洲图片一区二区| 亚洲色图.com| 国产网红主播福利一区二区| 欧美一区二区日韩一区二区| 在线视频国内自拍亚洲视频| 成人性视频网站| 激情综合五月婷婷| 免费成人av在线播放| 亚洲国产精品人人做人人爽| 成人欧美一区二区三区视频网页| 久久精品欧美一区二区三区麻豆| 91精品国产综合久久久久久漫画 | 日本中文字幕一区二区视频| 日韩一区在线播放| 欧美国产激情二区三区| 亚洲精品一区二区三区在线观看| 欧美无人高清视频在线观看| 91久久精品网| 色综合久久中文综合久久牛| 成人黄色在线看| 国产成a人无v码亚洲福利| 69堂精品视频| 欧美午夜精品理论片a级按摩| 在线观看视频一区| 欧美在线免费观看亚洲| 91福利精品第一导航| 色哟哟一区二区| 91黄色激情网站| 91免费观看在线| 91浏览器打开| 在线精品视频一区二区三四| 91激情在线视频| 欧美亚洲动漫另类| 欧美日韩高清在线播放| 欧美丰满嫩嫩电影| 日韩欧美一区中文| 欧美不卡视频一区| 国产亚洲女人久久久久毛片| 国产亚洲污的网站| 亚洲欧洲美洲综合色网| 亚洲精品美腿丝袜| 舔着乳尖日韩一区| 久久97超碰国产精品超碰| 激情欧美一区二区| 成人午夜视频在线| 在线区一区二视频| 91精品国产综合久久久蜜臀图片| 精品国内片67194| 国产欧美一区二区精品性色超碰| 国产精品另类一区| 亚洲精品免费电影| 久久成人18免费观看| 高潮精品一区videoshd| 在线免费观看成人短视频| 欧美绝品在线观看成人午夜影视| 日韩精品一区二| 国产精品视频免费| 亚洲成人自拍网| 国内久久精品视频| 91丝袜高跟美女视频| 91麻豆精品国产91久久久使用方法| 欧美一个色资源| 亚洲欧洲色图综合| 日本强好片久久久久久aaa| 国产美女视频一区| 日本韩国精品在线| 久久精品亚洲麻豆av一区二区| 亚洲精选一二三| 美国一区二区三区在线播放| 99在线视频精品| 日韩欧美中文一区二区| 亚洲男人的天堂在线aⅴ视频 | 天使萌一区二区三区免费观看| 久久成人免费网站| 国产欧美精品一区aⅴ影院 | 国产福利电影一区二区三区| 在线观看视频91| 久久久久国产精品麻豆| 亚洲18影院在线观看| 国产成人8x视频一区二区| 欧美二区三区的天堂| 国产精品国产三级国产普通话蜜臀| 亚洲v中文字幕| 成人avav在线| 欧美变态tickle挠乳网站| 一区二区三区欧美视频| 国产成人免费9x9x人网站视频| 欧美日韩国产一级片| 1024亚洲合集| 国产一区不卡视频| 欧美久久一二区| 亚洲精品一二三区| 国产99久久久国产精品免费看| 欧美日韩国产影片| 亚洲天天做日日做天天谢日日欢| 国产一区二区三区美女| 欧美一区午夜视频在线观看| 亚洲精品国产a久久久久久| 成人永久免费视频| 国产亚洲精品超碰| 国内精品久久久久影院色| 777色狠狠一区二区三区| 亚洲免费视频成人| caoporm超碰国产精品| 国产亲近乱来精品视频| 国产在线视频精品一区| 日韩欧美国产小视频| 奇米四色…亚洲| 欧美一区二区三区的| 天堂va蜜桃一区二区三区| 在线国产电影不卡| 国产酒店精品激情| 欧美一区二区福利在线| 日韩高清不卡一区二区三区| 欧美视频一区二区三区四区| 亚洲日穴在线视频| 91精品福利视频| 一区二区三区精品视频| 在线影院国内精品| 亚洲最大成人综合| 欧美性色综合网| 香蕉加勒比综合久久 | 欧美日韩一区在线| 亚洲国产视频网站| 欧美美女一区二区在线观看| 午夜一区二区三区视频| 4438x亚洲最大成人网| 免费观看在线综合色| 精品少妇一区二区三区视频免付费| 久久精品国产色蜜蜜麻豆| 欧美sm美女调教| 国产精品原创巨作av| 国产精品少妇自拍| 日本高清不卡aⅴ免费网站| 亚洲成年人网站在线观看| 91精品免费观看| 国产综合色在线视频区| 欧美国产乱子伦| 日本久久精品电影| 青青草视频一区| 久久久精品免费免费| 91玉足脚交白嫩脚丫在线播放| 亚洲自拍偷拍av| 欧美一区二视频| 国产福利视频一区二区三区| 亚洲欧美激情插| 日韩一区二区三| 成人免费视频视频在线观看免费 | 精品久久久久久久一区二区蜜臀| 国产精品一卡二卡在线观看|