您好,欢迎来到步遥情感网。
搜索
您的当前位置:首页int get_frame_total_yuv( hnd_t handle )函数解释

int get_frame_total_yuv( hnd_t handle )函数解释

来源:步遥情感网
  1.   语句i_frame_total = p_get_frame_total( opt->hin ),实现得到输入文件的总帧数,由于p_get_frame_total = get_frame_total_yuv(见Parse()函数),所以调用函数int get_frame_total_yuv( hnd_t handle ),在文件muxers.c中,原型如下:

int get_frame_total_yuv( hnd_t handle )
{
    yuv_input_t *h = handle;
    int i_frame_total = 0;

    if( !fseek( h->fh, 0, SEEK_END ) )
    {
        uint_t i_size = ftell( h->fh );                           //计算出文件的大小
        fseek( h->fh, 0, SEEK_SET );                           //作用是将文件指针放到文件开始位置
        i_frame_total = (int)(i_size / ( h->width * h->height * 3 / 2 ));

     //计算总的帧数, 这里乘以1.5是因为一个编码单位是一个亮度块加2个色度块,大小上等于1.5个亮度块
    }

    return i_frame_total;
}

    其中fseek中第一个参数为文件指针,第二个参数为偏移量,起始位置,SEEK_END 表示文件尾,SEEK_SET 表示文件头。fseek作用是将定位文件指针,用于随机访问。ftell函数返回h->fh的指针偏移位值.

    2.    i_frame_total -= opt->i_seek;
           if( ( i_frame_total == 0 || param->i_frame_total < i_frame_total )
          && param->i_frame_total > 0 )
           i_frame_total = param->i_frame_total;
          param->i_frame_total = i_frame_total;

          //获取要求编码的帧数param->i_frame_total。

     3.   x2_t *x2_encoder_open   ( x2_param_t *param ), 在文件encoder.c中,对不正确的2_t结构体(h的类型是2_t * )参数进行修改,并对各结构体参数、编码、预测等需要的参数进行初始化。

  x2_t *x2_encoder_open   ( x2_param_t *param )
{
    x2_t *h = x2_malloc( sizeof( x2_t ) );   //分配空间并进行初始化,x2_malloc( )在common.c中。
    int i;

    memset( h, 0, sizeof( x2_t ) );    

    /* Create a copy of param */
    memcpy( &h->param, param, sizeof( x2_param_t ) );    //创建param的副本

             //memcpy原型:extern void *memcpy(void *dest, void *src, unsigned int count);


                  //用法:#include <string.h>, 功能:由src所指内存区域复制count个字节到dest所指内存区域。
                  //说明:src和dest所指内存区域不能重叠,函数返回指向dest的指针。

    if( x2_validate_parameters( h ) < 0 )   //   函数x2_validate_parameters( h )在encoder.c中,

                                                                   //   功能为判断参数是否有效,并对不合适的参数进行修改

    {
        x2_free( h );
        return NULL;
    }

    if( h->param.psz_cqm_file )
        if( x2_cqm_parse_file( h, h->param.psz_cqm_file ) < 0 )
        {
            x2_free( h );
            return NULL;
        }

............

}


因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- obuygou.com 版权所有 赣ICP备2024042798号-5

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务