function [ enc_order ] = get_enc_order( GOP_structure )
%GET_ENC_ORDER Summary of this function goes here
%   Detailed explanation goes here


disp_order = (1:length(GOP_structure));
enc_order = zeros(1,length(GOP_structure));
n = 0;
while n<length(GOP_structure)
    
    n = n+1;
    if (strcmp(GOP_structure(n),'I'))
        enc_order(n) = disp_order(n);
    elseif (strcmp(GOP_structure(n),'P'))
        enc_order(n) = disp_order(n);
    elseif (strcmp(GOP_structure(n),'B'))
        m = 0;
        while ~( strcmp( GOP_structure(n+m),'I') || strcmp( GOP_structure(n+m),'P')  )
            m = m+1;
        end
        enc_order(n) = disp_order(n+m);
        enc_order(n+1:n+m) = disp_order(n:n+m-1);
        n = n + m;
    end
    
end

end

