function PixelStreamingDesignHDLTestBench
% VISIONHDLGAMMA_TB  Provide test bench for HDL code generation 

%   Copyright 2014 The MathWorks, Inc.

% frm2pix converts an input frame to a stream of pixels and control structures
frm2pix = visionhdl.FrameToPixels(...
        'VideoFormat','custom',...
        'ActivePixelsPerLine',40,...
        'ActiveVideoLines',20,...
        'TotalPixelsPerLine',50,...
        'TotalVideoLines',30,...
        'StartingActiveLine',2,...
        'FrontPorch',5); 
[actPixPerLine,actLine,numPixPerFrm] = getparamfromfrm2pix(frm2pix);

% pix2frm converts a pixel stream and control structures to a full frame
pix2frm = visionhdl.PixelsToFrame(...
        'VideoFormat','Custom',...
        'ActivePixelsPerLine',actPixPerLine,...
        'ActiveVideoLines',actLine);                 

% videoIn reads a rhinos video
videoIn = vision.VideoFileReader(... 
        'Filename','rhinos.avi',...
        'ImageColorSpace','Intensity',...
        'VideoOutputDataType','uint8');
                   
viewer = vision.DeployableVideoPlayer(...
        'Size','Custom',...
        'CustomSize',[2*actPixPerLine actLine]*5);
       
pixOutVec = zeros(numPixPerFrm,1,'uint8');
ctrlOutVec = repmat(pixelcontrolstruct,numPixPerFrm,1);

numFrm = 10;
tic;
for f = 1:numFrm       
    frmFull = step(videoIn);        % Get a new frame  
    frmIn = imresize(frmFull, [actLine actPixPerLine]); % Reduce the frame size
    [pixInVec,ctrlInVec] = step(frm2pix,frmIn);                   
    for p = 1:numPixPerFrm            
        [pixOutVec(p),ctrlOutVec(p)] = PixelStreamingDesignHDLDesign(pixInVec(p),ctrlInVec(p));                                              
    end         
    frmOut = step(pix2frm,pixOutVec,ctrlOutVec);
            
    step(viewer,[frmIn frmOut]);
end
t = toc;

fprintf('\n%d frames have been processed in %.2f seconds.\n',numFrm,t);
fprintf('Average frame rate is %.2f frames/second.\n',numFrm/t);