步长stride以及拓展

函数:void x264_sps_init( x264_sps_t *sps, int i_id, x264_param_t *param )

语句:sps->i_mb_width = ( param->i_width + 15 ) / 16;

函数:x264_t *x264_encoder_open( x264_param_t *param )

语句:h->mb.i_mb_width = h->sps->i_mb_width;

函数:void x264_frame_expand_border_mod16( x264_t *h, x264_frame_t *frame )

{
for( int i = 0; i < frame->i_plane; i++ )
{
int i_width = h->param.i_width;
int h_shift = i && CHROMA_H_SHIFT;
int v_shift = i && CHROMA_V_SHIFT;
int i_height = h->param.i_height >> v_shift;
int i_padx = (h->mb.i_mb_width * 16 - h->param.i_width);//计算出需要拓展的宽度
int i_pady = (h->mb.i_mb_height * 16 - h->param.i_height) >> v_shift;//计算出需要拓展的高度
if( i_padx )
{
for( int y = 0; y < i_height; y++ )
pixel_memset( &frame->plane[i][yframe->i_stride[i] + i_width],//dst
&frame->plane[i][y
frame->i_stride[i] + i_width - 1-h_shift],//src
i_padx>>h_shift, sizeof(pixel)< //将最右边的像素填充到拓展区域
}

    >if( i_pady )
    {
        for( int y = i_height; y < i_height + i_pady; y++ )
            memcpy( &frame->plane[i][y*frame->i_stride[i]],
            &frame->plane[i][(i_height-(~y&PARAM_INTERLACED)-1)*frame->i_stride[i]],
            (i_width + i_padx) * sizeof(pixel) );
    }
}

}

#define ALIGN(x,a) (((x)+((a)-1))&~((a)-1))//此公式用于对齐。
比如:448= ALIGN( 432, 32);即,(432+31)&0x11100000=448

函数:static x264_frame_t *x264_frame_new( x264_t *h, int b_fdec )

语句:i_stride = align_stride( i_width + 2*PADH, align, disalign );
其中,

static int align_stride( int x, int align, int disalign )
{
x = ALIGN( x, align );
if( !(x&(disalign-1)) )
x += align;
return x;
}

你可能感兴趣的:(步长stride以及拓展)