/*
raw 420 yuv file operation(操作)
打开一个文件,已经文件路径
*/
int open_file_yuv( char *psz_filename, hnd_t *p_handle, x264_param_t *p_param )
{
yuv_input_t *h = malloc(sizeof(yuv_input_t));//申请一块内存给yuv_input_t结构体用,内存地址存到h
/*对结构体字段赋值*/
h->width = p_param->i_width;
h->height = p_param->i_height;
h->next_frame = 0;
if( !strcmp(psz_filename, "-") )
h->fh = stdin;//这句应该是代表文件已经打开,这儿只需接收这个句柄/地址
else
h->fh = fopen(psz_filename, "rb");/* 打开一个文件 文件顺利打开后,指向该流的文件指针就会被返回。如果文件打开失败则返回NULL,并把错误代码存在errno 中 */
//rb 以只读方式打开文件,该文件必须存在,加入b 字符用来告诉函数库打开的文件为二进制文件,而非纯文字文件
if( h->fh == NULL )//文件打开失败
return -1;
*p_handle = (hnd_t)h;//把此处打开的文件的指针传出去,左边的p_handle在调本函数时以参数方式提供过来
printf("文件名:%s\n",psz_filename);//zjh
return 0;
}