?? mc.c
字號:
} else { mc_copy( src1, i_src_stride, dst, i_dst_stride, i_width, i_height ); }}static uint8_t *get_ref( uint8_t *src[4], int i_src_stride, uint8_t *dst, int * i_dst_stride, int mvx,int mvy, int i_width, int i_height ){ int qpel_idx = ((mvy&3)<<2) + (mvx&3); int offset = (mvy>>2)*i_src_stride + (mvx>>2); uint8_t *src1 = src[hpel_ref0[qpel_idx]] + offset + ((mvy&3) == 3) * i_src_stride; if( qpel_idx & 5 ) /* qpel interpolation needed */ { uint8_t *src2 = src[hpel_ref1[qpel_idx]] + offset + ((mvx&3) == 3); pixel_avg( dst, *i_dst_stride, src1, i_src_stride, src2, i_src_stride, i_width, i_height ); return dst; } else { *i_dst_stride = i_src_stride; return src1; }}/* full chroma mc (ie until 1/8 pixel)*/static void motion_compensation_chroma( uint8_t *src, int i_src_stride, uint8_t *dst, int i_dst_stride, int mvx, int mvy, int i_width, int i_height ){ uint8_t *srcp; int x, y; const int d8x = mvx&0x07; const int d8y = mvy&0x07; const int cA = (8-d8x)*(8-d8y); const int cB = d8x *(8-d8y); const int cC = (8-d8x)*d8y; const int cD = d8x *d8y; src += (mvy >> 3) * i_src_stride + (mvx >> 3); srcp = &src[i_src_stride]; for( y = 0; y < i_height; y++ ) { for( x = 0; x < i_width; x++ ) { dst[x] = ( cA*src[x] + cB*src[x+1] + cC*srcp[x] + cD*srcp[x+1] + 32 ) >> 6; } dst += i_dst_stride; src = srcp; srcp += i_src_stride; }}#define MC_COPY(W) \static void mc_copy_w##W( uint8_t *dst, int i_dst, uint8_t *src, int i_src, int i_height ) \{ \ mc_copy( src, i_src, dst, i_dst, W, i_height ); \}MC_COPY( 16 )MC_COPY( 8 )MC_COPY( 4 )void x264_mc_init( int cpu, x264_mc_functions_t *pf ){ pf->mc_luma = mc_luma; pf->get_ref = get_ref; pf->mc_chroma = motion_compensation_chroma; pf->avg[PIXEL_16x16]= pixel_avg_16x16; pf->avg[PIXEL_16x8] = pixel_avg_16x8; pf->avg[PIXEL_8x16] = pixel_avg_8x16; pf->avg[PIXEL_8x8] = pixel_avg_8x8; pf->avg[PIXEL_8x4] = pixel_avg_8x4; pf->avg[PIXEL_4x8] = pixel_avg_4x8; pf->avg[PIXEL_4x4] = pixel_avg_4x4; pf->avg[PIXEL_4x2] = pixel_avg_4x2; pf->avg[PIXEL_2x4] = pixel_avg_2x4; pf->avg[PIXEL_2x2] = pixel_avg_2x2; pf->avg_weight[PIXEL_16x16]= pixel_avg_weight_16x16; pf->avg_weight[PIXEL_16x8] = pixel_avg_weight_16x8; pf->avg_weight[PIXEL_8x16] = pixel_avg_weight_8x16; pf->avg_weight[PIXEL_8x8] = pixel_avg_weight_8x8; pf->avg_weight[PIXEL_8x4] = pixel_avg_weight_8x4; pf->avg_weight[PIXEL_4x8] = pixel_avg_weight_4x8; pf->avg_weight[PIXEL_4x4] = pixel_avg_weight_4x4; pf->avg_weight[PIXEL_4x2] = pixel_avg_weight_4x2; pf->avg_weight[PIXEL_2x4] = pixel_avg_weight_2x4; pf->avg_weight[PIXEL_2x2] = pixel_avg_weight_2x2; pf->copy[PIXEL_16x16] = mc_copy_w16; pf->copy[PIXEL_8x8] = mc_copy_w8; pf->copy[PIXEL_4x4] = mc_copy_w4;//#ifdef HAVE_MMXEXT
// if( cpu&X264_CPU_MMXEXT ) {
// x264_mc_mmxext_init( pf );
// pf->mc_chroma = x264_mc_chroma_mmxext;
// }
//#endif
#ifdef HAVE_SSE2 if( cpu&X264_CPU_SSE2 ) x264_mc_sse2_init( pf );#endif#ifdef ARCH_PPC if( cpu&X264_CPU_ALTIVEC ) x264_mc_altivec_init( pf );#endif}extern void x264_horizontal_filter_mmxext( uint8_t *dst, int i_dst_stride, uint8_t *src, int i_src_stride, int i_width, int i_height );extern void x264_center_filter_mmxext( uint8_t *dst1, int i_dst1_stride, uint8_t *dst2, int i_dst2_stride, uint8_t *src, int i_src_stride, int i_width, int i_height );void x264_frame_filter( int cpu, x264_frame_t *frame ){ const int x_inc = 16, y_inc = 16; const int stride = frame->i_stride[0]; int x, y; pf_mc_t int_h = mc_hh; pf_mc_t int_v = mc_hv; pf_mc_t int_hv = mc_hc;//#ifdef HAVE_MMXEXT
// if ( cpu & X264_CPU_MMXEXT )
// {
// x264_horizontal_filter_mmxext(frame->filtered[1] - 8 * stride - 8, stride,
// frame->plane[0] - 8 * stride - 8, stride,
// stride - 48, frame->i_lines[0] + 16);
// x264_center_filter_mmxext(frame->filtered[2] - 8 * stride - 8, stride,
// frame->filtered[3] - 8 * stride - 8, stride,
// frame->plane[0] - 8 * stride - 8, stride,
// stride - 48, frame->i_lines[0] + 16);
// }
// else
//#endif
{ for( y = -8; y < frame->i_lines[0]+8; y += y_inc ) { uint8_t *p_in = frame->plane[0] + y * stride - 8; uint8_t *p_h = frame->filtered[1] + y * stride - 8; uint8_t *p_v = frame->filtered[2] + y * stride - 8; uint8_t *p_hv = frame->filtered[3] + y * stride - 8; for( x = -8; x < stride - 64 + 8; x += x_inc ) { int_h( p_in, stride, p_h, stride, x_inc, y_inc ); int_v( p_in, stride, p_v, stride, x_inc, y_inc ); int_hv( p_in, stride, p_hv, stride, x_inc, y_inc ); p_h += x_inc; p_v += x_inc; p_hv += x_inc; p_in += x_inc; } } } /* generate integral image: * each entry in frame->integral is the sum of all luma samples above and * to the left of its location (inclusive). * this allows us to calculate the DC of any rectangle by looking only * at the corner entries. * individual entries will overflow 16 bits, but that's ok: * we only need the differences between entries, and those will be correct * as long as we don't try to evaluate a rectangle bigger than 16x16. * likewise, we don't really have to init the edges to 0, leaving garbage * there wouldn't affect the results.*/ if( frame->integral ) { memset( frame->integral - 32 * stride - 32, 0, stride * sizeof(uint16_t) ); for( y = -31; y < frame->i_lines[0] + 32; y++ ) { uint8_t *ref = frame->plane[0] + y * stride - 32; uint16_t *line = frame->integral + y * stride - 32; uint16_t v = line[0] = 0; for( x = 1; x < stride; x++ ) line[x] = v += ref[x] + line[x-stride] - line[x-stride-1]; } }}void x264_frame_init_lowres( int cpu, x264_frame_t *frame ){ // FIXME: tapfilter? const int i_stride = frame->i_stride[0]; const int i_stride2 = frame->i_stride_lowres; const int i_width2 = i_stride2 - 64; int x, y, i; for( y = 0; y < frame->i_lines_lowres - 1; y++ ) { uint8_t *src0 = &frame->plane[0][2*y*i_stride]; uint8_t *src1 = src0+i_stride; uint8_t *src2 = src1+i_stride; uint8_t *dst0 = &frame->lowres[0][y*i_stride2]; uint8_t *dsth = &frame->lowres[1][y*i_stride2]; uint8_t *dstv = &frame->lowres[2][y*i_stride2]; uint8_t *dstc = &frame->lowres[3][y*i_stride2]; for( x = 0; x < i_width2 - 1; x++ ) { dst0[x] = (src0[2*x ] + src0[2*x+1] + src1[2*x ] + src1[2*x+1] + 2) >> 2; dsth[x] = (src0[2*x+1] + src0[2*x+2] + src1[2*x+1] + src1[2*x+2] + 2) >> 2; dstv[x] = (src1[2*x ] + src1[2*x+1] + src2[2*x ] + src2[2*x+1] + 2) >> 2; dstc[x] = (src1[2*x+1] + src1[2*x+2] + src2[2*x+1] + src2[2*x+2] + 2) >> 2; } dst0[x] = (src0[2*x ] + src0[2*x+1] + src1[2*x ] + src1[2*x+1] + 2) >> 2; dstv[x] = (src1[2*x ] + src1[2*x+1] + src2[2*x ] + src2[2*x+1] + 2) >> 2; dsth[x] = (src0[2*x+1] + src1[2*x+1] + 1) >> 1; dstc[x] = (src1[2*x+1] + src2[2*x+1] + 1) >> 1; } for( i = 0; i < 4; i++ ) memcpy( &frame->lowres[i][y*i_stride2], &frame->lowres[i][(y-1)*i_stride2], i_width2 ); for( y = 0; y < 16; y++ ) for( x = 0; x < 16; x++ ) frame->i_cost_est[x][y] = -1; x264_frame_expand_border_lowres( frame );}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -