This work is on the MPEG codec which is supposed to take a YUV file as raw video inout. Following is the code I'm using to convert the YUV file to RGB
fileName = 'bus.y4m';
width = 250;
height = 250;
nrFrame = 10;
fileId = fopen(fileName, 'r');
subSampleMat = [1, 1; 1, 1];
dummy = fgetl(fileId); % Skip file header
%progressbar
for f = 1:nrFrame
%f
% Skip frame header
dummy = fgetl(fileId);
fprintf('fileID = %i',fileId);
% read Y component
buf = fread(fileId, width * height, 'uchar');
imgYuv(:, :, 1) = reshape(buf, width, height).'; % reshape
% read U component
buf = fread(fileId, width / 2 * height / 2, 'uchar');
buf = reshape(buf, width / 2, height / 2).';
imgYuv(:, :, 2) = kron(buf, subSampleMat); % reshape and upsample
% read V component
buf = fread(fileId, width / 2 * height / 2, 'uchar');
buf = reshape(buf, width / 2, height / 2).';
imgYuv(:, :, 3) = kron(buf, subSampleMat); % reshape and upsample
% convert YUV to RGB
imgRgb = reshape(convertYuvToRgb(reshape(imgYuv, height * width, 3)), height, width, 3);
mov(f) = im2frame(imgRgb);
progressbar(f/nrFrame)
end
fclose(fileId);
I'm getting the following error
Undefined function 'clipValue' for input arguments of type 'double'.
Error in convertYuvToRgb (line 11)
rgb = uint8(clipValue(rgb, 0, 255));
Error in conv (line 32) imgRgb = reshape(convertYuvToRgb(reshape(imgYuv, height * width, 3)), height, width,3);
Error in run (line 64)
evalin('caller', [script ';']);
What might have gone wrong??