function delays = Macro_RLC_Decoder(R,M,T,Channel)
preChannel = zeros(1,M*T);
postChannel = zeros(1,M*T+M-mod(length(Channel),M));
Conc_Channel = [preChannel Channel postChannel];
delays = zeros(1,length(Conc_Channel));
delays(Conc_Channel == 1) = -1;
No_Of_Erasures = 0;
No_Of_Parities = 0;

for index = T+1:length(Conc_Channel)/M;
    Macro_Erasures = sum(Conc_Channel((index-1)*M+1:index*M));
    if Macro_Erasures == 0;
        if No_Of_Erasures == 0;
        else
            No_Of_Erasures = No_Of_Erasures + Macro_Erasures*R;
            No_Of_Parities = No_Of_Parities + (M - Macro_Erasures)*(1-R);
        end
    else
        No_Of_Erasures = No_Of_Erasures + Macro_Erasures*R;
        No_Of_Parities = No_Of_Parities + (M - Macro_Erasures)*(1-R);
    end
    if No_Of_Parities >= No_Of_Erasures;
            delays(Conc_Channel(1:index*M) == 1) = index - ceil(find(Conc_Channel(1:index*M) == 1)/M);
            No_Of_Erasures = 0;
            No_Of_Parities = 0;
            Conc_Channel(Conc_Channel(1:index*M) == 1) = 0;
    end
end
delays = delays(length(preChannel)+1:length(Conc_Channel)-length(postChannel));