Rate control (RC) is crucial for video codec to control bit-stream such that the coding efficiency is maximized without violating the constraints imposed by the bandwidth, buffer size and the constant end-to-end delay. To solve MAD dilemma caused by data-dependency between RC and ratedistortion optimization (RDO), a Macroblock (MB) level rate control algorithm with context-adaptive mean absolute difference (MAD) prediction model is proposed in this paper. 2D sliding window combined with temporal ordering is used for model update, and the reference MAD is computed by considering spatial information relativity. Simulations based on JM software show that the proposed model achieves higher peak-signal-noise-ratio (PSNR) and more accurate rate match than the original JVT-G012 algorithm. A gain up to 0.63dB is observed on luminance PSNR, and 0.58dB on PSNR includes both luminance and chrominance components. Average gains are 0.35dB and 0.29dB, respectively. Meanwhile, the average rate mismatch is reduced by 88%.