From: Jason Garrett-Glaser Date: Wed, 8 May 2013 17:48:41 +0000 (-0700) Subject: Fix invalid memcpy in sliced-threads X-Git-Url: http://www.zmx.ovh/git.videolan.org/?a=commitdiff_plain;h=b1749e204d14087a768990e8bfe964d343e0b9a9;p=x264.git Fix invalid memcpy in sliced-threads Likely didn't actually break in practice, but memcpy with src==dst is incorrect. --- diff --git a/encoder/ratecontrol.c b/encoder/ratecontrol.c index 21573018..0fc7a0a1 100644 --- a/encoder/ratecontrol.c +++ b/encoder/ratecontrol.c @@ -2593,14 +2593,16 @@ void x264_threads_distribute_ratecontrol( x264_t *h ) if( h->i_frame == 0 ) for( int i = 0; i < h->param.i_threads; i++ ) { - x264_ratecontrol_t *t = h->thread[i]->rc; - memcpy( t->row_preds, rc->row_preds, sizeof(rc->row_preds) ); + x264_t *t = h->thread[i]; + if( t != h ) + memcpy( t->rc->row_preds, rc->row_preds, sizeof(rc->row_preds) ); } for( int i = 0; i < h->param.i_threads; i++ ) { x264_t *t = h->thread[i]; - memcpy( t->rc, rc, offsetof(x264_ratecontrol_t, row_pred) ); + if( t != h ) + memcpy( t->rc, rc, offsetof(x264_ratecontrol_t, row_pred) ); t->rc->row_pred = &t->rc->row_preds[h->sh.i_type]; /* Calculate the planned slice size. */ if( rc->b_vbv && rc->frame_size_planned )