x264代码阅读笔记,版本是20060309。
一、函数入口main x264.c
1、调用x264_param_default 设置默认的编码参数。
2、调用Parse 转换 命令行参数
3、进入Encode函数,开始编码
二、Encode x264.c
1、p_get_frame_total获取要编的总数
2、x264_encoder_open创建x264编码器,配置参数
3、p_set_outfile_param设置输出文件参数
4、x264_picture_alloc分配原始图像的内存空间
5、for 循环编码每一帧
6、Encode_frame 编码一帧图像,并nal打包
7、编完剩余的B帧
8、x264_picture_clean释放分配的图像空间
9、x264_encoder_close关闭编码器
10、p_close_infile和p_close_outfile关闭输入和输出文件。
三、Encode_frame x264.c
1、x264_encoder_encode编一帧图像
2、for循环,用x264_nal_encode打nal包,用p_write_nalu写出nal码流。
四、x264_encoder_encode Encoder.c
1、x264_frame_get 申请空间,fenc指向新空间
2、x264_frame_copy_picture 将图像数据从pic_in 拷贝到fenc
3、如果图像的宽高不是16对齐,用x264_frame_expand_border_mod16对数据进行扩展
4、x264_frame_put 将fenc放到next指针数组中
5、当使用低分辨率图像时,用