问题描述
如您所知,ref
参数可以设置每个 P 帧可以用作参考的先前帧数。
对于 B 帧,我需要同样的东西,但 ref=1
对 B 帧不起作用。
我的意思是一个 I/P 帧仅用作 B 帧的参考。
static inline int reference_update( x264_t *h )
{
if( !h->fdec->b_kept_as_ref )
{
if( h->i_thread_frames > 1 )
{
x264_frame_push_unused( h,h->fdec );
h->fdec = x264_frame_pop_unused( h,1 );
if( !h->fdec )
return -1;
}
return 0;
}
/* apply mmco from prevIoUs frame. */
for( int i = 0; i < h->sh.i_mmco_command_count; i++ )
for( int j = 0; h->frames.reference[j]; j++ )
if( h->frames.reference[j]->i_poc == h->sh.mmco[i].i_poc )
x264_frame_push_unused( h,x264_frame_shift( &h->frames.reference[j] ) );
/* move frame in the buffer */
x264_frame_push( h->frames.reference,h->fdec );
if( h->frames.reference[h->sps->i_num_ref_frames] )
x264_frame_push_unused( h,x264_frame_shift( h->frames.reference ) );
h->fdec = x264_frame_pop_unused( h,1 );
if( !h->fdec )
return -1;
return 0;
}
解决方法
没有。 B 帧根据定义是双向的,即它必须至少有 2 个参考帧(按呈现顺序一个在前一个在后),否则它根本没有意义并且它与 P 帧没有区别。