Fe++
24th August 2009, 15:59
Hi dear community,
I'm studying on the code of x264.c for implementing an encoder that take an YUV420 picture and encode an h264 frame.
In particular, I observe this function
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\n" );
}
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;
}
In this function, where I can extract the complete encoded frame? is mux_buffer the frame that i can save in file? i don't find any comment that suggest where is store the encoded frame, please help me. Thanks in advance.
Best regards
I'm studying on the code of x264.c for implementing an encoder that take an YUV420 picture and encode an h264 frame.
In particular, I observe this function
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\n" );
}
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;
}
In this function, where I can extract the complete encoded frame? is mux_buffer the frame that i can save in file? i don't find any comment that suggest where is store the encoded frame, please help me. Thanks in advance.
Best regards