/* threading */
-
-#ifdef HAVE_PTHREAD
void x264_frame_cond_broadcast( x264_frame_t *frame, int i_lines_completed )
{
x264_pthread_mutex_lock( &frame->mutex );
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 )
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 );
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 )
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
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 */
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 );
}
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);
}
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;
}
}