gakonst

Untitled

Jan 1st, 2018
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.39 KB | None | 0 0
  1. function [ vlcStream ] = vlc( runSymbols )
  2.     % huffman table --> take each combination and encode in a  stream
  3.     getTheGlobals;
  4.     global d15a;
  5.     global d15b;
  6.     global d16a;
  7.     global d16b;
  8.     global d17a;
  9.     global d17b;
  10.    
  11.     rows = size(runSymbols);
  12.     % Col 1 = run length
  13.     % Col 2 = level
  14.     runLength = runSymbols(:, 1);
  15.     level     = runSymbols(:, 2);
  16.    
  17.     ESCAPE_CODE = '000001';
  18.     END_SEQ     = '10';
  19.     vlcStream = [];
  20.     %% Find row which has the keypair
  21.     for i = 1:rows
  22.         [tf, index]=ismember(d15a, runSymbols(i,:), 'rows');
  23.         row = find(index);
  24.         if ~isempty(row) % If found in table 15
  25.             s = sign(level(i)) < 0;
  26.             data = sprintf('%s%d', d15b{row}, s);
  27.         else % Go to tables 16/17
  28.             % Find row in RL tables
  29.             [tf, index] = ismember(d16a, runLength(i), 'rows');
  30.             row_length = find(index);
  31.            
  32.             % Find row in Levels tables
  33.             [tf, index] = ismember(d17a, level(i), 'rows');
  34.             row_level = find(index);
  35.            
  36.             % Concatenate with Escape code
  37.             data = sprintf('%s%s%s',ESCAPE_CODE, d16b{row_length}, d17b{row_level} );
  38.            
  39.         end
  40.  
  41.         % Add to stream
  42.         vlcStream = [vlcStream data];      
  43.        
  44.     end
  45.    
  46.    % EOB
  47.    vlcStream = [ vlcStream END_SEQ];
  48.        
  49. end
Advertisement