Hi,

I found this programming from a book entitled 'Analysis of the MPEG-1 Layer III (MP3) Algorithm Using MATLAB
'.

% P 6.1 Seek the synchronization word and place the bitstream pointer

function [bs, retval] = seek_sync(bs, sync, N)

global ALIGNING
maxi = round(2^N - 1);
aligning = rem(bs.totbit, ALIGNING);

if (aligning)
[bs val] = getbits(bs, (ALIGNING-aligning));
end

[bs val] = getbits(bs, N);

while (bitand(val, maxi) ~= sync) & ~(bs.eobs)
val = bitshift(val, ALIGNING);
[bs v] = getbits(bs, ALIGNING);
val = bitor(val, v);
end

if bs.eobs
retval = 0;
else
retval = 1;
end


I have some doubts:
1. Why bs can be input and output arguments at the same time?
2. Is getbits same as bitget?

Looking forward for reply.

Thanks.