aboutsummaryrefslogtreecommitdiff
path: root/webrtc/modules/video_processing/test/writeYUV420file.m
blob: 359445009bd93620692ff285903271fa352f8db2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function writeYUV420file(filename, Y, U, V)
% writeYUV420file(filename, Y, U, V)

fid = fopen(filename,'wb');
if fid==-1
    error(['Cannot open file ' filename]);
end

numFrames=size(Y,3);

for k=1:numFrames
   % Write luminance
   fwrite(fid,uint8(Y(:,:,k).'), 'uchar');

   % Write U channel
   fwrite(fid,uint8(U(:,:,k).'), 'uchar');

   % Write V channel
   fwrite(fid,uint8(V(:,:,k).'), 'uchar');
end

fclose(fid);