x264中Encode_frame函数解析
2019-04-15 17:46发布
生成海报
点击打开链接
[cpp] view
plaincopy
-
static int Encode_frame( x264_t *h, hnd_t hout, x264_picture_t *pic )
-
{
-
x264_picture_t pic_out;
-
x264_nal_t *nal;
-
int i_nal, i;
-
int i_file = 0;
-
-
if( x264_encoder_encode( h, &nal, &i_nal, pic, &pic_out ) < 0 )
-
{
-
fprintf( stderr, "x264 [error]: x264_encoder_encode failed
" );
-
}
-
-
for( i = 0; i < i_nal; i++ )
-
{
-
int i_size;
-
-
if( mux_buffer_size < nal[i].i_payload * 3/2 + 4 )
-
{
-
mux_buffer_size = nal[i].i_payload * 2 + 4;
-
x264_free( mux_buffer );
-
mux_buffer = x264_malloc( mux_buffer_size );
-
}
-
-
i_size = mux_buffer_size;
-
x264_nal_encode( mux_buffer, &i_size, 1, &nal[i] );
-
i_file += p_write_nalu( hout, mux_buffer, i_size );
-
}
-
if (i_nal)
-
p_set_eop( hout, &pic_out );
-
-
return i_file;
-
}
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮