Commit 5e59162c authored by Gabriel Bouvigne's avatar Gabriel Bouvigne Committed by Fiona Glaser

Cosmetics in VBV handling

parent d4a4b3f1
......@@ -825,8 +825,6 @@ void x264_deblock_init( int cpu, x264_deblock_function_t *pf )
/* threading */
#ifdef HAVE_PTHREAD
void x264_frame_cond_broadcast( x264_frame_t *frame, int i_lines_completed )
{
x264_pthread_mutex_lock( &frame->mutex );
......@@ -843,42 +841,6 @@ void x264_frame_cond_wait( x264_frame_t *frame, int i_lines_completed )
x264_pthread_mutex_unlock( &frame->mutex );
}
void x264_frame_size_estimated_set( x264_t *h, int bits )
{
x264_pthread_mutex_lock( &h->fenc->mutex );
x264_ratecontrol_set_estimated_size(h, bits);
x264_pthread_mutex_unlock( &h->fenc->mutex );
}
int x264_frame_size_estimated_get( x264_t const *h)
{
int size;
x264_pthread_mutex_lock( &h->fenc->mutex );
size = x264_ratecontrol_get_estimated_size(h);
x264_pthread_mutex_unlock( &h->fenc->mutex );
return size;
}
#else
void x264_frame_cond_broadcast( x264_frame_t *frame, int i_lines_completed )
{}
void x264_frame_cond_wait( x264_frame_t *frame, int i_lines_completed )
{}
void x264_frame_size_estimated_set( x264_t *h, int bits )
{
x264_ratecontrol_set_estimated_size(h, bits);
}
int x264_frame_size_estimated_get( x264_t const *h)
{
int size;
size = x264_ratecontrol_set_estimated_size(h);
return size;
}
#endif
/* list operators */
void x264_frame_push( x264_frame_t **list, x264_frame_t *frame )
......
......@@ -121,9 +121,6 @@ void x264_deblock_init( int cpu, x264_deblock_function_t *pf );
void x264_frame_cond_broadcast( x264_frame_t *frame, int i_lines_completed );
void x264_frame_cond_wait( x264_frame_t *frame, int i_lines_completed );
void x264_frame_size_estimated_set( x264_t *h, int bits );
int x264_frame_size_estimated_get( x264_t const *h);
void x264_frame_push( x264_frame_t **list, x264_frame_t *frame );
x264_frame_t *x264_frame_pop( x264_frame_t **list );
void x264_frame_unshift( x264_frame_t **list, x264_frame_t *frame );
......
......@@ -127,7 +127,7 @@
#define x264_pthread_cond_init(c,f)
#define x264_pthread_cond_destroy(c)
#define x264_pthread_cond_broadcast(c)
#define x264_pthread_cond_wait(c,m) usleep(100)
#define x264_pthread_cond_wait(c,m)
#endif
/* FIXME: long isn't always the native register size (e.g. win64). */
......
......@@ -729,12 +729,18 @@ void x264_ratecontrol_delete( x264_t *h )
void x264_ratecontrol_set_estimated_size( x264_t *h, int bits )
{
x264_pthread_mutex_lock( &h->fenc->mutex );
h->rc->frame_size_estimated = bits;
x264_pthread_mutex_unlock( &h->fenc->mutex );
}
int x264_ratecontrol_get_estimated_size( x264_t const *h)
{
return h->rc->frame_size_estimated;
int size;
x264_pthread_mutex_lock( &h->fenc->mutex );
size = h->rc->frame_size_estimated;
x264_pthread_mutex_unlock( &h->fenc->mutex );
return size;
}
static void accum_p_qp_update( x264_t *h, float qp )
......@@ -919,7 +925,7 @@ void x264_ratecontrol_mb( x264_t *h, int bits )
rc->qpm = X264_MIN(X264_MAX( rc->qp, avg_qp), 51); //avg_qp could go higher than 51 due to pb_offset
i_estimated = row_bits_so_far(h, y); //FIXME: compute full estimated size
if (i_estimated > h->rc->frame_size_planned)
x264_frame_size_estimated_set(h, i_estimated);
x264_ratecontrol_set_estimated_size(h, i_estimated);
}
}
else
......@@ -975,7 +981,7 @@ void x264_ratecontrol_mb( x264_t *h, int bits )
rc->qpm --;
b1 = predict_row_size_sum( h, y, rc->qpm );
}
x264_frame_size_estimated_set(h, b1);
x264_ratecontrol_set_estimated_size(h, b1);
}
}
/* loses the fractional part of the frame-wise qp */
......@@ -1327,7 +1333,7 @@ static void update_vbv_plan( x264_t *h )
double bits = t->rc->frame_size_planned;
if( !t->b_thread_active )
continue;
bits = X264_MAX(bits, x264_frame_size_estimated_get(t));
bits = X264_MAX(bits, x264_ratecontrol_get_estimated_size(t));
rcc->buffer_fill += rcc->buffer_rate - bits;
rcc->buffer_fill = x264_clip3( rcc->buffer_fill, 0, rcc->buffer_size );
}
......@@ -1464,7 +1470,7 @@ static float rate_estimate_qscale( x264_t *h )
q += rcc->pb_offset;
rcc->frame_size_planned = predict_size( rcc->pred_b_from_p, q, h->fref1[h->i_ref1-1]->i_satd );
x264_frame_size_estimated_set(h, rcc->frame_size_planned);
x264_ratecontrol_set_estimated_size(h, rcc->frame_size_planned);
rcc->last_satd = 0;
return qp2qscale(q);
}
......@@ -1594,7 +1600,7 @@ static float rate_estimate_qscale( x264_t *h )
rcc->frame_size_planned = qscale2bits(&rce, q);
else
rcc->frame_size_planned = predict_size( &rcc->pred[h->sh.i_type], q, rcc->last_satd );
x264_frame_size_estimated_set(h, rcc->frame_size_planned);
x264_ratecontrol_set_estimated_size(h, rcc->frame_size_planned);
return q;
}
}
......
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