function rle = EQA3YM_rle_encoder( zigzag )
% A simple run-length encoder to make compact representation to the 0s at this point of the code,
%  you have a condensed representation of your specific image-block

places = find(zigzag);
skip = [places(1); diff(places)];
values = zigzag(places);

if zigzag(end) == 0
    skip = [skip; length(zigzag)-places(end)];
    values = [values; 0];
end

rle = [skip'; values'];
rle = rle(:);

end

