Commit a79aac14 authored by Loren Merritt's avatar Loren Merritt

cosmetics: use separate variables for frame width and stride


git-svn-id: svn://svn.videolan.org/x264/trunk@686 df754926-b1dd-0310-bc7b-ec298dee348c
parent a8650641
......@@ -32,8 +32,7 @@ x264_frame_t *x264_frame_new( x264_t *h )
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;
......@@ -41,7 +40,8 @@ x264_frame_t *x264_frame_new( x264_t *h )
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;
......@@ -59,6 +59,7 @@ x264_frame_t *x264_frame_new( x264_t *h )
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 ) );
......@@ -66,10 +67,6 @@ x264_frame_t *x264_frame_new( x264_t *h )
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++ )
......@@ -82,7 +79,8 @@ x264_frame_t *x264_frame_new( x264_t *h )
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++ )
{
......
......@@ -38,11 +38,13 @@ typedef struct
/* 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;
......@@ -105,8 +107,8 @@ void x264_frame_expand_border_mod16( x264_t *h, x264_frame_t *frame );
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 );
......
......@@ -382,10 +382,12 @@ void x264_mc_init( int cpu, x264_mc_functions_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;
......@@ -395,7 +397,7 @@ void x264_frame_filter( int cpu, x264_frame_t *frame, int b_interlaced, int mb_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;
......@@ -404,7 +406,7 @@ void x264_frame_filter( int cpu, x264_frame_t *frame, int b_interlaced, int mb_y
frame->filtered[2] + offs,
frame->filtered[3] + offs,
frame->plane[0] + offs,
stride, stride - 48, height - start );
stride, width + 16, height - start );
}
else
#endif
......@@ -415,7 +417,7 @@ void x264_frame_filter( int cpu, x264_frame_t *frame, int b_interlaced, int mb_y
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 );
......@@ -464,12 +466,12 @@ void x264_frame_filter( int cpu, x264_frame_t *frame, int b_interlaced, int mb_y
}
}
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++ )
{
......
......@@ -924,7 +924,7 @@ static void x264_fdec_filter_row( x264_t *h, int mb_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 );
}
......@@ -1299,7 +1299,7 @@ int x264_encoder_encode( x264_t *h,
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 )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment