gpt-3.5-turbo-0301· openai
from WildChat-4.8M
这是x264encoderopen部分代码,给每一行做注释 x264_t *x264encoderopen( x264paramt *param ) { x264_t h;…
- User
这是x264_encoder_open部分代码,给每一行做注释 x264_t *x264_encoder_open( x264_param_t *param ) { x264_t *h; char buf[1000], *p; int i_slicetype_length;
codeCHECKED_MALLOCZERO( h, sizeof(x264_t) ); /* Create a copy of param */ // 拷贝参数 memcpy( &h->param, param, sizeof(x264_param_t) ); if( param->param_free ) param->param_free( param );#if HAVE_INTEL_DISPATCHER x264_intel_dispatcher_override(); #endif
code// 初始化线程 if( x264_threading_init() ) { x264_log( h, X264_LOG_ERROR, "unable to initialize threading\n" ); goto fail; } // 检查参数合法性 if( validate_parameters( h, 1 ) < 0 ) goto fail; // 打开量化矩阵文件 if( h->param.psz_cqm_file ) if( x264_cqm_parse_file( h, h->param.psz_cqm_file ) < 0 ) goto fail; // 2pass的输入和输出文件 if( h->param.rc.psz_stat_out ) h->param.rc.psz_stat_out = strdup( h->param.rc.psz_stat_out ); if( h->param.rc.psz_stat_in ) h->param.rc.psz_stat_in = strdup( h->param.rc.psz_stat_in ); // 对帧率和时间基数约分 x264_reduce_fraction( &h->param.i_fps_num, &h->param.i_fps_den ); x264_reduce_fraction( &h->param.i_timebase_num, &h->param.i_timebase_den ); /* Init x264_t */ // 对帧数赋初值 h->i_frame = -1; h->i_frame_num = 0; // I帧的id赋值 if( h->param.i_avcintra_class ) h->i_idr_pic_id = 5; else h->i_idr_pic_id = 0; // 时间基准太大 if( (uint64_t)h->param.i_timebase_den * 2 > UINT32_MAX ) { x264_log( h, X264_LOG_ERROR, "Effective timebase denominator %u exceeds H.264 maximum\n", h->param.i_timebase_den ); goto fail; } // 设置vui的长宽 set_aspect_ratio( h, &h->param, 1 ); // 初始化sps、pps x264_sps_init( h->sps, h->param.i_sps_id, &h->param ); x264_sps_init_scaling_list( h->sps, &h->param ); x264_pps_init( h->pps, h->param.i_sps_id, &h->param, h->sps ); // level是否合法 x264_validate_levels( h, 1 ); // 色度量化参数 h->chroma_qp_table = i_chroma_qp_table + 12 + h->pps->i_chroma_qp_index_offset; // 初始化量化参数 if( x264_cqm_init( h ) < 0 ) goto fail; // 以宏块为单位的长宽 h->mb.i_mb_width = h->sps->i_mb_width; h->mb.i_mb_height = h->sps->i_mb_height; // 宏块数 h->mb.i_mb_count = h->mb.i_mb_width * h->mb.i_mb_height; h->mb.chroma_h_shift = CHROMA_FORMAT == CHROMA_420 || CHROMA_FORMAT == CHROMA_422; h->mb.chroma_v_shift = CHROMA_FORMAT == CHROMA_420; - Assistant
// 分配内存给量化矩阵 CHECKED_MALLOC( h->quant4x4, sizeof(int16_t)616 ); CHECKED_MALLOC( h->quant8x8, sizeof(int16_t)264 );
code