Commit acee2d51 authored by Loren Merritt's avatar Loren Merritt

don't allocate lowres planes if they won't be used (i.e. in the 2nd pass).



git-svn-id: svn://svn.videolan.org/x264/trunk@320 df754926-b1dd-0310-bc7b-ec298dee348c
parent 938c52d2
......@@ -279,6 +279,7 @@ struct x264_t
int i_max_ref0;
int i_max_ref1;
int i_delay; /* Number of frames buffered for B reordering */
int b_have_lowres; /* Whether 1/2 resolution luma planes are being used */
} frames;
/* current frame being encoded */
......
......@@ -37,6 +37,8 @@ x264_frame_t *x264_frame_new( x264_t *h )
int i_stride;
int i_lines;
memset( frame, 0, sizeof(x264_frame_t) );
/* allocate frame data (+64 for extra data for me) */
i_stride = ( ( h->param.i_width + 15 )&0xfffff0 )+ 64;
i_lines = ( ( h->param.i_height + 15 )&0xfffff0 );
......@@ -76,14 +78,17 @@ x264_frame_t *x264_frame_new( x264_t *h )
frame->i_stride[0] * 32 + 32;
}
frame->i_stride_lowres = frame->i_stride[0]/2 + 32;
frame->i_lines_lowres = frame->i_lines[0]/2;
for( i = 0; i < 4; i++ )
if( h->frames.b_have_lowres )
{
frame->buffer[7+i] = x264_malloc( frame->i_stride_lowres *
( frame->i_lines[0]/2 + 64 ) );
frame->lowres[i] = ((uint8_t*)frame->buffer[7+i]) +
frame->i_stride_lowres * 32 + 32;
frame->i_stride_lowres = frame->i_stride[0]/2 + 32;
frame->i_lines_lowres = frame->i_lines[0]/2;
for( i = 0; i < 4; i++ )
{
frame->buffer[7+i] = x264_malloc( frame->i_stride_lowres *
( frame->i_lines[0]/2 + 64 ) );
frame->lowres[i] = ((uint8_t*)frame->buffer[7+i]) +
frame->i_stride_lowres * 32 + 32;
}
}
frame->i_poc = -1;
......
......@@ -544,6 +544,8 @@ x264_t *x264_encoder_open ( x264_param_t *param )
h->frames.i_max_ref0 = h->param.i_frame_reference;
h->frames.i_max_ref1 = h->sps->vui.i_num_reorder_frames;
h->frames.i_max_dpb = h->sps->vui.i_max_dec_frame_buffering + 1;
h->frames.b_have_lowres = !h->param.rc.b_stat_read
&& ( h->param.rc.b_cbr || h->param.b_bframe_adaptive );
for( i = 0; i < X264_BFRAME_MAX + 3; i++ )
{
......@@ -1201,7 +1203,8 @@ int x264_encoder_encode( x264_t *h,
x264_frame_put( h->frames.next, fenc );
x264_frame_init_lowres( h->param.cpu, fenc );
if( h->frames.b_have_lowres )
x264_frame_init_lowres( h->param.cpu, fenc );
if( h->frames.i_input <= h->frames.i_delay )
{
......
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