int i, j;
int i_mb_count = h->mb.i_mb_count;
- int i_stride;
- int i_lines;
+ int i_stride, i_width, i_lines;
int i_padv = PADV << h->param.b_interlaced;
if( !frame ) return NULL;
memset( frame, 0, sizeof(x264_frame_t) );
/* allocate frame data (+64 for extra data for me) */
- i_stride = ( ( h->param.i_width + 15 ) & -16 )+ 2*PADH;
+ i_width = ( ( h->param.i_width + 15 ) & -16 );
+ i_stride = i_width + 2*PADH;
i_lines = ( ( h->param.i_height + 15 ) & -16 );
if( h->param.b_interlaced )
i_lines = ( i_lines + 31 ) & -32;
i_divw = 2;
}
frame->i_stride[i] = i_stride / i_divw;
+ frame->i_width[i] = i_width / i_divw;
frame->i_lines[i] = i_lines / i_divh;
CHECKED_MALLOC( frame->buffer[i],
frame->i_stride[i] * ( frame->i_lines[i] + 2*i_padv / i_divh ) );
frame->plane[i] = ((uint8_t*)frame->buffer[i]) +
frame->i_stride[i] * i_padv / i_divh + PADH / i_divw;
}
- frame->i_stride[3] = 0;
- frame->i_lines[3] = 0;
- frame->buffer[3] = NULL;
- frame->plane[3] = NULL;
frame->filtered[0] = frame->plane[0];
for( i = 0; i < 3; i++ )
if( h->frames.b_have_lowres )
{
- frame->i_stride_lowres = frame->i_stride[0]/2 + PADH;
+ frame->i_width_lowres = frame->i_width[0]/2;
+ frame->i_stride_lowres = frame->i_width_lowres + 2*PADH;
frame->i_lines_lowres = frame->i_lines[0]/2;
for( i = 0; i < 4; i++ )
{
/* YUV buffer */
int i_plane;
- int i_stride[4];
- int i_lines[4];
+ int i_stride[3];
+ int i_width[3];
+ int i_lines[3];
int i_stride_lowres;
+ int i_width_lowres;
int i_lines_lowres;
- uint8_t *plane[4];
+ uint8_t *plane[3];
uint8_t *filtered[4]; /* plane[0], H, V, HV */
uint8_t *lowres[4]; /* half-size copy of input frame: Orig, H, V, HV */
uint16_t *integral;
void x264_frame_deblock( x264_t *h );
void x264_frame_deblock_row( x264_t *h, int mb_y );
-void x264_frame_filter( int cpu, x264_frame_t *frame, int b_interlaced, int mb_y, int b_end );
-void x264_frame_init_lowres( int cpu, x264_frame_t *frame );
+void x264_frame_filter( x264_t *h, x264_frame_t *frame, int mb_y, int b_end );
+void x264_frame_init_lowres( x264_t *h, x264_frame_t *frame );
void x264_deblock_init( int cpu, x264_deblock_function_t *pf );
extern void x264_hpel_filter_mmxext( uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, uint8_t *src,
int i_stride, int i_width, int i_height );
-void x264_frame_filter( int cpu, x264_frame_t *frame, int b_interlaced, int mb_y, int b_end )
+void x264_frame_filter( x264_t *h, x264_frame_t *frame, int mb_y, int b_end )
{
+ const int b_interlaced = h->sh.b_mbaff;
const int x_inc = 16, y_inc = 16;
const int stride = frame->i_stride[0] << b_interlaced;
+ const int width = stride + frame->i_width[0] - frame->i_stride[0];
int start = (mb_y*16 >> b_interlaced) - 8;
int height = ((b_end ? frame->i_lines[0] : mb_y*16) >> b_interlaced) + 8;
int x, y;
mb_y >>= b_interlaced;
#ifdef HAVE_MMX
- if ( cpu & X264_CPU_MMXEXT )
+ if( h->param.cpu & X264_CPU_MMXEXT )
{
// buffer = 4 for deblock + 3 for 6tap, rounded to 8
int offs = start*stride - 8;
frame->filtered[2] + offs,
frame->filtered[3] + offs,
frame->plane[0] + offs,
- stride, stride - 48, height - start );
+ stride, width + 16, height - start );
}
else
#endif
uint8_t *p_h = frame->filtered[1] + y * stride - 8;
uint8_t *p_v = frame->filtered[2] + y * stride - 8;
uint8_t *p_c = frame->filtered[3] + y * stride - 8;
- for( x = -8; x < stride - 64 + 8; x += x_inc )
+ for( x = -8; x < width + 8; x += x_inc )
{
mc_hh( p_in, stride, p_h, stride, x_inc, y_inc );
mc_hv( p_in, stride, p_v, stride, x_inc, y_inc );
}
}
-void x264_frame_init_lowres( int cpu, x264_frame_t *frame )
+void x264_frame_init_lowres( x264_t *h, 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;
+ const int i_width2 = frame->i_width_lowres;
int x, y, i;
for( y = 0; y < frame->i_lines_lowres - 1; y++ )
{
if( b_hpel )
{
x264_frame_expand_border( h, h->fdec, min_y, b_end );
- x264_frame_filter( h->param.cpu, h->fdec, h->sh.b_mbaff, min_y, b_end );
+ x264_frame_filter( h, h->fdec, min_y, b_end );
x264_frame_expand_border_filtered( h, h->fdec, min_y, b_end );
}
x264_frame_push( h->frames.next, fenc );
if( h->frames.b_have_lowres )
- x264_frame_init_lowres( h->param.cpu, fenc );
+ x264_frame_init_lowres( h, fenc );
if( h->frames.i_input <= h->frames.i_delay + 1 - h->param.i_threads )
{