From b1749e204d14087a768990e8bfe964d343e0b9a9 Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Wed, 8 May 2013 10:48:41 -0700 Subject: [PATCH] Fix invalid memcpy in sliced-threads Likely didn't actually break in practice, but memcpy with src==dst is incorrect. --- encoder/ratecontrol.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 ) -- 2.47.3