Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [ vlcStream ] = vlc( runSymbols )
- % huffman table --> take each combination and encode in a stream
- getTheGlobals;
- global d15a;
- global d15b;
- global d16a;
- global d16b;
- global d17a;
- global d17b;
- rows = size(runSymbols);
- % Col 1 = run length
- % Col 2 = level
- runLength = runSymbols(:, 1);
- level = runSymbols(:, 2);
- ESCAPE_CODE = '000001';
- END_SEQ = '10';
- vlcStream = [];
- %% Find row which has the keypair
- for i = 1:rows
- [tf, index]=ismember(d15a, runSymbols(i,:), 'rows');
- row = find(index);
- if ~isempty(row) % If found in table 15
- s = sign(level(i)) < 0;
- data = sprintf('%s%d', d15b{row}, s);
- else % Go to tables 16/17
- % Find row in RL tables
- [tf, index] = ismember(d16a, runLength(i), 'rows');
- row_length = find(index);
- % Find row in Levels tables
- [tf, index] = ismember(d17a, level(i), 'rows');
- row_level = find(index);
- % Concatenate with Escape code
- data = sprintf('%s%s%s',ESCAPE_CODE, d16b{row_length}, d17b{row_level} );
- end
- % Add to stream
- vlcStream = [vlcStream data];
- end
- % EOB
- vlcStream = [ vlcStream END_SEQ];
- end
Advertisement