aboutsummaryrefslogtreecommitdiff
path: root/webrtc/modules/video_processing/main/test/unit_test/writeYUV420file.m
blob: 69a88083380306fb2acf6ff9d17323f93f55b880 (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);