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

📄 hamaro_binsrch.c

📁 机顶盒Hamaro解调器驱动。包含自动搜台
💻 C
📖 第 1 页 / 共 2 页
字号:
    unsigned short edge = STS_GetEdge();
#endif /* HAMARO_WIN_DEBUG */

    STS_AdjustFilledBufferLengthToPower2();
    STS_GetFilledBufferLength(&filled_buffer_length);
    
#if HAMARO_WIN_DEBUG        
    STS_SetUseMainBuffer(False); /* use sub buffer */
    if (edge == STS_EDGE_RISING)
    {
        STS_SetPowerSpectrumLogFormat(2); 
        //STS_LogPowerSpectrum();
    }
    else
    {
        STS_SetPowerSpectrumLogFormat(3); 
    		//STS_LogPowerSpectrum();
    }

    STSDBG_WR_UNSIGNED_LN("[BINSRCH_BeginEnter] filled_buffer_length = ", filled_buffer_length);

    STS_GetFirstFreq(&freq);
    STSDBG_WR_UNSIGNED_LN("[BINSRCH_BeginEnter] First freq = ", freq);

    STS_GetLastFreq(&freq);
    STSDBG_WR_UNSIGNED_LN("[BINSRCH_BeginEnter] Last freq = ", freq);
#endif /* HAMARO_WIN_DEBUG */
    STS_MoveExInit(filled_buffer_length>>1);
}

static void   
BINSRCH_Begin()
{
    HAMARO_STS_SAMPLE* p_samples;
    
    p_samples = STS_GetSamples();

    s_curvature = STS_BinSearchCurvatureTest(*p_samples->p_power[0],
                                             *p_samples->p_power[1], 
                                             *p_samples->p_power[2],
                                             STS_CURVATURE_TEST_THRESH);
}

static BOOL   
BINSRCH_Begin2ReadyCriterion()
{
    HAMARO_STS_SAMPLE* p_samples;
    unsigned short edge;

    if (s_curvature == CURVATURE_STRAIGHT)
    {
        p_samples = STS_GetSamples();
        edge = STS_GetEdge();
        inflection_point_hz = *p_samples->p_freq[1]; 
        if (edge == STS_EDGE_RISING) 
        {
            left_inflection_point_power = *p_samples->p_power[1];
        }
        return (True);
    }
	return (False);
}

static STATE* 
BINSRCH_Begin2Ready()
{
    DBG_CHECK_FSM_LIMITS(&bin_search_ready_state);
	return &bin_search_ready_state; 
}

static BOOL   
BINSRCH_Begin2ConcaveCriterion()
{
    if (s_curvature == CURVATURE_CONCAVE)
    {
        return (True);
    }
	return (False);
}

static STATE* 
BINSRCH_Begin2Concave()
{
    DBG_CHECK_FSM_LIMITS(&bin_search_concave_state);
	return &bin_search_concave_state;
}

static BOOL   
BINSRCH_Begin2ConvexCriterion()
{
    if (s_curvature == CURVATURE_CONVEX)
    {
        return (True);
    }
	return (False);
}

static STATE* 
BINSRCH_Begin2Convex()
{
    DBG_CHECK_FSM_LIMITS(&bin_search_convex_state);
	return &bin_search_convex_state;
}


/* -- Binary search Concave state -- */
static void   
BINSRCH_Concave()
{
    HAMARO_STS_SAMPLE* p_samples = STS_GetSamples();
    unsigned short edge = STS_GetEdge();
    
    if (edge == STS_EDGE_FALLING)
    {
        if (STS_MoveLeftEx() == False)
        {
            inflection_point_hz = *p_samples->p_freq[1]; 
        }
    }
    else if (edge == STS_EDGE_RISING)
    {
        if (STS_MoveRightEx() == False)
        {
            inflection_point_hz = *p_samples->p_freq[1]; 
            left_inflection_point_power = *p_samples->p_power[1];
        }
    }

    s_curvature = STS_BinSearchCurvatureTest(*p_samples->p_power[0],
                                             *p_samples->p_power[1], 
                                             *p_samples->p_power[2],
                                             STS_CURVATURE_TEST_THRESH);
}

static BOOL   
BINSRCH_Concave2ReadyCriterion()
{
    HAMARO_STS_SAMPLE* p_samples = STS_GetSamples();    

    if (s_curvature == CURVATURE_STRAIGHT || ((*p_samples->p_freq[2] - *p_samples->p_freq[0]) <= (2 * BINSEARCH_RESOLUTION)))
    {
        unsigned short edge = STS_GetEdge();

        inflection_point_hz = *p_samples->p_freq[1];
        if (edge == STS_EDGE_RISING) 
        {
            left_inflection_point_power = *p_samples->p_power[1];
        }
        STSDBG_WR_STR("[BINSRCH_Concave2ReadyCriterion]", True);
        STSDBG_WR_UNSIGNED_LN("[Inflection point] = ", inflection_point_hz);
        return (True);
    }
	return (False);
}

static STATE* 
BINSRCH_Concave2Ready()
{
    DBG_CHECK_FSM_LIMITS(&bin_search_ready_state);
	return &bin_search_ready_state;
}

static BOOL   
BINSRCH_Concave2ConvexCriterion()
{
    if (s_curvature == CURVATURE_CONVEX)
    {
        return (True);
    }
	return (False);
}

static STATE* 
BINSRCH_Concave2Convex()
{
    DBG_CHECK_FSM_LIMITS(&bin_search_convex_state);
	return &bin_search_convex_state;
}


/* -- Binary search Convex state -- */
static void   
BINSRCH_Convex()
{
    HAMARO_STS_SAMPLE* p_samples = STS_GetSamples();
    unsigned short edge = STS_GetEdge();

    if (edge == STS_EDGE_FALLING)
    {
        if (STS_MoveRightEx() == False)
        {
            inflection_point_hz = *p_samples->p_freq[1]; 
        }
    }
    else if (edge == STS_EDGE_RISING)
    {
        if (STS_MoveLeftEx() == False)
        {
            inflection_point_hz = *p_samples->p_freq[1]; 
            left_inflection_point_power = *p_samples->p_power[1];
        }
    }

    s_curvature = STS_BinSearchCurvatureTest(*p_samples->p_power[0],
                                             *p_samples->p_power[1], 
                                             *p_samples->p_power[2],
                                             STS_CURVATURE_TEST_THRESH);
}

static BOOL   
BINSRCH_Convex2ReadyCriterion()
{
    HAMARO_STS_SAMPLE* p_samples = STS_GetSamples();
    
    if (s_curvature == CURVATURE_STRAIGHT || ((*p_samples->p_freq[2] - *p_samples->p_freq[0]) <= (2 * BINSEARCH_RESOLUTION)))
    {
        unsigned short edge = STS_GetEdge();

        inflection_point_hz = *p_samples->p_freq[1];   
        if (edge == STS_EDGE_RISING) 
        {
            left_inflection_point_power = *p_samples->p_power[1];
        }
        STSDBG_WR_STR ("[BINSRCH_Convex2ReadyCriterion]", True);
        STSDBG_WR_UNSIGNED_LN ("[Inflection point] = ", inflection_point_hz);
        return (True);
    }
	return (False);
}

static STATE* 
BINSRCH_Convex2Ready()
{
    DBG_CHECK_FSM_LIMITS(&bin_search_ready_state);
	return &bin_search_ready_state;
}

static BOOL   
BINSRCH_Convex2ConcaveCriterion()
{
    if (s_curvature == CURVATURE_CONCAVE)
    {
        return (True);
    }
	return (False);
}

static STATE* 
BINSRCH_Convex2Concave()
{
    DBG_CHECK_FSM_LIMITS(&bin_search_concave_state);
	return &bin_search_concave_state;
}

/* -- Binary search Ready state -- */
static void   
BINSRCH_ReadyEnter()
{
}

/* other functions */
unsigned long
BINSRCH_GetInflectionPoint()
{
    return inflection_point_hz;
}

unsigned short
BINSRCH_GetLeftInflectionPointPower()
{
    return left_inflection_point_power;
}

#endif /* HAMARO_SCAN_THE_SKY */

⌨️ 快捷键说明

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