function [ pred_MB ] = motion_prediction( MB_size, ref, u, v, m, n )
% returns returns a predicted MB
%
% MB_size: macro block (MB) size in pixels (can be different for luma and chroma!)
% ref: the reference picture (! - not MB)
% u,v: the coordinates of the MB in ref frame which matches the best to MB to predict (in MB coordinates, not pixels (!))
% m,n: position of MB_in (in MB coordinates, not pixel (!))

ind_y = (m-1)*MB_size + 1 + v : m*MB_size + v;
ind_x = (n-1)*MB_size + 1 + u : n*MB_size + u;
ind_x(ind_x<=0) = 1;     ind_x(ind_x>=size(ref,2)) = size(ref,2);
ind_y(ind_y<=0) = 1;     ind_y(ind_y>=size(ref,1)) = size(ref,1);

pred_MB = ref( ind_y ,   ind_x, : );


