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

📄 vout_synchro.c

📁 video linux conference
💻 C
📖 第 1 页 / 共 2 页
字号:
        if( p_synchro->i_nb_ref < 2 )        {            b_decode = 0;        }        else if( (S.i_n_b + 1) * period > S.p_tau[P_CODING_TYPE] )        {            b_decode = (pts - now) > (TAU_PRIME(B_CODING_TYPE) + DELTA);        }        else        {            b_decode = 0;        }    }    if( !b_decode )    {        S.i_not_chosen_pic++;    }    return( b_decode );#undef S#undef TAU_PRIME}/***************************************************************************** * vout_SynchroTrash : Update counters when we trash a picture *****************************************************************************/void vout_SynchroTrash( vout_synchro_t * p_synchro ){    p_synchro->i_trashed_pic++;    p_synchro->i_nb_ref = p_synchro->i_trash_nb_ref;}/***************************************************************************** * vout_SynchroDecode : Update timers when we decide to decode a picture *****************************************************************************/void vout_SynchroDecode( vout_synchro_t * p_synchro ){    p_synchro->decoding_start = mdate();    p_synchro->i_nb_ref = p_synchro->i_dec_nb_ref;}/***************************************************************************** * vout_SynchroEnd : Called when the image is totally decoded *****************************************************************************/void vout_SynchroEnd( vout_synchro_t * p_synchro, int i_coding_type,                      vlc_bool_t b_garbage ){    mtime_t     tau;    if( !b_garbage )    {        tau = mdate() - p_synchro->decoding_start;        /* If duration too high, something happened (pause ?), so don't         * take it into account. */        if( tau < 3 * p_synchro->p_tau[i_coding_type]             || ( !p_synchro->pi_meaningful[i_coding_type]                   && tau < MAX_VALID_TAU ) )        {            /* Mean with average tau, to ensure stability. */            p_synchro->p_tau[i_coding_type] =                (p_synchro->pi_meaningful[i_coding_type]                 * p_synchro->p_tau[i_coding_type] + tau)                / (p_synchro->pi_meaningful[i_coding_type] + 1);            if( p_synchro->pi_meaningful[i_coding_type] < MAX_PIC_AVERAGE )            {                p_synchro->pi_meaningful[i_coding_type]++;            }        }    }}/***************************************************************************** * vout_SynchroDate : When an image has been decoded, ask for its date *****************************************************************************/mtime_t vout_SynchroDate( vout_synchro_t * p_synchro ){    /* No need to lock, since PTS are only used by the video parser. */    return p_synchro->current_pts;}/***************************************************************************** * vout_SynchroNewPicture: Update stream structure and PTS *****************************************************************************/void vout_SynchroNewPicture( vout_synchro_t * p_synchro, int i_coding_type,                             int i_repeat_field, mtime_t next_pts,                             mtime_t next_dts, int i_current_rate,                             vlc_bool_t b_low_delay ){    mtime_t         period = 1000000 * 1001 / p_synchro->i_frame_rate                              * i_current_rate / INPUT_RATE_DEFAULT;#if 0    mtime_t         now = mdate();#endif    p_synchro->i_current_rate = i_current_rate;    switch( i_coding_type )    {    case I_CODING_TYPE:        if( p_synchro->i_eta_p             && p_synchro->i_eta_p != p_synchro->i_n_p )        {#if 0            if( !p_synchro->b_quiet )                msg_Dbg( p_synchro,                         "stream periodicity changed from P[%d] to P[%d]",                         p_synchro->i_n_p, p_synchro->i_eta_p );#endif            p_synchro->i_n_p = p_synchro->i_eta_p;        }        p_synchro->i_eta_p = p_synchro->i_eta_b = 0;        p_synchro->i_trash_nb_ref = 0;        if( p_synchro->i_nb_ref < 2 )            p_synchro->i_dec_nb_ref = p_synchro->i_nb_ref + 1;        else            p_synchro->i_dec_nb_ref = p_synchro->i_nb_ref;#if 0        if( !p_synchro->b_quiet )            msg_Dbg( p_synchro, "I("I64Fd") P("I64Fd")[%d] B("I64Fd")"                  "[%d] YUV("I64Fd") : trashed %d:%d/%d",                  p_synchro->p_tau[I_CODING_TYPE],                  p_synchro->p_tau[P_CODING_TYPE],                  p_synchro->i_n_p,                  p_synchro->p_tau[B_CODING_TYPE],                  p_synchro->i_n_b,                  p_synchro->i_render_time,                  p_synchro->i_not_chosen_pic,                  p_synchro->i_trashed_pic -                  p_synchro->i_not_chosen_pic,                  p_synchro->i_pic );        p_synchro->i_trashed_pic = p_synchro->i_not_chosen_pic            = p_synchro->i_pic = 0;#else        if( p_synchro->i_pic >= 100 )        {            if( !p_synchro->b_quiet && p_synchro->i_trashed_pic != 0 )                msg_Dbg( p_synchro, "decoded %d/%d pictures",                         p_synchro->i_pic                           - p_synchro->i_trashed_pic,                         p_synchro->i_pic );            p_synchro->i_trashed_pic = p_synchro->i_not_chosen_pic                = p_synchro->i_pic = 0;        }#endif        break;    case P_CODING_TYPE:        p_synchro->i_eta_p++;        if( p_synchro->i_eta_b             && p_synchro->i_eta_b != p_synchro->i_n_b )        {#if 0            if( !p_synchro->b_quiet )                msg_Dbg( p_synchro,                         "stream periodicity changed from B[%d] to B[%d]",                         p_synchro->i_n_b, p_synchro->i_eta_b );#endif            p_synchro->i_n_b = p_synchro->i_eta_b;        }        p_synchro->i_eta_b = 0;        p_synchro->i_dec_nb_ref = 2;        p_synchro->i_trash_nb_ref = 0;        break;    case B_CODING_TYPE:        p_synchro->i_eta_b++;        p_synchro->i_dec_nb_ref = p_synchro->i_trash_nb_ref            = p_synchro->i_nb_ref;        break;    }    p_synchro->current_pts += p_synchro->i_current_period                                        * (period >> 1);#define PTS_THRESHOLD   (period >> 2)    if( i_coding_type == B_CODING_TYPE || b_low_delay )    {        /* A video frame can be displayed 1, 2 or 3 times, according to         * repeat_first_field, top_field_first, progressive_sequence and         * progressive_frame. */        p_synchro->i_current_period = i_repeat_field;        if( next_pts )        {            if( (next_pts - p_synchro->current_pts                    > PTS_THRESHOLD                  || p_synchro->current_pts - next_pts                    > PTS_THRESHOLD) && !p_synchro->b_quiet )            {                msg_Warn( p_synchro, "vout synchro warning: pts != "                          "current_date ("I64Fd")",                          p_synchro->current_pts                              - next_pts );            }            p_synchro->current_pts = next_pts;        }    }    else    {        p_synchro->i_current_period = p_synchro->i_backward_period;        p_synchro->i_backward_period = i_repeat_field;        if( p_synchro->backward_pts )        {            if( next_dts &&                (next_dts - p_synchro->backward_pts                    > PTS_THRESHOLD                  || p_synchro->backward_pts - next_dts                    > PTS_THRESHOLD) && !p_synchro->b_quiet )            {                msg_Warn( p_synchro, "backward_pts != dts ("I64Fd")",                           next_dts                               - p_synchro->backward_pts );            }            if( (p_synchro->backward_pts - p_synchro->current_pts                    > PTS_THRESHOLD                  || p_synchro->current_pts - p_synchro->backward_pts                    > PTS_THRESHOLD) && !p_synchro->b_quiet )            {                msg_Warn( p_synchro,                          "backward_pts != current_pts ("I64Fd")",                          p_synchro->current_pts                              - p_synchro->backward_pts );            }            p_synchro->current_pts = p_synchro->backward_pts;            p_synchro->backward_pts = 0;        }        else if( next_dts )        {            if( (next_dts - p_synchro->current_pts                    > PTS_THRESHOLD                  || p_synchro->current_pts - next_dts                    > PTS_THRESHOLD) && !p_synchro->b_quiet )            {                msg_Warn( p_synchro, "dts != current_pts ("I64Fd")",                          p_synchro->current_pts                              - next_dts );            }            /* By definition of a DTS. */            p_synchro->current_pts = next_dts;            next_dts = 0;        }        if( next_pts )        {            /* Store the PTS for the next time we have to date an I picture. */            p_synchro->backward_pts = next_pts;            next_pts = 0;        }    }#undef PTS_THRESHOLD#if 0    /* Removed for incompatibility with slow motion */    if( p_synchro->current_pts + DEFAULT_PTS_DELAY < now )    {        /* We cannot be _that_ late, something must have happened, reinit         * the dates. */        if( !p_synchro->b_quiet )            msg_Warn( p_synchro, "PTS << now ("I64Fd"), resetting",                      now - p_synchro->current_pts - DEFAULT_PTS_DELAY );        p_synchro->current_pts = now + DEFAULT_PTS_DELAY;    }    if( p_synchro->backward_pts         && p_synchro->backward_pts + DEFAULT_PTS_DELAY < now )    {        /* The same. */        p_synchro->backward_pts = 0;    }#endif    p_synchro->i_pic++;}

⌨️ 快捷键说明

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